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
// Copyright 2019 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/

mod consensus_graph_exposer;
mod network_exposer;
mod sync_graph_exposer;

pub use self::{
    consensus_graph_exposer::{
        ConsensusGraphBlockExecutionState, ConsensusGraphBlockState,
        ConsensusGraphStates,
    },
    network_exposer::NetworkExposer,
    sync_graph_exposer::{SyncGraphBlockState, SyncGraphStates},
};

use parking_lot::Mutex;
use std::sync::Arc;

pub type SharedStateExposer = Arc<StateExposer>;

pub struct StateExposer {
    pub consensus_graph: Mutex<ConsensusGraphStates>,
    pub sync_graph: Mutex<SyncGraphStates>,
    pub network: Mutex<NetworkExposer>,
}

impl StateExposer {
    pub fn new() -> Self {
        Self {
            consensus_graph: Mutex::new(Default::default()),
            sync_graph: Mutex::new(Default::default()),
            network: Mutex::new(Default::default()),
        }
    }
}

lazy_static! {
    pub static ref STATE_EXPOSER: SharedStateExposer =
        SharedStateExposer::new(StateExposer::new());
}