Move gossip structs into behaviour
This commit is contained in:
parent
32a025bdf7
commit
098e63ac32
@ -1,3 +1,4 @@
|
||||
use crate::rpc::methods::BlockRootSlot;
|
||||
use crate::rpc::{RPCEvent, RPCMessage, Rpc};
|
||||
use crate::NetworkConfig;
|
||||
use futures::prelude::*;
|
||||
@ -13,6 +14,8 @@ use libp2p::{
|
||||
NetworkBehaviour, PeerId,
|
||||
};
|
||||
use slog::{debug, o};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use types::Attestation;
|
||||
use types::Topic;
|
||||
|
||||
/// Builds the network behaviour for the libp2p Swarm.
|
||||
@ -154,3 +157,21 @@ pub enum BehaviourEvent {
|
||||
// TODO: This is a stub at the moment
|
||||
Message(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum IncomingGossip {
|
||||
Block(BlockGossip),
|
||||
Attestation(AttestationGossip),
|
||||
}
|
||||
|
||||
/// Gossipsub message providing notification of a new block.
|
||||
#[derive(Encode, Decode, Clone, Debug, PartialEq)]
|
||||
pub struct BlockGossip {
|
||||
pub root: BlockRootSlot,
|
||||
}
|
||||
|
||||
/// Gossipsub message providing notification of a new attestation.
|
||||
#[derive(Encode, Decode, Clone, Debug, PartialEq)]
|
||||
pub struct AttestationGossip {
|
||||
pub attestation: Attestation,
|
||||
}
|
||||
|
@ -97,12 +97,6 @@ impl RPCResponse {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum IncomingGossip {
|
||||
Block(BlockGossip),
|
||||
Attestation(AttestationGossip),
|
||||
}
|
||||
|
||||
/* Request/Response data structures for RPC methods */
|
||||
|
||||
/// The HELLO request/response handshake message.
|
||||
@ -242,15 +236,3 @@ pub struct BeaconChainStateResponse {
|
||||
/// The values corresponding the to the requested tree hashes.
|
||||
pub values: bool, //TBD - stubbed with encodeable bool
|
||||
}
|
||||
|
||||
/// Gossipsub message providing notification of a new block.
|
||||
#[derive(Encode, Decode, Clone, Debug, PartialEq)]
|
||||
pub struct BlockGossip {
|
||||
pub root: BlockRootSlot,
|
||||
}
|
||||
|
||||
/// Gossipsub message providing notification of a new attestation.
|
||||
#[derive(Encode, Decode, Clone, Debug, PartialEq)]
|
||||
pub struct AttestationGossip {
|
||||
pub attestation: Attestation,
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ use libp2p::core::swarm::{
|
||||
ConnectedPoint, NetworkBehaviour, NetworkBehaviourAction, PollParameters,
|
||||
};
|
||||
use libp2p::{Multiaddr, PeerId};
|
||||
pub use methods::{HelloMessage, IncomingGossip, RPCMethod, RPCRequest, RPCResponse};
|
||||
pub use methods::{HelloMessage, RPCMethod, RPCRequest, RPCResponse};
|
||||
pub use protocol::{RPCEvent, RPCProtocol, RequestId};
|
||||
use slog::o;
|
||||
use std::marker::PhantomData;
|
||||
|
@ -4,7 +4,8 @@ use crate::service::{NetworkMessage, OutgoingMessage};
|
||||
use crate::sync::SimpleSync;
|
||||
use crossbeam_channel::{unbounded as channel, Sender};
|
||||
use eth2_libp2p::{
|
||||
rpc::{methods::GoodbyeReason, IncomingGossip, RPCRequest, RPCResponse, RequestId},
|
||||
behaviour::IncomingGossip,
|
||||
rpc::{methods::GoodbyeReason, RPCRequest, RPCResponse, RequestId},
|
||||
PeerId, RPCEvent,
|
||||
};
|
||||
use futures::future;
|
||||
|
@ -1,6 +1,7 @@
|
||||
use super::import_queue::ImportQueue;
|
||||
use crate::beacon_chain::BeaconChain;
|
||||
use crate::message_handler::NetworkContext;
|
||||
use eth2_libp2p::behaviour::{AttestationGossip, BlockGossip};
|
||||
use eth2_libp2p::rpc::methods::*;
|
||||
use eth2_libp2p::rpc::{RPCRequest, RPCResponse, RequestId};
|
||||
use eth2_libp2p::PeerId;
|
||||
|
Loading…
Reference in New Issue
Block a user