small speed optimization for header sync (#1728)

* fix: avoid a confusing log when fastsync start (#1720)

(cherry picked from commit 4f462cdfdc)

* small speed optimization for header sync (#1719)

(cherry picked from commit d3589d1bf5)
This commit is contained in:
Gary Yu 2018-10-12 08:44:35 +08:00 committed by GitHub
parent 9adbaf55a1
commit 3fb4669d0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -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,

View file

@ -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);
}
}