mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Ask for txhashet before horizon to account for fast sync time
We test if we're in fast sync or not by checking if our head is more recent than horizon. However, by the time we get the data and validate, more blocks have passed, and we'd be after horizon again. So we request the txhashset for a more recent block than the one at horizon. The current value was 20, leaving only 20 min of slack, which isn't enough for debug builds and isn't future-proof. Change to use `0.9*horizon`, leaving about 2.5 hours.
This commit is contained in:
parent
9909e8e2ff
commit
ce1dca1b68
1 changed files with 3 additions and 2 deletions
|
@ -248,9 +248,10 @@ fn fast_sync(peers: Arc<Peers>, chain: Arc<chain::Chain>, header_head: &chain::T
|
||||||
header_head.last_block_h
|
header_head.last_block_h
|
||||||
);
|
);
|
||||||
|
|
||||||
// ask for txhashset at horizon
|
// ask for txhashset at 90% of horizon, this still leaves time for download
|
||||||
|
// and validation to happen and stay within horizon
|
||||||
let mut txhashset_head = chain.get_block_header(&header_head.prev_block_h).unwrap();
|
let mut txhashset_head = chain.get_block_header(&header_head.prev_block_h).unwrap();
|
||||||
for _ in 0..horizon.saturating_sub(20) {
|
for _ in 0..(horizon - horizon / 10) {
|
||||||
txhashset_head = chain.get_block_header(&txhashset_head.previous).unwrap();
|
txhashset_head = chain.get_block_header(&txhashset_head.previous).unwrap();
|
||||||
}
|
}
|
||||||
p.send_txhashset_request(txhashset_head.height, txhashset_head.hash())
|
p.send_txhashset_request(txhashset_head.height, txhashset_head.hash())
|
||||||
|
|
Loading…
Reference in a new issue