Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Structures for Message - Manager Communication #69

Merged
merged 5 commits into from
Dec 9, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions blockchain/src/blocks/block_msg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
use super::TipSetKeys;
use libp2p::PeerId;
use std::fmt;

/// BlockMsg is a container used to decode pubsub messages into prior to validation and propagation
pub struct BlockMsg {
dutterbutter marked this conversation as resolved.
Show resolved Hide resolved
// the originator of the TipSetKey propagation wave
_source: PeerId,
// the peer that sent us the TipSetKey message
_sender: PeerId,
// proposed canonical tipset keys
_head: TipSetKeys,
// proposed chain height
_height: u64,
}

impl BlockMsg {
/// new creates a BlockMsg container for peer id a head tipset key and chain height
fn _new(_source: PeerId, _sender: PeerId, _head: TipSetKeys, _height: u64) -> Self {
Self {
_source,
_sender,
_head,
_height,
}
}
}

/// human-readable string representation of a block msg
impl fmt::Display for BlockMsg {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{} {} {:?} {}",
self._source, self._sender, self._head, self._height
)
}
}
35 changes: 0 additions & 35 deletions blockchain/src/blocks/chain_info.rs

This file was deleted.

3 changes: 1 addition & 2 deletions blockchain/src/blocks/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
mod block;
pub mod chain_info;
pub mod block_msg;
mod errors;
mod ticket;
mod tipset;

pub use block::*;
pub use chain_info::*;
pub use errors::*;
pub use tipset::*;
10 changes: 5 additions & 5 deletions blockchain/src/chain_sync/block_proposer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::blocks::chain_info::BlockMsg;
use crate::blocks::block_msg::BlockMsg;
dutterbutter marked this conversation as resolved.
Show resolved Hide resolved
use std::io;
/// BlockProposer allows callers to propose new blocks for inclusion in the chain
trait BlockProposer {
fn send_hello(bm: BlockMsg) -> Result<(), io::Error>;
fn send_own_block(bm: BlockMsg) -> Result<(), io::Error>;
fn send_gossip_block(bm: BlockMsg) -> Result<(), io::Error>;
pub trait BlockProposer {
fn send_hello(&self, bm: BlockMsg) -> Result<(), io::Error>;
fn send_own_block(&self, bm: BlockMsg) -> Result<(), io::Error>;
fn send_gossip_block(&self, bm: BlockMsg) -> Result<(), io::Error>;
}