Move BlockData to a new file

This commit is contained in:
Luke Parker 2022-11-12 11:42:40 -05:00
parent 2f3bb88744
commit b7b57ee6dc
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
2 changed files with 28 additions and 17 deletions
substrate/tendermint/machine/src

View file

@ -0,0 +1,23 @@
use std::collections::{HashSet, HashMap};
use crate::{
time::CanonicalInstant,
ext::{RoundNumber, BlockNumber, Block, Network},
round::RoundData,
message_log::MessageLog,
};
pub(crate) struct BlockData<N: Network> {
pub(crate) number: BlockNumber,
pub(crate) validator_id: Option<N::ValidatorId>,
pub(crate) proposal: N::Block,
pub(crate) log: MessageLog<N>,
pub(crate) slashes: HashSet<N::ValidatorId>,
pub(crate) end_time: HashMap<RoundNumber, CanonicalInstant>,
pub(crate) round: RoundData<N>,
pub(crate) locked: Option<(RoundNumber, <N::Block as Block>::Id)>,
pub(crate) valid: Option<(RoundNumber, N::Block)>,
}

View file

@ -16,10 +16,13 @@ use futures::{
use tokio::time::sleep;
mod time;
use time::*;
use time::{sys_time, CanonicalInstant};
mod round;
use round::*;
use round::RoundData;
mod block;
use block::BlockData;
mod message_log;
use message_log::MessageLog;
@ -106,21 +109,6 @@ enum TendermintError<V: ValidatorId> {
Temporal,
}
struct BlockData<N: Network> {
number: BlockNumber,
validator_id: Option<N::ValidatorId>,
proposal: N::Block,
log: MessageLog<N>,
slashes: HashSet<N::ValidatorId>,
end_time: HashMap<RoundNumber, CanonicalInstant>,
round: RoundData<N>,
locked: Option<(RoundNumber, <N::Block as Block>::Id)>,
valid: Option<(RoundNumber, N::Block)>,
}
/// A machine executing the Tendermint protocol.
pub struct TendermintMachine<N: Network> {
network: N,