From e66543827cd4ae9b76ff4c5c6e414c1942c7d727 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 13 Jan 2021 11:56:19 +1000 Subject: [PATCH] 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. --- contrib/signet/miner | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/contrib/signet/miner b/contrib/signet/miner index 0c1a4ac12d..09eb07502f 100755 --- a/contrib/signet/miner +++ b/contrib/signet/miner @@ -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