mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Remove HeaderBackend requirement from AuthorityDiscovery and NetworkWorker (#13730)
* Remove `HeaderBackend` requirement from `NetworkWorker` * Remove HeaderBackend from authority-discovery
This commit is contained in:
@@ -34,6 +34,7 @@ use prometheus_endpoint::Registry;
|
||||
pub use sc_network_common::{role::Role, sync::warp::WarpSyncProvider, ExHashT};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use std::{
|
||||
error::Error,
|
||||
fmt, fs,
|
||||
@@ -44,7 +45,6 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
pin::Pin,
|
||||
str::{self, FromStr},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
pub use libp2p::{
|
||||
@@ -688,7 +688,7 @@ impl NetworkConfiguration {
|
||||
}
|
||||
|
||||
/// Network initialization parameters.
|
||||
pub struct Params<Client> {
|
||||
pub struct Params<Block: BlockT> {
|
||||
/// Assigned role for our node (full, light, ...).
|
||||
pub role: Role,
|
||||
|
||||
@@ -698,12 +698,12 @@ pub struct Params<Client> {
|
||||
/// Network layer configuration.
|
||||
pub network_config: NetworkConfiguration,
|
||||
|
||||
/// Client that contains the blockchain.
|
||||
pub chain: Arc<Client>,
|
||||
|
||||
/// Legacy name of the protocol to use on the wire. Should be different for each chain.
|
||||
pub protocol_id: ProtocolId,
|
||||
|
||||
/// Genesis hash of the chain
|
||||
pub genesis_hash: Block::Hash,
|
||||
|
||||
/// Fork ID to distinguish protocols of different hard forks. Part of the standard protocol
|
||||
/// name on the wire.
|
||||
pub fork_id: Option<String>,
|
||||
|
||||
@@ -73,8 +73,7 @@ use parking_lot::Mutex;
|
||||
use sc_network_common::ExHashT;
|
||||
use sc_peerset::PeersetHandle;
|
||||
use sc_utils::mpsc::{tracing_unbounded, TracingUnboundedReceiver, TracingUnboundedSender};
|
||||
use sp_blockchain::HeaderBackend;
|
||||
use sp_runtime::traits::{Block as BlockT, Zero};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
|
||||
use std::{
|
||||
cmp,
|
||||
@@ -147,9 +146,7 @@ where
|
||||
/// Returns a `NetworkWorker` that implements `Future` and must be regularly polled in order
|
||||
/// for the network processing to advance. From it, you can extract a `NetworkService` using
|
||||
/// `worker.service()`. The `NetworkService` can be shared through the codebase.
|
||||
pub fn new<Client: HeaderBackend<B> + 'static>(
|
||||
mut params: Params<Client>,
|
||||
) -> Result<Self, Error> {
|
||||
pub fn new<Block: BlockT>(mut params: Params<Block>) -> Result<Self, Error> {
|
||||
// Private and public keys configuration.
|
||||
let local_identity = params.network_config.node_key.clone().into_keypair()?;
|
||||
let local_public = local_identity.public();
|
||||
@@ -277,13 +274,11 @@ where
|
||||
config.discovery_limit(
|
||||
u64::from(params.network_config.default_peers_set.out_peers) + 15,
|
||||
);
|
||||
let genesis_hash = params
|
||||
.chain
|
||||
.hash(Zero::zero())
|
||||
.ok()
|
||||
.flatten()
|
||||
.expect("Genesis block exists; qed");
|
||||
config.with_kademlia(genesis_hash, params.fork_id.as_deref(), ¶ms.protocol_id);
|
||||
config.with_kademlia(
|
||||
params.genesis_hash,
|
||||
params.fork_id.as_deref(),
|
||||
¶ms.protocol_id,
|
||||
);
|
||||
config.with_dht_random_walk(params.network_config.enable_dht_random_walk);
|
||||
config.allow_non_globals_in_dht(params.network_config.allow_non_globals_in_dht);
|
||||
config.use_kademlia_disjoint_query_paths(
|
||||
|
||||
Reference in New Issue
Block a user