rpc: hold chain lock during submitblock.
This commit is contained in:
parent
de50a62b00
commit
9581225b8c
@ -1051,11 +1051,13 @@ RPC.prototype.submitBlock = co(function* submitBlock(args, help) {
|
||||
});
|
||||
|
||||
RPC.prototype._submitBlock = co(function* _submitBlock(block) {
|
||||
var unlock = yield this.locker.lock();
|
||||
var unlock1 = yield this.locker.lock();
|
||||
var unlock2 = yield this.chain.locker.lock();
|
||||
try {
|
||||
return yield this.__submitBlock(block);
|
||||
} finally {
|
||||
unlock();
|
||||
unlock2();
|
||||
unlock1();
|
||||
}
|
||||
});
|
||||
|
||||
@ -1066,29 +1068,28 @@ RPC.prototype.__submitBlock = co(function* __submitBlock(block) {
|
||||
|
||||
prev = yield this.chain.db.getEntry(block.prevBlock);
|
||||
|
||||
if (!prev)
|
||||
return 'rejected: bad-prevblk';
|
||||
if (prev) {
|
||||
state = yield this.chain.getDeployments(block.ts, prev);
|
||||
|
||||
state = yield this.chain.getDeployments(block.ts, prev);
|
||||
// Fix eloipool bug (witness nonce is not present).
|
||||
if (state.hasWitness() && block.getCommitmentHash()) {
|
||||
tx = block.txs[0];
|
||||
if (!tx.hasWitness()) {
|
||||
this.logger.warning('Submitted block had no witness nonce.');
|
||||
this.logger.debug(tx);
|
||||
|
||||
// Fix eloipool bug (witness nonce is not present).
|
||||
if (state.hasWitness() && block.getCommitmentHash()) {
|
||||
tx = block.txs[0];
|
||||
if (!tx.hasWitness()) {
|
||||
this.logger.warning('Submitted block had no witness nonce.');
|
||||
this.logger.debug(tx);
|
||||
// Recreate witness nonce (all zeroes).
|
||||
tx.inputs[0].witness.set(0, encoding.ZERO_HASH);
|
||||
tx.inputs[0].witness.compile();
|
||||
|
||||
// Recreate witness nonce (all zeroes).
|
||||
tx.inputs[0].witness.set(0, encoding.ZERO_HASH);
|
||||
tx.inputs[0].witness.compile();
|
||||
|
||||
tx.refresh();
|
||||
block.refresh();
|
||||
tx.refresh();
|
||||
block.refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
entry = yield this.chain.add(block);
|
||||
entry = yield this.chain._add(block);
|
||||
} catch (err) {
|
||||
if (err.type === 'VerifyError') {
|
||||
this.logger.warning('RPC block rejected: %s (%s).',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user