client/node_types/
full.rs1use jsonrpc_http_server::Server as HttpServer;
6use jsonrpc_tcp_server::Server as TcpServer;
7use jsonrpc_ws_server::Server as WsServer;
8
9use crate::{
10 common::{initialize_not_light_node_modules, ClientComponents},
11 configuration::Configuration,
12};
13use blockgen::BlockGenerator;
14use cfx_rpc_builder::RpcServerHandle;
15use cfx_tasks::TaskManager;
16use cfxcore::{
17 pow::PowComputer, ConsensusGraph, NodeType, SynchronizationService,
18 TransactionPool,
19};
20use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
21use parking_lot::{Condvar, Mutex};
22use std::sync::Arc;
23use tokio::runtime::Runtime as TokioRuntime;
24
25pub struct FullClientExtraComponents {
26 pub consensus: Arc<ConsensusGraph>,
27 pub debug_rpc_http_server: Option<HttpServer>,
28 pub rpc_http_server: Option<HttpServer>,
29 pub debug_rpc_tcp_server: Option<TcpServer>,
30 pub rpc_tcp_server: Option<TcpServer>,
31 pub debug_rpc_ws_server: Option<WsServer>,
32 pub rpc_ws_server: Option<WsServer>,
33 pub sync: Arc<SynchronizationService>,
34 pub txpool: Arc<TransactionPool>,
35 pub pow: Arc<PowComputer>,
36 pub eth_rpc_server_handle: Option<RpcServerHandle>,
39 pub cfx_rpc_server_handle: Option<RpcServerHandle>,
43 pub debug_cfx_rpc_server_handle: Option<RpcServerHandle>,
46 pub tokio_runtime: Arc<TokioRuntime>,
47 pub task_manager: TaskManager,
48}
49
50impl MallocSizeOf for FullClientExtraComponents {
51 fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { unimplemented!() }
52}
53
54pub struct FullClient {}
55
56impl FullClient {
57 pub fn start(
59 mut conf: Configuration, exit: Arc<(Mutex<bool>, Condvar)>,
60 ) -> Result<
61 Box<ClientComponents<BlockGenerator, FullClientExtraComponents>>,
62 String,
63 > {
64 let (
65 data_man,
66 pow,
67 txpool,
68 consensus,
69 sync,
70 blockgen,
71 debug_rpc_http_server,
72 rpc_http_server,
73 debug_rpc_tcp_server,
74 rpc_tcp_server,
75 debug_rpc_ws_server,
76 rpc_ws_server,
77 pos_handler,
78 tokio_runtime,
79 eth_rpc_server_handle,
80 cfx_rpc_server_handle,
81 debug_cfx_rpc_server_handle,
82 task_manager,
83 ) = initialize_not_light_node_modules(&mut conf, exit, NodeType::Full)?;
84 Ok(Box::new(ClientComponents {
85 data_manager_weak_ptr: Arc::downgrade(&data_man),
86 blockgen: Some(blockgen),
87 pos_handler: Some(pos_handler),
88 other_components: FullClientExtraComponents {
89 consensus,
90 debug_rpc_http_server,
91 rpc_http_server,
92 debug_rpc_tcp_server,
93 rpc_tcp_server,
94 debug_rpc_ws_server,
95 rpc_ws_server,
96 sync,
97 txpool,
98 pow,
99 eth_rpc_server_handle,
100 cfx_rpc_server_handle,
101 debug_cfx_rpc_server_handle,
102 tokio_runtime,
103 task_manager,
104 },
105 }))
106 }
107}