Persist block announcements (#3826)

* Persist block announcements

* Renamed sync requests to fork targets

* Fixed pruning detection condition
This commit is contained in:
Arkadiy Paronyan
2019-10-18 16:44:40 +02:00
committed by Gavin Wood
parent 3437d64115
commit 3963bb58ff
4 changed files with 105 additions and 128 deletions
+3 -8
View File
@@ -1121,18 +1121,13 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
};
match self.sync.on_block_announce(who.clone(), hash, &announce, is_their_best) {
sync::OnBlockAnnounce::Request(peer, req) => {
self.send_message(peer, GenericMessage::BlockRequest(req));
return CustomMessageOutcome::None
}
sync::OnBlockAnnounce::Nothing => {
// try_import is only true when we have all data required to import block
// `on_block_announce` returns `OnBlockAnnounce::ImportHeader`
// when we have all data required to import the block
// in the BlockAnnounce message. This is only when:
// 1) we're on light client;
// AND
// - EITHER 2.1) announced block is stale;
// - OR 2.2) announced block is NEW and we normally only want to download this single block (i.e.
// there are no ascendants of this block scheduled for retrieval)
// 2) parent block is already imported and not pruned.
return CustomMessageOutcome::None
}
sync::OnBlockAnnounce::ImportHeader => () // We proceed with the import.