client/node_types/
full.rs1use crate::{
6 common::{initialize_not_light_node_modules, ClientComponents},
7 configuration::Configuration,
8};
9use blockgen::BlockGenerator;
10use cfx_rpc_builder::RpcServerHandle;
11use cfx_tasks::TaskManager;
12use cfxcore::{
13 pow::PowComputer, ConsensusGraph, NodeType, SynchronizationService,
14 TransactionPool,
15};
16use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
17use parking_lot::{Condvar, Mutex};
18use std::sync::Arc;
19use tokio::runtime::Runtime as TokioRuntime;
20
21pub struct FullClientExtraComponents {
22 pub consensus: Arc<ConsensusGraph>,
23 pub sync: Arc<SynchronizationService>,
24 pub txpool: Arc<TransactionPool>,
25 pub pow: Arc<PowComputer>,
26 pub eth_rpc_server_handle: Option<RpcServerHandle>,
29 pub cfx_rpc_server_handle: Option<RpcServerHandle>,
33 pub debug_cfx_rpc_server_handle: Option<RpcServerHandle>,
36 pub tokio_runtime: Arc<TokioRuntime>,
37 pub task_manager: TaskManager,
38}
39
40impl MallocSizeOf for FullClientExtraComponents {
41 fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { unimplemented!() }
42}
43
44pub struct FullClient {}
45
46impl FullClient {
47 pub fn start(
49 mut conf: Configuration, exit: Arc<(Mutex<bool>, Condvar)>,
50 ) -> Result<
51 Box<ClientComponents<BlockGenerator, FullClientExtraComponents>>,
52 String,
53 > {
54 let (
55 data_man,
56 pow,
57 txpool,
58 consensus,
59 sync,
60 blockgen,
61 pos_handler,
62 tokio_runtime,
63 eth_rpc_server_handle,
64 cfx_rpc_server_handle,
65 debug_cfx_rpc_server_handle,
66 task_manager,
67 ) = initialize_not_light_node_modules(&mut conf, exit, NodeType::Full)?;
68 Ok(Box::new(ClientComponents {
69 data_manager_weak_ptr: Arc::downgrade(&data_man),
70 blockgen: Some(blockgen),
71 pos_handler: Some(pos_handler),
72 other_components: FullClientExtraComponents {
73 consensus,
74 sync,
75 txpool,
76 pow,
77 eth_rpc_server_handle,
78 cfx_rpc_server_handle,
79 debug_cfx_rpc_server_handle,
80 tokio_runtime,
81 task_manager,
82 },
83 }))
84 }
85}