mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 18:27:56 +00:00
Persist block announcements (#3826)
* Persist block announcements * Renamed sync requests to fork targets * Fixed pruning detection condition
This commit is contained in:
committed by
Gavin Wood
parent
3437d64115
commit
3963bb58ff
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user