From 3fb4669d0a37f20bd433fcf7d6e5053868ca251e Mon Sep 17 00:00:00 2001 From: Gary Yu Date: Fri, 12 Oct 2018 08:44:35 +0800 Subject: [PATCH] small speed optimization for header sync (#1728) * fix: avoid a confusing log when fastsync start (#1720) (cherry picked from commit 4f462cdfdca2c15aa6309a3885388a3fe21c428e) * small speed optimization for header sync (#1719) (cherry picked from commit d3589d1bf5991be3e89b118eed4e371b4c953ce3) --- p2p/src/protocol.rs | 2 +- servers/src/grin/sync/state_sync.rs | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/p2p/src/protocol.rs b/p2p/src/protocol.rs index 330f05313..b30837323 100644 --- a/p2p/src/protocol.rs +++ b/p2p/src/protocol.rs @@ -186,7 +186,7 @@ impl MessageHandler for Protocol { let headers: Headers = headers_streaming_body( conn, msg.header.msg_len, - 8, + 32, &mut total_read, &mut reserved, header_size, diff --git a/servers/src/grin/sync/state_sync.rs b/servers/src/grin/sync/state_sync.rs index c834f0e27..a9b598a37 100644 --- a/servers/src/grin/sync/state_sync.rs +++ b/servers/src/grin/sync/state_sync.rs @@ -123,6 +123,19 @@ impl StateSync { } Err(e) => self.sync_state.set_sync_error(Error::P2P(e)), } + + // to avoid the confusing log, + // update the final HeaderSync state mainly for 'current_height' + { + let status = self.sync_state.status(); + if let SyncStatus::HeaderSync { .. } = status { + self.sync_state.update(SyncStatus::HeaderSync { + current_height: header_head.height, + highest_height, + }); + } + } + self.sync_state.update(SyncStatus::TxHashsetDownload); } }