mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 16:01:08 +00:00
Move around definitions in sc_network (#5701)
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
|
||||
pub use crate::chain::{Client, FinalityProofProvider};
|
||||
pub use crate::on_demand_layer::{AlwaysBadChecker, OnDemand};
|
||||
pub use crate::service::{TransactionPool, EmptyTransactionPool};
|
||||
pub use libp2p::{identity, core::PublicKey, wasm_ext::ExtTransport, build_multiaddr};
|
||||
|
||||
// Note: this re-export shouldn't be part of the public API of the crate and will be removed in
|
||||
@@ -29,17 +28,19 @@ pub use libp2p::{identity, core::PublicKey, wasm_ext::ExtTransport, build_multia
|
||||
#[doc(hidden)]
|
||||
pub use crate::protocol::ProtocolConfig;
|
||||
|
||||
use crate::service::ExHashT;
|
||||
use crate::{ExHashT, ReportHandle};
|
||||
|
||||
use core::{fmt, iter};
|
||||
use libp2p::identity::{ed25519, Keypair};
|
||||
use libp2p::wasm_ext;
|
||||
use libp2p::{multiaddr, Multiaddr, PeerId};
|
||||
use prometheus_endpoint::Registry;
|
||||
use sc_peerset::ReputationChange;
|
||||
use sp_consensus::{block_validation::BlockAnnounceValidator, import_queue::ImportQueue};
|
||||
use sp_runtime::{traits::Block as BlockT, ConsensusEngineId};
|
||||
use std::{borrow::Cow, convert::TryFrom, future::Future, pin::Pin, str::FromStr};
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
error::Error,
|
||||
fs,
|
||||
io::{self, Write},
|
||||
@@ -166,6 +167,60 @@ impl<B: BlockT> FinalityProofRequestBuilder<B> for DummyFinalityProofRequestBuil
|
||||
/// Shared finality proof request builder struct used by the queue.
|
||||
pub type BoxFinalityProofRequestBuilder<B> = Box<dyn FinalityProofRequestBuilder<B> + Send + Sync>;
|
||||
|
||||
/// Transaction pool interface
|
||||
pub trait TransactionPool<H: ExHashT, B: BlockT>: Send + Sync {
|
||||
/// Get transactions from the pool that are ready to be propagated.
|
||||
fn transactions(&self) -> Vec<(H, B::Extrinsic)>;
|
||||
/// Get hash of transaction.
|
||||
fn hash_of(&self, transaction: &B::Extrinsic) -> H;
|
||||
/// Import a transaction into the pool.
|
||||
///
|
||||
/// Peer reputation is changed by reputation_change if transaction is accepted by the pool.
|
||||
fn import(
|
||||
&self,
|
||||
report_handle: ReportHandle,
|
||||
who: PeerId,
|
||||
reputation_change_good: ReputationChange,
|
||||
reputation_change_bad: ReputationChange,
|
||||
transaction: B::Extrinsic,
|
||||
);
|
||||
/// Notify the pool about transactions broadcast.
|
||||
fn on_broadcasted(&self, propagations: HashMap<H, Vec<String>>);
|
||||
/// Get transaction by hash.
|
||||
fn transaction(&self, hash: &H) -> Option<B::Extrinsic>;
|
||||
}
|
||||
|
||||
/// Dummy implementation of the [`TransactionPool`] trait for a transaction pool that is always
|
||||
/// empty and discards all incoming transactions.
|
||||
///
|
||||
/// Requires the "hash" type to implement the `Default` trait.
|
||||
///
|
||||
/// Useful for testing purposes.
|
||||
pub struct EmptyTransactionPool;
|
||||
|
||||
impl<H: ExHashT + Default, B: BlockT> TransactionPool<H, B> for EmptyTransactionPool {
|
||||
fn transactions(&self) -> Vec<(H, B::Extrinsic)> {
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
fn hash_of(&self, _transaction: &B::Extrinsic) -> H {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
fn import(
|
||||
&self,
|
||||
_report_handle: ReportHandle,
|
||||
_who: PeerId,
|
||||
_rep_change_good: ReputationChange,
|
||||
_rep_change_bad: ReputationChange,
|
||||
_transaction: B::Extrinsic
|
||||
) {}
|
||||
|
||||
fn on_broadcasted(&self, _: HashMap<H, Vec<String>>) {}
|
||||
|
||||
fn transaction(&self, _h: &H) -> Option<B::Extrinsic> { None }
|
||||
}
|
||||
|
||||
/// Name of a protocol, transmitted on the wire. Should be unique for each chain.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ProtocolId(smallvec::SmallVec<[u8; 6]>);
|
||||
|
||||
Reference in New Issue
Block a user