rpc: fix getblocktemplate.
This commit is contained in:
parent
c300df7340
commit
dd0ebe5320
@ -1532,13 +1532,15 @@ RPC.prototype._template = co(function* _template(version, coinbase, rules) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
RPC.prototype.__template = co(function* _template(version, coinbase, rules) {
|
RPC.prototype.__template = co(function* _template(version, coinbase, rules) {
|
||||||
|
var mutable = ['time', 'transactions', 'prevblock'];
|
||||||
var txs = [];
|
var txs = [];
|
||||||
var txIndex = {};
|
var txIndex = {};
|
||||||
|
var vbavailable = {};
|
||||||
|
var vbrules = [];
|
||||||
var attempt = yield this._getAttempt(false);
|
var attempt = yield this._getAttempt(false);
|
||||||
var block = attempt.block;
|
var block = attempt.block;
|
||||||
var i, j, tx, deps, input, dep, output, raw, rwhash;
|
var i, j, tx, deps, input, dep, output, raw, rwhash;
|
||||||
var keys, vbavailable, vbrules, mutable, template;
|
var template, name, deployment, state;
|
||||||
var id, deployment, state;
|
|
||||||
|
|
||||||
for (i = 1; i < block.txs.length; i++) {
|
for (i = 1; i < block.txs.length; i++) {
|
||||||
tx = block.txs[i];
|
tx = block.txs[i];
|
||||||
@ -1569,18 +1571,13 @@ RPC.prototype.__template = co(function* _template(version, coinbase, rules) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
keys = Object.keys(this.network.deployments);
|
|
||||||
vbavailable = {};
|
|
||||||
vbrules = [];
|
|
||||||
mutable = ['time', 'transactions', 'prevblock'];
|
|
||||||
|
|
||||||
if (version >= 2)
|
if (version >= 2)
|
||||||
mutable.push('version/force');
|
mutable.push('version/force');
|
||||||
|
|
||||||
for (i = 0; i < keys.length; i++) {
|
for (i = 0; i < this.network.deploys.length; i++) {
|
||||||
id = keys[i];
|
deployment = this.network.deploys[i];
|
||||||
deployment = this.network.deployments[id];
|
state = yield this.chain.getState(this.chain.tip, deployment);
|
||||||
state = yield this.chain.getState(this.chain.tip, id);
|
name = deployment.name;
|
||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case constants.thresholdStates.DEFINED:
|
case constants.thresholdStates.DEFINED:
|
||||||
@ -1589,17 +1586,17 @@ RPC.prototype.__template = co(function* _template(version, coinbase, rules) {
|
|||||||
case constants.thresholdStates.LOCKED_IN:
|
case constants.thresholdStates.LOCKED_IN:
|
||||||
block.version |= 1 << deployment.bit;
|
block.version |= 1 << deployment.bit;
|
||||||
case constants.thresholdStates.STARTED:
|
case constants.thresholdStates.STARTED:
|
||||||
vbavailable[id] = deployment.bit;
|
vbavailable[name] = deployment.bit;
|
||||||
if (rules) {
|
if (rules) {
|
||||||
if (rules.indexOf(id) === -1 && !deployment.force)
|
if (rules.indexOf(name) === -1 && !deployment.force)
|
||||||
block.version &= ~(1 << deployment.bit);
|
block.version &= ~(1 << deployment.bit);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case constants.thresholdStates.ACTIVE:
|
case constants.thresholdStates.ACTIVE:
|
||||||
vbrules.push(id);
|
vbrules.push(name);
|
||||||
if (rules) {
|
if (rules) {
|
||||||
if (rules.indexOf(id) === -1 && !deployment.force)
|
if (rules.indexOf(name) === -1 && !deployment.force)
|
||||||
throw new RPCError('Client must support ' + id + '.');
|
throw new RPCError('Client must support ' + name + '.');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user