mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-28 17:57:25 +00:00
Use custom type for ProtocolName (#12172)
* Add ProtocolName custom type * Use new ProtocolName in sc_network_common * Use new ProtocolName in sc_network * Use new ProtocolName for BEEFY and GRANDPA * Use new ProtocolName for notifications * Use new ProtocolName in sc_network (part 2) * Use new ProtocolName in sc_network_gossip * Use new ProtocolName in sc_offchain * Remove unused imports * Some more fixes * Add tests * Fix minor import issues * Re-export ProtocolName in sc_network * Revert "Re-export ProtocolName in sc_network" This reverts commit 8d8ff71927e7750757f29c9bbd88dc0ba181d214. * Re-export ProtocolName in sc_network * Remove dependency on sc-network-common from beefy-gadget
This commit is contained in:
@@ -42,7 +42,10 @@ use log::debug;
|
||||
use sc_consensus::import_queue::{IncomingBlock, Origin};
|
||||
use sc_network_common::{
|
||||
config::ProtocolId,
|
||||
protocol::event::{DhtEvent, ObservedRole},
|
||||
protocol::{
|
||||
event::{DhtEvent, ObservedRole},
|
||||
ProtocolName,
|
||||
},
|
||||
request_responses::{IfDisconnected, ProtocolConfig, RequestFailure},
|
||||
};
|
||||
use sc_peerset::PeersetHandle;
|
||||
@@ -53,7 +56,6 @@ use sp_runtime::{
|
||||
Justifications,
|
||||
};
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
collections::{HashSet, VecDeque},
|
||||
iter,
|
||||
task::{Context, Poll},
|
||||
@@ -117,7 +119,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
/// Peer which sent us a request.
|
||||
peer: PeerId,
|
||||
/// Protocol name of the request.
|
||||
protocol: Cow<'static, str>,
|
||||
protocol: ProtocolName,
|
||||
/// If `Ok`, contains the time elapsed between when we received the request and when we
|
||||
/// sent back the response. If `Err`, the error that happened.
|
||||
result: Result<Duration, ResponseFailure>,
|
||||
@@ -130,7 +132,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
/// Peer that we send a request to.
|
||||
peer: PeerId,
|
||||
/// Name of the protocol in question.
|
||||
protocol: Cow<'static, str>,
|
||||
protocol: ProtocolName,
|
||||
/// Duration the request took.
|
||||
duration: Duration,
|
||||
/// Result of the request.
|
||||
@@ -144,12 +146,12 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
/// Node we opened the substream with.
|
||||
remote: PeerId,
|
||||
/// The concerned protocol. Each protocol uses a different substream.
|
||||
protocol: Cow<'static, str>,
|
||||
protocol: ProtocolName,
|
||||
/// If the negotiation didn't use the main name of the protocol (the one in
|
||||
/// `notifications_protocol`), then this field contains which name has actually been
|
||||
/// used.
|
||||
/// See also [`crate::Event::NotificationStreamOpened`].
|
||||
negotiated_fallback: Option<Cow<'static, str>>,
|
||||
negotiated_fallback: Option<ProtocolName>,
|
||||
/// Object that permits sending notifications to the peer.
|
||||
notifications_sink: NotificationsSink,
|
||||
/// Role of the remote.
|
||||
@@ -165,7 +167,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
/// Id of the peer we are connected to.
|
||||
remote: PeerId,
|
||||
/// The concerned protocol. Each protocol uses a different substream.
|
||||
protocol: Cow<'static, str>,
|
||||
protocol: ProtocolName,
|
||||
/// Replacement for the previous [`NotificationsSink`].
|
||||
notifications_sink: NotificationsSink,
|
||||
},
|
||||
@@ -176,7 +178,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
/// Node we closed the substream with.
|
||||
remote: PeerId,
|
||||
/// The concerned protocol. Each protocol uses a different substream.
|
||||
protocol: Cow<'static, str>,
|
||||
protocol: ProtocolName,
|
||||
},
|
||||
|
||||
/// Received one or more messages from the given node using the given protocol.
|
||||
@@ -184,7 +186,7 @@ pub enum BehaviourOut<B: BlockT> {
|
||||
/// Node we received the message from.
|
||||
remote: PeerId,
|
||||
/// Concerned protocol and associated message.
|
||||
messages: Vec<(Cow<'static, str>, Bytes)>,
|
||||
messages: Vec<(ProtocolName, Bytes)>,
|
||||
},
|
||||
|
||||
/// Now connected to a new peer for syncing purposes.
|
||||
|
||||
Reference in New Issue
Block a user