mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 17:17:56 +00:00
Improvements to the import queue (#3101)
* Remove block_imported * Move blocks results processing to sync * Remove methods from Link * Better errors * Allow cancelling the import queue * Restore the import trace * Fix network tests * Line widths * Use has_error instead * Minor style
This commit is contained in:
committed by
Gavin Wood
parent
7ae6556a02
commit
5bd806bd9b
@@ -28,6 +28,7 @@ use runtime_primitives::traits::{
|
||||
Block as BlockT, Header as HeaderT, NumberFor, One, Zero,
|
||||
CheckedSub, SaturatedConversion
|
||||
};
|
||||
use consensus::import_queue::{BlockImportResult, BlockImportError};
|
||||
use message::{BlockAttributes, Direction, FromBlock, Message, RequestId};
|
||||
use message::generic::{Message as GenericMessage, ConsensusMessage};
|
||||
use event::Event;
|
||||
@@ -1194,22 +1195,23 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
self.sync.request_justification(&hash, number)
|
||||
}
|
||||
|
||||
/// Clears all pending justification requests.
|
||||
pub fn clear_justification_requests(&mut self) {
|
||||
self.sync.clear_justification_requests()
|
||||
}
|
||||
|
||||
/// A batch of blocks have been processed, with or without errors.
|
||||
/// Call this when a batch of blocks have been processed by the import queue, with or without
|
||||
/// Call this when a batch of blocks have been processed by the importqueue, with or without
|
||||
/// errors.
|
||||
pub fn blocks_processed(&mut self, processed_blocks: Vec<B::Hash>, has_error: bool) {
|
||||
self.sync.on_blocks_processed(processed_blocks, has_error);
|
||||
}
|
||||
|
||||
/// Restart the sync process.
|
||||
pub fn restart(&mut self) {
|
||||
pub fn blocks_processed(
|
||||
&mut self,
|
||||
imported: usize,
|
||||
count: usize,
|
||||
results: Vec<(Result<BlockImportResult<NumberFor<B>>, BlockImportError>, B::Hash)>
|
||||
) {
|
||||
let peers = self.context_data.peers.clone();
|
||||
for result in self.sync.restart(|peer_id| peers.get(peer_id).map(|i| i.info.clone())) {
|
||||
let results = self.sync.on_blocks_processed(
|
||||
imported,
|
||||
count,
|
||||
results,
|
||||
|peer_id| peers.get(peer_id).map(|i| i.info.clone())
|
||||
);
|
||||
for result in results {
|
||||
match result {
|
||||
Ok((id, req)) => {
|
||||
let msg = GenericMessage::BlockRequest(req);
|
||||
@@ -1223,11 +1225,6 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Notify about successful import of the given block.
|
||||
pub fn block_imported(&mut self, hash: &B::Hash, number: NumberFor<B>) {
|
||||
trace!(target: "sync", "Block imported successfully {} ({})", number, hash)
|
||||
}
|
||||
|
||||
/// Call this when a justification has been processed by the import queue, with or without
|
||||
/// errors.
|
||||
pub fn justification_import_result(&mut self, hash: B::Hash, number: NumberFor<B>, success: bool) {
|
||||
|
||||
Reference in New Issue
Block a user