mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 08:07:58 +00:00
Introduce ChainSyncInterface (#12489)
* Introduce `ChainSyncInterface` `ChainSyncInterface` provides an asynchronous interface for other subsystems to submit calls to `ChainSync`. This allows `NetworkService` to delegate calls to `ChainSync` while still providing the same API for other subsystems (for now). This makes it possible to move the syncing code in piecemeal fashion out of `protocol.rs` as the calls are just forwarded to `ChainSync`. * Apply review comments * Fix tests
This commit is contained in:
@@ -947,18 +947,6 @@ where
|
||||
self.chain_sync.clear_justification_requests();
|
||||
}
|
||||
|
||||
/// Request syncing for the given block from given set of peers.
|
||||
/// Uses `protocol` to queue a new block download request and tries to dispatch all pending
|
||||
/// requests.
|
||||
pub fn set_sync_fork_request(
|
||||
&mut self,
|
||||
peers: Vec<PeerId>,
|
||||
hash: &B::Hash,
|
||||
number: NumberFor<B>,
|
||||
) {
|
||||
self.chain_sync.set_sync_fork_request(peers, hash, number)
|
||||
}
|
||||
|
||||
/// A batch of blocks have been processed, with or without errors.
|
||||
/// Call this when a batch of blocks have been processed by the importqueue, with or without
|
||||
/// errors.
|
||||
@@ -1461,8 +1449,11 @@ where
|
||||
self.pending_messages.push_back(event);
|
||||
}
|
||||
|
||||
// Check if there is any block announcement validation finished.
|
||||
while let Poll::Ready(result) = self.chain_sync.poll_block_announce_validation(cx) {
|
||||
// Advance the state of `ChainSync`
|
||||
//
|
||||
// Process any received requests received from `NetworkService` and
|
||||
// check if there is any block announcement validation finished.
|
||||
while let Poll::Ready(result) = self.chain_sync.poll(cx) {
|
||||
match self.process_block_announce_validation_result(result) {
|
||||
CustomMessageOutcome::None => {},
|
||||
outcome => self.pending_messages.push_back(outcome),
|
||||
|
||||
Reference in New Issue
Block a user