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
|
||||
// last checkpoint.
|
||||
if (!this.options.witness) {
|
||||
if (!this.options.segwit) {
|
||||
// We can't skip this with segwit
|
||||
// enabled since the block may have
|
||||
// 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)
|
||||
active = yield this.isActive(prev, deployments.witness);
|
||||
active = yield this.isActive(prev, deployments.segwit);
|
||||
if (active) {
|
||||
if (this.options.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.');
|
||||
}
|
||||
|
||||
this.logger.debug('Handling %d RPC calls.', cmds.length);
|
||||
|
||||
for (i = 0; i < cmds.length; i++) {
|
||||
cmd = cmds[i];
|
||||
|
||||
@ -580,7 +578,10 @@ HTTPServer.prototype._init = function _init() {
|
||||
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 {
|
||||
json = yield this.rpc.execute(cmd);
|
||||
|
||||
@ -306,26 +306,18 @@ Miner.prototype._onStop = function _onStop() {
|
||||
|
||||
Miner.prototype.createBlock = co(function* createBlock(tip, address) {
|
||||
var version = this.version;
|
||||
var now = this.network.now();
|
||||
var ts, locktime, median, target, attempt;
|
||||
var ts, locktime, target, attempt;
|
||||
|
||||
if (!tip)
|
||||
tip = this.chain.tip;
|
||||
|
||||
assert(tip);
|
||||
|
||||
ts = Math.max(now, tip.ts + 1);
|
||||
locktime = ts;
|
||||
|
||||
if (version === -1)
|
||||
version = yield this.chain.computeBlockVersion(tip);
|
||||
|
||||
// Cheat on testnet.
|
||||
// if (this.network.pow.difficultyReset) {
|
||||
// median = yield tip.getMedianTimeAsync();
|
||||
// ts = cheat(tip.ts, median, now, this.network.pow.targetSpacing);
|
||||
// locktime = ts;
|
||||
// }
|
||||
ts = Math.max(this.network.now(), tip.ts + 1);
|
||||
locktime = ts;
|
||||
|
||||
target = yield this.chain.getTargetAsync(ts, tip);
|
||||
|
||||
@ -551,24 +543,6 @@ function cmpRate(a, b) {
|
||||
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
|
||||
*/
|
||||
|
||||
@ -347,8 +347,8 @@ main.deployments = {
|
||||
timeout: 1493596800, // May 1st, 2017
|
||||
force: true
|
||||
},
|
||||
witness: {
|
||||
name: 'witness',
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 1479168000, // November 15th, 2016.
|
||||
timeout: 1510704000, // November 15th, 2017.
|
||||
@ -371,7 +371,7 @@ main.deployments = {
|
||||
|
||||
main.deploys = [
|
||||
main.deployments.csv,
|
||||
main.deployments.witness,
|
||||
main.deployments.segwit,
|
||||
main.deployments.mast,
|
||||
main.deployments.testdummy
|
||||
];
|
||||
@ -592,8 +592,8 @@ testnet.deployments = {
|
||||
timeout: 1493596800, // May 1st, 2017
|
||||
force: true
|
||||
},
|
||||
witness: {
|
||||
name: 'witness',
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 1462060800, // May 1st 2016
|
||||
timeout: 1493596800, // May 1st 2017
|
||||
@ -610,7 +610,7 @@ testnet.deployments = {
|
||||
|
||||
testnet.deploys = [
|
||||
testnet.deployments.csv,
|
||||
testnet.deployments.witness,
|
||||
testnet.deployments.segwit,
|
||||
testnet.deployments.mast,
|
||||
testnet.deployments.testdummy
|
||||
];
|
||||
@ -750,8 +750,8 @@ regtest.deployments = {
|
||||
timeout: 0xffffffff,
|
||||
force: true
|
||||
},
|
||||
witness: {
|
||||
name: 'witness',
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 0,
|
||||
timeout: 0xffffffff,
|
||||
@ -768,7 +768,7 @@ regtest.deployments = {
|
||||
|
||||
regtest.deploys = [
|
||||
regtest.deployments.csv,
|
||||
regtest.deployments.witness,
|
||||
regtest.deployments.segwit,
|
||||
regtest.deployments.mast,
|
||||
regtest.deployments.testdummy
|
||||
];
|
||||
@ -1032,8 +1032,8 @@ segnet4.deployments = {
|
||||
timeout: 1493596800, // May 1st, 2017
|
||||
force: true
|
||||
},
|
||||
witness: {
|
||||
name: 'witness',
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 0,
|
||||
timeout: 999999999999,
|
||||
@ -1043,7 +1043,7 @@ segnet4.deployments = {
|
||||
|
||||
segnet4.deploys = [
|
||||
segnet4.deployments.csv,
|
||||
segnet4.deployments.witness,
|
||||
segnet4.deployments.segwit,
|
||||
segnet4.deployments.testdummy
|
||||
];
|
||||
|
||||
@ -1183,8 +1183,8 @@ simnet.deployments = {
|
||||
timeout: 1493596800, // May 1st, 2017
|
||||
force: true
|
||||
},
|
||||
witness: {
|
||||
name: 'witness',
|
||||
segwit: {
|
||||
name: 'segwit',
|
||||
bit: 1,
|
||||
startTime: 1462060800, // May 1st 2016
|
||||
timeout: 1493596800, // May 1st 2017
|
||||
@ -1201,7 +1201,7 @@ simnet.deployments = {
|
||||
|
||||
simnet.deploys = [
|
||||
simnet.deployments.csv,
|
||||
simnet.deployments.witness,
|
||||
simnet.deployments.segwit,
|
||||
simnet.deployments.mast,
|
||||
simnet.deployments.testdummy
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user