1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use super::model::{
    ConsensusVote,
    FuelBlock,
    SealedFuelBlock,
};
use crate::common::fuel_types::Bytes32;
use std::sync::Arc;

#[derive(Clone, Debug)]
pub enum ImportBlockBroadcast {
    PendingFuelBlockImported {
        block: Arc<FuelBlock>,
    },
    /// for blocks that imported in initial sync and in active sync.
    SealedFuelBlockImported {
        block: Arc<SealedFuelBlock>,
        is_created_by_self: bool,
    },
}

impl ImportBlockBroadcast {
    pub fn block(&self) -> &FuelBlock {
        match self {
            Self::PendingFuelBlockImported { block } => block.as_ref(),
            Self::SealedFuelBlockImported { block, .. } => &block.as_ref().block,
        }
    }
}

pub enum ImportBlockMpsc {
    ImportSealedFuelBlock {
        block: Arc<SealedFuelBlock>,
    },
    ImportFuelBlock {
        block: Arc<FuelBlock>,
    },
    SealFuelBlock {
        votes: Vec<ConsensusVote>,
        block_id: Bytes32,
    },
    Stop,
}