mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
Make network-libp2p's Service generic over the message (#1708)
* Make network-libp2p's Service generic over the message * Apply suggestions from code review Co-Authored-By: tomaka <pierre.krieger1708@gmail.com> * Fix warning
This commit is contained in:
committed by
Bastian Köcher
parent
1f05a47cdb
commit
9e999cdd81
@@ -14,7 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use parity_codec::Encode;
|
||||
use crossbeam_channel::{self as channel, Receiver, Sender, select};
|
||||
use network_libp2p::{NodeIndex, Severity};
|
||||
use primitives::storage::StorageKey;
|
||||
@@ -56,7 +55,7 @@ const LIGHT_MAXIMAL_BLOCKS_DIFFERENCE: u64 = 8192;
|
||||
|
||||
// Lock must always be taken in order declared here.
|
||||
pub struct Protocol<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> {
|
||||
network_chan: NetworkChan,
|
||||
network_chan: NetworkChan<B>,
|
||||
port: Receiver<ProtocolMsg<B, S>>,
|
||||
config: ProtocolConfig,
|
||||
on_demand: Option<Arc<OnDemandService<B>>>,
|
||||
@@ -133,14 +132,14 @@ pub trait Context<B: BlockT> {
|
||||
|
||||
/// Protocol context.
|
||||
pub(crate) struct ProtocolContext<'a, B: 'a + BlockT, H: 'a + ExHashT> {
|
||||
network_chan: &'a NetworkChan,
|
||||
network_chan: &'a NetworkChan<B>,
|
||||
context_data: &'a mut ContextData<B, H>,
|
||||
}
|
||||
|
||||
impl<'a, B: BlockT + 'a, H: 'a + ExHashT> ProtocolContext<'a, B, H> {
|
||||
pub(crate) fn new(
|
||||
context_data: &'a mut ContextData<B, H>,
|
||||
network_chan: &'a NetworkChan,
|
||||
network_chan: &'a NetworkChan<B>,
|
||||
) -> Self {
|
||||
ProtocolContext {
|
||||
network_chan,
|
||||
@@ -276,7 +275,7 @@ pub enum ProtocolMsg<B: BlockT, S: NetworkSpecialization<B>,> {
|
||||
impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
/// Create a new instance.
|
||||
pub fn new<I: 'static + ImportQueue<B>>(
|
||||
network_chan: NetworkChan,
|
||||
network_chan: NetworkChan<B>,
|
||||
config: ProtocolConfig,
|
||||
chain: Arc<Client<B>>,
|
||||
import_queue: Arc<I>,
|
||||
@@ -1106,7 +1105,7 @@ impl<B: BlockT, S: NetworkSpecialization<B>, H: ExHashT> Protocol<B, S, H> {
|
||||
|
||||
fn send_message<B: BlockT, H: ExHashT>(
|
||||
peers: &mut HashMap<NodeIndex, Peer<B, H>>,
|
||||
network_chan: &NetworkChan,
|
||||
network_chan: &NetworkChan<B>,
|
||||
who: NodeIndex,
|
||||
mut message: Message<B>,
|
||||
) {
|
||||
@@ -1124,7 +1123,7 @@ fn send_message<B: BlockT, H: ExHashT>(
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
network_chan.send(NetworkMsg::Outgoing(who, message.encode()));
|
||||
network_chan.send(NetworkMsg::Outgoing(who, message));
|
||||
}
|
||||
|
||||
/// Construct a simple protocol that is composed of several sub protocols.
|
||||
|
||||
Reference in New Issue
Block a user