refactor.

This commit is contained in:
Christopher Jeffrey 2016-06-12 22:41:55 -07:00
parent ebe3b3ed54
commit af8e3945b7
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -289,8 +289,9 @@ ChainEntry.prototype.getMedianTime = function getMedianTime(ancestors) {
ChainEntry.prototype.getMedianTimeAsync = function getMedianTimeAsync(callback) { ChainEntry.prototype.getMedianTimeAsync = function getMedianTimeAsync(callback) {
var self = this; var self = this;
var MEDIAN_TIMESPAN = constants.block.MEDIAN_TIMESPAN;
return this.getAncestors(constants.block.MEDIAN_TIMESPAN, function(err, ancestors) { return this.getAncestors(MEDIAN_TIMESPAN, function(err, ancestors) {
if (err) if (err)
return callback(err); return callback(err);
@ -306,7 +307,9 @@ ChainEntry.prototype.getMedianTimeAsync = function getMedianTimeAsync(callback)
*/ */
ChainEntry.prototype.isOutdated = function isOutdated(version, ancestors) { ChainEntry.prototype.isOutdated = function isOutdated(version, ancestors) {
return this.isSuperMajority(version, this.network.block.majorityRejectOutdated, ancestors); return this.isSuperMajority(version,
this.network.block.majorityRejectOutdated,
ancestors);
}; };
/** /**
@ -317,8 +320,7 @@ ChainEntry.prototype.isOutdated = function isOutdated(version, ancestors) {
*/ */
ChainEntry.prototype.isOutdatedAsync = function isOutdatedAsync(version, callback) { ChainEntry.prototype.isOutdatedAsync = function isOutdatedAsync(version, callback) {
return this.isSuperMajorityAsync( return this.isSuperMajorityAsync(version,
version,
this.network.block.majorityRejectOutdated, this.network.block.majorityRejectOutdated,
callback); callback);
}; };
@ -331,7 +333,9 @@ ChainEntry.prototype.isOutdatedAsync = function isOutdatedAsync(version, callbac
*/ */
ChainEntry.prototype.isUpgraded = function isUpgraded(version, ancestors) { ChainEntry.prototype.isUpgraded = function isUpgraded(version, ancestors) {
return this.isSuperMajority(version, this.network.block.majorityEnforceUpgrade, ancestors); return this.isSuperMajority(version,
this.network.block.majorityEnforceUpgrade,
ancestors);
}; };
/** /**
@ -342,8 +346,7 @@ ChainEntry.prototype.isUpgraded = function isUpgraded(version, ancestors) {
*/ */
ChainEntry.prototype.isUpgradedAsync = function isUpgradedAsync(version, callback) { ChainEntry.prototype.isUpgradedAsync = function isUpgradedAsync(version, callback) {
return this.isSuperMajorityAsync( return this.isSuperMajorityAsync(version,
version,
this.network.block.majorityEnforceUpgrade, this.network.block.majorityEnforceUpgrade,
callback); callback);
}; };
@ -381,8 +384,9 @@ ChainEntry.prototype.isSuperMajority = function isSuperMajority(version, require
ChainEntry.prototype.isSuperMajorityAsync = function isSuperMajorityAsync(version, required, callback) { ChainEntry.prototype.isSuperMajorityAsync = function isSuperMajorityAsync(version, required, callback) {
var self = this; var self = this;
var majorityWindow = this.network.block.majorityWindow;
return this.getAncestors(this.network.block.majorityWindow, function(err, ancestors) { return this.getAncestors(majorityWindow, function(err, ancestors) {
if (err) if (err)
return callback(err); return callback(err);