Skip to content

Commit 4287b38

Browse files
committed
Prevent pow miner from crashing on consensus bug
1 parent 9ed85ef commit 4287b38

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Features/Blockcore.Features.Miner/PowMining.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ public void Mine(Script reserveScript)
135135
// Issues constructing block or verifying it. Should not halt mining.
136136
this.logger.LogDebug("Consensus error exception occurred in miner loop: {0}", cee.ToString());
137137
}
138+
catch (ConsensusException ce)
139+
{
140+
// All consensus exceptions should be ignored. It means that the miner
141+
// run into problems while constructing block or verifying it
142+
// but it should not halted the staking operation.
143+
this.logger.LogDebug("Consensus exception occurred in miner loop: {0}", ce.ToString());
144+
}
138145
catch
139146
{
140147
this.logger.LogTrace("(-)[UNHANDLED_EXCEPTION]");
@@ -310,7 +317,7 @@ public int IncrementExtraNonce(Block block, ChainedHeader previousHeader, int ex
310317

311318
// BIP34 require the coinbase first input to start with the block height.
312319
int height = previousHeader.Height + 1;
313-
block.Transactions[0].Inputs[0].ScriptSig = new Script(Op.GetPushOp(height)) + OpcodeType.OP_0;
320+
block.Transactions[0].Inputs[0].ScriptSig = new Script(Op.GetPushOp(height)) + OpcodeType.OP_0;
314321

315322
this.blockProvider.BlockModified(previousHeader, block);
316323

0 commit comments

Comments
 (0)