mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Open one substream for each notifications protocol (#4909)
* Open one substream for each notifications protocol * Fix WASM build * Apply suggestions from code review Co-Authored-By: Toralf Wittner <tw@dtex.org> * Address concerns * Use unsigned-varint to read the varint * Use unsigned-varint * Forgot Cargo.lock Co-authored-by: Toralf Wittner <tw@dtex.org>
This commit is contained in:
@@ -65,6 +65,7 @@ mod periodic;
|
||||
pub(crate) mod tests;
|
||||
|
||||
pub use sp_finality_grandpa::GRANDPA_ENGINE_ID;
|
||||
pub const GRANDPA_PROTOCOL_NAME: &[u8] = b"/paritytech/grandpa/1";
|
||||
|
||||
// cost scalars for reporting peers.
|
||||
mod cost {
|
||||
@@ -185,7 +186,12 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
|
||||
);
|
||||
|
||||
let validator = Arc::new(validator);
|
||||
let gossip_engine = GossipEngine::new(service.clone(), GRANDPA_ENGINE_ID, validator.clone());
|
||||
let gossip_engine = GossipEngine::new(
|
||||
service.clone(),
|
||||
GRANDPA_ENGINE_ID,
|
||||
GRANDPA_PROTOCOL_NAME,
|
||||
validator.clone()
|
||||
);
|
||||
|
||||
{
|
||||
// register all previous votes with the gossip service so that they're
|
||||
|
||||
@@ -25,7 +25,7 @@ use std::sync::Arc;
|
||||
use sp_keyring::Ed25519Keyring;
|
||||
use parity_scale_codec::Encode;
|
||||
use sp_runtime::{ConsensusEngineId, traits::NumberFor};
|
||||
use std::{pin::Pin, task::{Context, Poll}};
|
||||
use std::{borrow::Cow, pin::Pin, task::{Context, Poll}};
|
||||
use crate::environment::SharedVoterSetState;
|
||||
use sp_finality_grandpa::{AuthorityList, GRANDPA_ENGINE_ID};
|
||||
use super::gossip::{self, GossipValidator};
|
||||
@@ -61,7 +61,7 @@ impl sc_network_gossip::Network<Block> for TestNetwork {
|
||||
let _ = self.sender.unbounded_send(Event::WriteNotification(who, message));
|
||||
}
|
||||
|
||||
fn register_notifications_protocol(&self, _: ConsensusEngineId) {}
|
||||
fn register_notifications_protocol(&self, _: ConsensusEngineId, _: Cow<'static, [u8]>) {}
|
||||
|
||||
fn announce(&self, block: Hash, _associated_data: Vec<u8>) {
|
||||
let _ = self.sender.unbounded_send(Event::Announce(block));
|
||||
|
||||
@@ -886,7 +886,10 @@ pub fn setup_disabled_grandpa<B, E, Block: BlockT, RA, N>(
|
||||
// We register the GRANDPA protocol so that we don't consider it an anomaly
|
||||
// to receive GRANDPA messages on the network. We don't process the
|
||||
// messages.
|
||||
network.register_notifications_protocol(communication::GRANDPA_ENGINE_ID);
|
||||
network.register_notifications_protocol(
|
||||
communication::GRANDPA_ENGINE_ID,
|
||||
From::from(communication::GRANDPA_PROTOCOL_NAME),
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user