mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
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.
This commit is contained in:
parent
a383ce5b4a
commit
e66543827c
1 changed files with 6 additions and 3 deletions
|
@ -428,10 +428,13 @@ def do_generate(args):
|
|||
action_time = now
|
||||
is_mine = True
|
||||
elif bestheader["height"] == 0:
|
||||
logging.error("When mining first block in a new signet, must specify --set-block-time")
|
||||
return 1
|
||||
time_delta = next_block_delta(int(bestheader["bits"], 16), bci["bestblockhash"], ultimate_target, args.poisson)
|
||||
time_delta *= 100 # 100 blocks
|
||||
logging.info("Backdating time for first block to %d minutes ago" % (time_delta/60))
|
||||
mine_time = now - time_delta
|
||||
action_time = now
|
||||
is_mine = True
|
||||
else:
|
||||
|
||||
time_delta = next_block_delta(int(bestheader["bits"], 16), bci["bestblockhash"], ultimate_target, args.poisson)
|
||||
mine_time = bestheader["time"] + time_delta
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue