mining: remove cheating. rename witness deployment to segwit.
This commit is contained in:
parent
f8b4750d90
commit
4353decc5a
@ -303,7 +303,7 @@ Chain.prototype.verify = co(function* verify(block, prev) {
|
|||||||
|
|
||||||
// Skip any blocks below the
|
// Skip any blocks below the
|
||||||
// last checkpoint.
|
// last checkpoint.
|
||||||
if (!this.options.witness) {
|
if (!this.options.segwit) {
|
||||||
// We can't skip this with segwit
|
// We can't skip this with segwit
|
||||||
// enabled since the block may have
|
// enabled since the block may have
|
||||||
// been malleated: we don't know
|
// been malleated: we don't know
|
||||||
@ -509,7 +509,7 @@ Chain.prototype.getDeployments = co(function* getDeployments(block, prev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Segregrated witness is now usable (bip141 - segnet4)
|
// Segregrated witness is now usable (bip141 - segnet4)
|
||||||
active = yield this.isActive(prev, deployments.witness);
|
active = yield this.isActive(prev, deployments.segwit);
|
||||||
if (active) {
|
if (active) {
|
||||||
if (this.options.witness)
|
if (this.options.witness)
|
||||||
state.flags |= constants.flags.VERIFY_WITNESS;
|
state.flags |= constants.flags.VERIFY_WITNESS;
|
||||||
|
|||||||
@ -569,8 +569,6 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
enforce(typeof cmd.id === 'number', 'ID must be a number.');
|
enforce(typeof cmd.id === 'number', 'ID must be a number.');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug('Handling %d RPC calls.', cmds.length);
|
|
||||||
|
|
||||||
for (i = 0; i < cmds.length; i++) {
|
for (i = 0; i < cmds.length; i++) {
|
||||||
cmd = cmds[i];
|
cmd = cmds[i];
|
||||||
|
|
||||||
@ -580,7 +578,10 @@ HTTPServer.prototype._init = function _init() {
|
|||||||
cmd.method = 'getworklp';
|
cmd.method = 'getworklp';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.debug(cmd);
|
if (cmd.method !== 'getblocktemplate' && cmd.method !== 'getwork') {
|
||||||
|
this.logger.debug('Handling RPC call : %s.', cmd.method);
|
||||||
|
this.logger.debug(cmd.params);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = yield this.rpc.execute(cmd);
|
json = yield this.rpc.execute(cmd);
|
||||||
|
|||||||
@ -306,26 +306,18 @@ Miner.prototype._onStop = function _onStop() {
|
|||||||
|
|
||||||
Miner.prototype.createBlock = co(function* createBlock(tip, address) {
|
Miner.prototype.createBlock = co(function* createBlock(tip, address) {
|
||||||
var version = this.version;
|
var version = this.version;
|
||||||
var now = this.network.now();
|
var ts, locktime, target, attempt;
|
||||||
var ts, locktime, median, target, attempt;
|
|
||||||
|
|
||||||
if (!tip)
|
if (!tip)
|
||||||
tip = this.chain.tip;
|
tip = this.chain.tip;
|
||||||
|
|
||||||
assert(tip);
|
assert(tip);
|
||||||
|
|
||||||
ts = Math.max(now, tip.ts + 1);
|
|
||||||
locktime = ts;
|
|
||||||
|
|
||||||
if (version === -1)
|
if (version === -1)
|
||||||
version = yield this.chain.computeBlockVersion(tip);
|
version = yield this.chain.computeBlockVersion(tip);
|
||||||
|
|
||||||
// Cheat on testnet.
|
ts = Math.max(this.network.now(), tip.ts + 1);
|
||||||
// if (this.network.pow.difficultyReset) {
|
locktime = ts;
|
||||||
// median = yield tip.getMedianTimeAsync();
|
|
||||||
// ts = cheat(tip.ts, median, now, this.network.pow.targetSpacing);
|
|
||||||
// locktime = ts;
|
|
||||||
// }
|
|
||||||
|
|
||||||
target = yield this.chain.getTargetAsync(ts, tip);
|
target = yield this.chain.getTargetAsync(ts, tip);
|
||||||
|
|
||||||
@ -551,24 +543,6 @@ function cmpRate(a, b) {
|
|||||||
return a.rate - b.rate;
|
return a.rate - b.rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cheat(prevTime, medianTime, now, targetSpacing) {
|
|
||||||
var resetTime = prevTime + (targetSpacing * 3);
|
|
||||||
|
|
||||||
// Already easy.
|
|
||||||
if (now >= resetTime)
|
|
||||||
return now;
|
|
||||||
|
|
||||||
// time-too-new - 30 min
|
|
||||||
if (resetTime > now + (1.5 * 60 * 60))
|
|
||||||
return medianTime + 1;
|
|
||||||
|
|
||||||
// time-too-old
|
|
||||||
if (resetTime <= medianTime)
|
|
||||||
return medianTime + 1;
|
|
||||||
|
|
||||||
return resetTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Expose
|
* Expose
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -347,8 +347,8 @@ main.deployments = {
|
|||||||
timeout: 1493596800, // May 1st, 2017
|
timeout: 1493596800, // May 1st, 2017
|
||||||
force: true
|
force: true
|
||||||
},
|
},
|
||||||
witness: {
|
segwit: {
|
||||||
name: 'witness',
|
name: 'segwit',
|
||||||
bit: 1,
|
bit: 1,
|
||||||
startTime: 1479168000, // November 15th, 2016.
|
startTime: 1479168000, // November 15th, 2016.
|
||||||
timeout: 1510704000, // November 15th, 2017.
|
timeout: 1510704000, // November 15th, 2017.
|
||||||
@ -371,7 +371,7 @@ main.deployments = {
|
|||||||
|
|
||||||
main.deploys = [
|
main.deploys = [
|
||||||
main.deployments.csv,
|
main.deployments.csv,
|
||||||
main.deployments.witness,
|
main.deployments.segwit,
|
||||||
main.deployments.mast,
|
main.deployments.mast,
|
||||||
main.deployments.testdummy
|
main.deployments.testdummy
|
||||||
];
|
];
|
||||||
@ -592,8 +592,8 @@ testnet.deployments = {
|
|||||||
timeout: 1493596800, // May 1st, 2017
|
timeout: 1493596800, // May 1st, 2017
|
||||||
force: true
|
force: true
|
||||||
},
|
},
|
||||||
witness: {
|
segwit: {
|
||||||
name: 'witness',
|
name: 'segwit',
|
||||||
bit: 1,
|
bit: 1,
|
||||||
startTime: 1462060800, // May 1st 2016
|
startTime: 1462060800, // May 1st 2016
|
||||||
timeout: 1493596800, // May 1st 2017
|
timeout: 1493596800, // May 1st 2017
|
||||||
@ -610,7 +610,7 @@ testnet.deployments = {
|
|||||||
|
|
||||||
testnet.deploys = [
|
testnet.deploys = [
|
||||||
testnet.deployments.csv,
|
testnet.deployments.csv,
|
||||||
testnet.deployments.witness,
|
testnet.deployments.segwit,
|
||||||
testnet.deployments.mast,
|
testnet.deployments.mast,
|
||||||
testnet.deployments.testdummy
|
testnet.deployments.testdummy
|
||||||
];
|
];
|
||||||
@ -750,8 +750,8 @@ regtest.deployments = {
|
|||||||
timeout: 0xffffffff,
|
timeout: 0xffffffff,
|
||||||
force: true
|
force: true
|
||||||
},
|
},
|
||||||
witness: {
|
segwit: {
|
||||||
name: 'witness',
|
name: 'segwit',
|
||||||
bit: 1,
|
bit: 1,
|
||||||
startTime: 0,
|
startTime: 0,
|
||||||
timeout: 0xffffffff,
|
timeout: 0xffffffff,
|
||||||
@ -768,7 +768,7 @@ regtest.deployments = {
|
|||||||
|
|
||||||
regtest.deploys = [
|
regtest.deploys = [
|
||||||
regtest.deployments.csv,
|
regtest.deployments.csv,
|
||||||
regtest.deployments.witness,
|
regtest.deployments.segwit,
|
||||||
regtest.deployments.mast,
|
regtest.deployments.mast,
|
||||||
regtest.deployments.testdummy
|
regtest.deployments.testdummy
|
||||||
];
|
];
|
||||||
@ -1032,8 +1032,8 @@ segnet4.deployments = {
|
|||||||
timeout: 1493596800, // May 1st, 2017
|
timeout: 1493596800, // May 1st, 2017
|
||||||
force: true
|
force: true
|
||||||
},
|
},
|
||||||
witness: {
|
segwit: {
|
||||||
name: 'witness',
|
name: 'segwit',
|
||||||
bit: 1,
|
bit: 1,
|
||||||
startTime: 0,
|
startTime: 0,
|
||||||
timeout: 999999999999,
|
timeout: 999999999999,
|
||||||
@ -1043,7 +1043,7 @@ segnet4.deployments = {
|
|||||||
|
|
||||||
segnet4.deploys = [
|
segnet4.deploys = [
|
||||||
segnet4.deployments.csv,
|
segnet4.deployments.csv,
|
||||||
segnet4.deployments.witness,
|
segnet4.deployments.segwit,
|
||||||
segnet4.deployments.testdummy
|
segnet4.deployments.testdummy
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -1183,8 +1183,8 @@ simnet.deployments = {
|
|||||||
timeout: 1493596800, // May 1st, 2017
|
timeout: 1493596800, // May 1st, 2017
|
||||||
force: true
|
force: true
|
||||||
},
|
},
|
||||||
witness: {
|
segwit: {
|
||||||
name: 'witness',
|
name: 'segwit',
|
||||||
bit: 1,
|
bit: 1,
|
||||||
startTime: 1462060800, // May 1st 2016
|
startTime: 1462060800, // May 1st 2016
|
||||||
timeout: 1493596800, // May 1st 2017
|
timeout: 1493596800, // May 1st 2017
|
||||||
@ -1201,7 +1201,7 @@ simnet.deployments = {
|
|||||||
|
|
||||||
simnet.deploys = [
|
simnet.deploys = [
|
||||||
simnet.deployments.csv,
|
simnet.deployments.csv,
|
||||||
simnet.deployments.witness,
|
simnet.deployments.segwit,
|
||||||
simnet.deployments.mast,
|
simnet.deployments.mast,
|
||||||
simnet.deployments.testdummy
|
simnet.deployments.testdummy
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user