mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 18:27:56 +00:00
Rename CustomProto to LegacyProto (#3313)
This commit is contained in:
committed by
Gavin Wood
parent
97febf4c30
commit
c32d9a17e0
@@ -15,7 +15,7 @@
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{DiscoveryNetBehaviour, config::ProtocolId};
|
||||
use crate::custom_proto::{CustomProto, CustomProtoOut};
|
||||
use crate::legacy_proto::{LegacyProto, LegacyProtoOut};
|
||||
use futures::prelude::*;
|
||||
use futures03::{StreamExt as _, TryStreamExt as _};
|
||||
use libp2p::{Multiaddr, PeerId};
|
||||
@@ -111,7 +111,7 @@ pub struct Protocol<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> {
|
||||
/// When asked for a proof of finality, we use this struct to build one.
|
||||
finality_proof_provider: Option<Arc<dyn FinalityProofProvider<B>>>,
|
||||
/// Handles opening the unique substream and sending and receiving raw messages.
|
||||
behaviour: CustomProto<B, Substream<StreamMuxerBox>>,
|
||||
behaviour: LegacyProto<B, Substream<StreamMuxerBox>>,
|
||||
}
|
||||
|
||||
/// A peer that we are connected to
|
||||
@@ -150,7 +150,7 @@ pub struct PeerInfo<B: BlockT> {
|
||||
}
|
||||
|
||||
struct LightDispatchIn<'a, B: BlockT> {
|
||||
behaviour: &'a mut CustomProto<B, Substream<StreamMuxerBox>>,
|
||||
behaviour: &'a mut LegacyProto<B, Substream<StreamMuxerBox>>,
|
||||
peerset: peerset::PeersetHandle,
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ pub trait Context<B: BlockT> {
|
||||
|
||||
/// Protocol context.
|
||||
struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> {
|
||||
behaviour: &'a mut CustomProto<B, Substream<StreamMuxerBox>>,
|
||||
behaviour: &'a mut LegacyProto<B, Substream<StreamMuxerBox>>,
|
||||
context_data: &'a mut ContextData<B, H>,
|
||||
peerset_handle: &'a peerset::PeersetHandle,
|
||||
}
|
||||
@@ -289,7 +289,7 @@ struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> {
|
||||
impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> {
|
||||
fn new(
|
||||
context_data: &'a mut ContextData<B, H>,
|
||||
behaviour: &'a mut CustomProto<B, Substream<StreamMuxerBox>>,
|
||||
behaviour: &'a mut LegacyProto<B, Substream<StreamMuxerBox>>,
|
||||
peerset_handle: &'a peerset::PeersetHandle,
|
||||
) -> Self {
|
||||
ProtocolContext { context_data, peerset_handle, behaviour }
|
||||
@@ -363,7 +363,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
let sync = ChainSync::new(config.roles, chain.clone(), &info, finality_proof_request_builder);
|
||||
let (peerset, peerset_handle) = peerset::Peerset::from_config(peerset_config);
|
||||
let versions = &((MIN_VERSION as u8)..=(CURRENT_VERSION as u8)).collect::<Vec<u8>>();
|
||||
let behaviour = CustomProto::new(protocol_id, versions, peerset);
|
||||
let behaviour = LegacyProto::new(protocol_id, versions, peerset);
|
||||
|
||||
let protocol = Protocol {
|
||||
tick_timeout: Box::new(futures_timer::Interval::new(TICK_TIMEOUT).map(|v| Ok::<_, ()>(v)).compat()),
|
||||
@@ -1479,7 +1479,7 @@ pub enum CustomMessageOutcome<B: BlockT> {
|
||||
}
|
||||
|
||||
fn send_message<B: BlockT, H: ExHashT>(
|
||||
behaviour: &mut CustomProto<B, Substream<StreamMuxerBox>>,
|
||||
behaviour: &mut LegacyProto<B, Substream<StreamMuxerBox>>,
|
||||
peers: &mut HashMap<PeerId, Peer<B, H>>,
|
||||
who: PeerId,
|
||||
mut message: Message<B>,
|
||||
@@ -1500,7 +1500,7 @@ fn send_message<B: BlockT, H: ExHashT>(
|
||||
|
||||
impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> NetworkBehaviour for
|
||||
Protocol<B, S, H> {
|
||||
type ProtocolsHandler = <CustomProto<B, Substream<StreamMuxerBox>> as NetworkBehaviour>::ProtocolsHandler;
|
||||
type ProtocolsHandler = <LegacyProto<B, Substream<StreamMuxerBox>> as NetworkBehaviour>::ProtocolsHandler;
|
||||
type OutEvent = CustomMessageOutcome<B>;
|
||||
|
||||
fn new_handler(&mut self) -> Self::ProtocolsHandler {
|
||||
@@ -1568,7 +1568,7 @@ Protocol<B, S, H> {
|
||||
};
|
||||
|
||||
let outcome = match event {
|
||||
CustomProtoOut::CustomProtocolOpen { peer_id, version, .. } => {
|
||||
LegacyProtoOut::CustomProtocolOpen { peer_id, version, .. } => {
|
||||
debug_assert!(
|
||||
version <= CURRENT_VERSION as u8
|
||||
&& version >= MIN_VERSION as u8
|
||||
@@ -1576,13 +1576,13 @@ Protocol<B, S, H> {
|
||||
self.on_peer_connected(peer_id);
|
||||
CustomMessageOutcome::None
|
||||
}
|
||||
CustomProtoOut::CustomProtocolClosed { peer_id, .. } => {
|
||||
LegacyProtoOut::CustomProtocolClosed { peer_id, .. } => {
|
||||
self.on_peer_disconnected(peer_id);
|
||||
CustomMessageOutcome::None
|
||||
},
|
||||
CustomProtoOut::CustomMessage { peer_id, message } =>
|
||||
LegacyProtoOut::CustomMessage { peer_id, message } =>
|
||||
self.on_custom_message(peer_id, message),
|
||||
CustomProtoOut::Clogged { peer_id, messages } => {
|
||||
LegacyProtoOut::Clogged { peer_id, messages } => {
|
||||
debug!(target: "sync", "{} clogging messages:", messages.len());
|
||||
for msg in messages.into_iter().take(5) {
|
||||
debug!(target: "sync", "{:?}", msg);
|
||||
|
||||
Reference in New Issue
Block a user