aboutsummaryrefslogtreecommitdiff
path: root/contrib/signet
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2021-01-13 11:56:19 +1000
committerAnthony Towns <aj@erisian.com.au>2021-02-07 06:50:11 +1000
commite66543827cd4ae9b76ff4c5c6e414c1942c7d727 (patch)
tree95297eb2e2096a5ca025b34f4c8376ea95e80e35 /contrib/signet
parenta383ce5b4add6cdf4e9974527b609a1147a0d972 (diff)
downloadbitcoin-e66543827cd4ae9b76ff4c5c6e414c1942c7d727.tar.xz
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.
Diffstat (limited to 'contrib/signet')
-rwxr-xr-xcontrib/signet/miner9
1 files 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