From ce1dca1b6855a1503ba6a2007c568e33484a6141 Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Sat, 12 May 2018 21:31:22 +0100 Subject: [PATCH] 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. --- servers/src/grin/sync.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/servers/src/grin/sync.rs b/servers/src/grin/sync.rs index 533b4348..fb1acf50 100644 --- a/servers/src/grin/sync.rs +++ b/servers/src/grin/sync.rs @@ -248,9 +248,10 @@ fn fast_sync(peers: Arc, chain: Arc, header_head: &chain::T 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(); - for _ in 0..horizon.saturating_sub(20) { + for _ in 0..(horizon - horizon / 10) { txhashset_head = chain.get_block_header(&txhashset_head.previous).unwrap(); } p.send_txhashset_request(txhashset_head.height, txhashset_head.hash())