mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 21:21:11 +00:00
Network crate cleanups (#3049)
* Remove useless internal messages * Remove NetworkService::disconnect_peer * Remove NetworkMsg altogether * Rename ProtocolMsg ServerToWorkerMsg * Remove useless code * Add example for parse_str_addr * Move parse_str_addr and ProtocolId to config * Don't reexport the content of config * Rework the imports * More reexports rework * Add documentation * Move finalization report to network future * Move on_block_imported to worker * get_value/put_value no longer locking * local_peer_id() no longer locks * Remove FetchFuture * Service imports cleanup * Produce the network state in the network task * Merge network task and RPC network task * Move network methods to NetworkWorker * Remove Arc peers system from network * add_reserved_peer now goes through the channel * Remove Mutex around network swarm * Remove the FnOnce alias traits * Replace is_offline with num_connected * Improve style of poll() * Fix network tests * Some doc in service module * Remove macro export * Minor doc changes * Remove the synchronized() method of the import queue * Line width * Line widths * Fix import queue tests * Fix CLI tests
This commit is contained in:
committed by
Gavin Wood
parent
7df8e52cfe
commit
1e126eab2f
@@ -145,9 +145,6 @@ pub trait Link<B: BlockT>: Send {
|
||||
fn report_peer(&mut self, _who: Origin, _reputation_change: i32) {}
|
||||
/// Restart sync.
|
||||
fn restart(&mut self) {}
|
||||
/// Synchronization request has been processed.
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
fn synchronized(&mut self) {}
|
||||
}
|
||||
|
||||
/// Block import successful result.
|
||||
|
||||
@@ -85,15 +85,6 @@ impl<B: BlockT> BasicQueue<B> {
|
||||
manual_poll: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Send synchronization request to the block import channel.
|
||||
///
|
||||
/// The caller should wait for Link::synchronized() call to ensure that it
|
||||
/// has synchronized with ImportQueue.
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
pub fn synchronize(&self) {
|
||||
let _ = self.sender.unbounded_send(ToWorkerMsg::Synchronize);
|
||||
}
|
||||
}
|
||||
|
||||
impl<B: BlockT> ImportQueue<B> for BasicQueue<B> {
|
||||
@@ -153,8 +144,6 @@ enum ToWorkerMsg<B: BlockT> {
|
||||
ImportBlocks(BlockOrigin, Vec<IncomingBlock<B>>),
|
||||
ImportJustification(Origin, B::Hash, NumberFor<B>, Justification),
|
||||
ImportFinalityProof(Origin, B::Hash, NumberFor<B>, Vec<u8>),
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
Synchronize,
|
||||
}
|
||||
|
||||
struct BlockImportWorker<B: BlockT, V: Verifier<B>> {
|
||||
@@ -213,11 +202,6 @@ impl<B: BlockT, V: 'static + Verifier<B>> BlockImportWorker<B, V> {
|
||||
ToWorkerMsg::ImportJustification(who, hash, number, justification) => {
|
||||
worker.import_justification(who, hash, number, justification);
|
||||
}
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
ToWorkerMsg::Synchronize => {
|
||||
trace!(target: "sync", "Sending sync message");
|
||||
worker.result_sender.synchronized();
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -63,8 +63,6 @@ enum BlockImportWorkerMsg<B: BlockT> {
|
||||
SetFinalityProofRequestBuilder(SharedFinalityProofRequestBuilder<B>),
|
||||
ReportPeer(Origin, i32),
|
||||
Restart,
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
Synchronized,
|
||||
}
|
||||
|
||||
impl<B: BlockT> Link<B> for BufferedLinkSender<B> {
|
||||
@@ -120,11 +118,6 @@ impl<B: BlockT> Link<B> for BufferedLinkSender<B> {
|
||||
fn restart(&mut self) {
|
||||
let _ = self.tx.unbounded_send(BlockImportWorkerMsg::Restart);
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
fn synchronized(&mut self) {
|
||||
let _ = self.tx.unbounded_send(BlockImportWorkerMsg::Synchronized);
|
||||
}
|
||||
}
|
||||
|
||||
/// See [`buffered_link`].
|
||||
@@ -168,9 +161,6 @@ impl<B: BlockT> BufferedLinkReceiver<B> {
|
||||
link.report_peer(who, reput),
|
||||
BlockImportWorkerMsg::Restart =>
|
||||
link.restart(),
|
||||
#[cfg(any(test, feature = "test-helpers"))]
|
||||
BlockImportWorkerMsg::Synchronized =>
|
||||
link.synchronized(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user