logs for deployment activation.
This commit is contained in:
parent
74c999abe3
commit
f4a70df1a0
@ -213,14 +213,16 @@ Chain.prototype._open = function open(callback) {
|
||||
|
||||
self.logger.memory();
|
||||
|
||||
self.getInitialState(function(err) {
|
||||
self.getDeploymentState(function(err, state) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
if (self.state.hasCSV())
|
||||
self.state = state;
|
||||
|
||||
if (state.hasCSV())
|
||||
self.logger.info('CSV is active.');
|
||||
|
||||
if (self.state.hasWitness())
|
||||
if (state.hasWitness())
|
||||
self.logger.info('Segwit is active.');
|
||||
|
||||
self.logger.memory();
|
||||
@ -432,6 +434,9 @@ Chain.prototype.verifyContext = function verifyContext(block, prev, callback) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
// Expose the state globally.
|
||||
self.state = state;
|
||||
|
||||
return callback(null, view);
|
||||
});
|
||||
});
|
||||
@ -509,9 +514,6 @@ Chain.prototype.verify = function verify(block, prev, callback) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
// Expose the state globally.
|
||||
self.state = state;
|
||||
|
||||
// Can't verify any further when merkleblock or headers.
|
||||
if (self.options.spv)
|
||||
return callback(null, state);
|
||||
@ -609,8 +611,11 @@ Chain.prototype.getDeployments = function getDeployments(block, prev, ancestors,
|
||||
// not have a signature. See:
|
||||
// 6a26d2ecb67f27d1fa5524763b49029d7106e91e3cc05743073461a719776192
|
||||
// 9c08a4d78931342b37fd5f72900fb9983087e6f46c4a097d8a1f52c74e28eaf6
|
||||
if (block.ts >= constants.block.BIP16_TIME)
|
||||
if (block.ts >= constants.block.BIP16_TIME) {
|
||||
state.flags |= constants.flags.VERIFY_P2SH;
|
||||
if (!this.state.hasP2SH())
|
||||
this.logger.warning('P2SH has been activated.');
|
||||
}
|
||||
|
||||
// Only allow version 2 blocks (coinbase height)
|
||||
// once the majority of blocks are using it.
|
||||
@ -635,21 +640,33 @@ Chain.prototype.getDeployments = function getDeployments(block, prev, ancestors,
|
||||
}
|
||||
|
||||
// Make sure the height contained in the coinbase is correct.
|
||||
if (block.version >= 2 && prev.isUpgraded(2, ancestors))
|
||||
if (block.version >= 2 && prev.isUpgraded(2, ancestors)) {
|
||||
state.bip34 = true;
|
||||
if (!this.state.hasBIP34())
|
||||
this.logger.warning('BIP34 has been activated.');
|
||||
}
|
||||
|
||||
// Signature validation is now enforced (bip66)
|
||||
if (block.version >= 3 && prev.isUpgraded(3, ancestors))
|
||||
if (block.version >= 3 && prev.isUpgraded(3, ancestors)) {
|
||||
state.flags |= constants.flags.VERIFY_DERSIG;
|
||||
if (!this.state.hasBIP66())
|
||||
this.logger.warning('BIP66 has been activated.');
|
||||
}
|
||||
|
||||
// CHECKLOCKTIMEVERIFY is now usable (bip65)
|
||||
if (block.version >= 4 && prev.isUpgraded(4, ancestors))
|
||||
if (block.version >= 4 && prev.isUpgraded(4, ancestors)) {
|
||||
state.flags |= constants.flags.VERIFY_CHECKLOCKTIMEVERIFY;
|
||||
if (!this.state.hasCLTV())
|
||||
this.logger.warning('BIP65 has been activated.');
|
||||
}
|
||||
|
||||
// Segregrated witness is now usable (bip141 - segnet3)
|
||||
if (this.network.segwitHeight !== -1 && height >= this.network.segwitHeight) {
|
||||
if (block.version >= 5 && prev.isUpgraded(5, ancestors))
|
||||
if (block.version >= 5 && prev.isUpgraded(5, ancestors)) {
|
||||
state.flags |= constants.flags.VERIFY_WITNESS;
|
||||
if (!this.state.hasWitness())
|
||||
this.logger.warning('Segwit has been activated.');
|
||||
}
|
||||
}
|
||||
|
||||
utils.serial([
|
||||
@ -664,6 +681,8 @@ Chain.prototype.getDeployments = function getDeployments(block, prev, ancestors,
|
||||
state.flags |= constants.flags.VERIFY_CHECKSEQUENCEVERIFY;
|
||||
state.lockFlags |= constants.flags.VERIFY_SEQUENCE;
|
||||
state.lockFlags |= constants.flags.MEDIAN_TIME_PAST;
|
||||
if (!self.state.hasCSV())
|
||||
self.logger.warning('CSV has been activated.');
|
||||
}
|
||||
|
||||
return next();
|
||||
@ -675,8 +694,11 @@ Chain.prototype.getDeployments = function getDeployments(block, prev, ancestors,
|
||||
if (err)
|
||||
return next(err);
|
||||
|
||||
if (active)
|
||||
if (active) {
|
||||
state.flags |= constants.flags.VERIFY_WITNESS;
|
||||
if (!self.state.hasWitness())
|
||||
self.logger.warning('Segwit has been activated.');
|
||||
}
|
||||
|
||||
return next();
|
||||
});
|
||||
@ -2247,36 +2269,29 @@ Chain.prototype.computeBlockVersion = function computeBlockVersion(prev, callbac
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the initial deployment state of the chain. Called on load.
|
||||
* Get the current deployment state of the chain. Called on load.
|
||||
* @private
|
||||
* @param {Function} callback - Returns [Error, {@link DeploymentState}].
|
||||
*/
|
||||
|
||||
Chain.prototype.getInitialState = function getInitialState(callback) {
|
||||
Chain.prototype.getDeploymentState = function getDeploymentState(callback) {
|
||||
var self = this;
|
||||
|
||||
if (!this.tip)
|
||||
return utils.nextTick(callback);
|
||||
return callback(null, this.state);
|
||||
|
||||
this.tip.getPrevious(function(err, prev) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
if (!prev)
|
||||
return callback();
|
||||
return callback(null, self.state);
|
||||
|
||||
prev.getRetargetAncestors(function(err, ancestors) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
self.getDeployments(self.tip, prev, ancestors, function(err, state) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
self.state = state;
|
||||
|
||||
return callback(null, state);
|
||||
});
|
||||
self.getDeployments(self.tip, prev, ancestors, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user