Skip to content

Commit e665438

Browse files
committed
contrib/signet/miner: Automatic timestamp for first block
When mining the first block of a new signet chain, pick a timestamp for the first block so that after mining 100 blocks the timestamp will be back to the current time -- this prevents an unnecessary delay before any miner rewards have matured enough to be spent. This takes into account that the delta between blocks may be shorter than 10 minutes due to attempting to increase the difficulty to match --nbits, but does not take into account the time spent actually generating the 100 blocks.
1 parent a383ce5 commit e665438

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

contrib/signet/miner

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,13 @@ def do_generate(args):
428428
action_time = now
429429
is_mine = True
430430
elif bestheader["height"] == 0:
431-
logging.error("When mining first block in a new signet, must specify --set-block-time")
432-
return 1
431+
time_delta = next_block_delta(int(bestheader["bits"], 16), bci["bestblockhash"], ultimate_target, args.poisson)
432+
time_delta *= 100 # 100 blocks
433+
logging.info("Backdating time for first block to %d minutes ago" % (time_delta/60))
434+
mine_time = now - time_delta
435+
action_time = now
436+
is_mine = True
433437
else:
434-
435438
time_delta = next_block_delta(int(bestheader["bits"], 16), bci["bestblockhash"], ultimate_target, args.poisson)
436439
mine_time = bestheader["time"] + time_delta
437440

0 commit comments

Comments
 (0)