network: rename segwitHeight.

This commit is contained in:
Christopher Jeffrey 2016-07-25 00:08:20 -07:00
parent cdbe6fc940
commit c9e8f779f3
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 15 additions and 10 deletions

View File

@ -641,7 +641,7 @@ Chain.prototype.getDeployments = function getDeployments(block, prev, ancestors,
// Only allow version 5 blocks (bip141 - segnet3)
// once the majority of blocks are using it.
if (this.network.segwitHeight !== -1 && height >= this.network.segwitHeight) {
if (this.network.oldWitness) {
if (block.version < 5 && prev.isOutdated(5, ancestors))
return callback(new VerifyError(block, 'obsolete', 'bad-version', 0));
}
@ -668,7 +668,7 @@ Chain.prototype.getDeployments = function getDeployments(block, prev, ancestors,
}
// Segregrated witness is now usable (bip141 - segnet3)
if (this.network.segwitHeight !== -1 && height >= this.network.segwitHeight) {
if (this.network.oldWitness) {
if (block.version >= 5 && prev.isUpgraded(5, ancestors)) {
state.flags |= constants.flags.VERIFY_WITNESS;
if (!this.state.hasWitness())

View File

@ -41,7 +41,7 @@ function Network(options) {
this.pow = options.pow;
this.block = options.block;
this.witness = options.witness;
this.segwitHeight = options.segwitHeight;
this.oldWitness = options.oldWitness;
this.activationThreshold = options.activationThreshold;
this.minerWindow = options.minerWindow;
this.deployments = options.deployments;

View File

@ -1315,6 +1315,11 @@ Peer.prototype._handleVersion = function _handleVersion(version) {
if (this.options.witness) {
if (!version.hasWitness()) {
if (!this.network.oldWitness) {
this._error('Peer does not support segregated witness.');
this.setMisbehavior(100);
return;
}
this.request('havewitness', function(err) {
if (err) {
self._error('Peer does not support segregated witness.');

View File

@ -298,12 +298,12 @@ main.block = {
main.witness = false;
/**
* Height at which segwit is activated (segnet3).
* @const {Number}
* Whether to use segnet3-style segwit.
* @const {Boolean}
* @default
*/
main.segwitHeight = 2000000000;
main.oldWitness = false;
/**
* For versionbits.
@ -544,7 +544,7 @@ testnet.block = {
testnet.witness = false;
testnet.segwitHeight = 2000000000;
testnet.oldWitness = false;
testnet.activationThreshold = 1512; // 75% for testchains
@ -689,7 +689,7 @@ regtest.block = {
regtest.witness = false;
regtest.segwitHeight = -1;
regtest.oldWitness = false;
regtest.activationThreshold = 108; // 75% for testchains
@ -833,7 +833,7 @@ segnet3.block = {
segnet3.witness = true;
segnet3.segwitHeight = 0;
segnet3.oldWitness = true;
segnet3.activationThreshold = 108;
@ -956,7 +956,7 @@ segnet4.block = {
segnet4.witness = true;
segnet4.segwitHeight = -1;
segnet4.oldWitness = false;
segnet4.activationThreshold = 108;