Move gossip structs into behaviour

This commit is contained in:
Paul Hauner
2019-03-25 18:59:50 +11:00
parent 32a025bdf7
commit 098e63ac32
5 changed files with 25 additions and 20 deletions

View File

@@ -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,
}