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 tokio_runtime: Arc<TokioRuntime>,
40 pub task_manager: TaskManager,
41}
42
43impl MallocSizeOf for FullClientExtraComponents {
44 fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize { unimplemented!() }
45}
46
47pub struct FullClient {}
48
49impl FullClient {
50 pub fn start(
52 mut conf: Configuration, exit: Arc<(Mutex<bool>, Condvar)>,
53 ) -> Result<
54 Box<ClientComponents<BlockGenerator, FullClientExtraComponents>>,
55 String,
56 > {
57 let (
58 data_man,
59 pow,
60 txpool,
61 consensus,
62 sync,
63 blockgen,
64 debug_rpc_http_server,
65 rpc_http_server,
66 debug_rpc_tcp_server,
67 rpc_tcp_server,
68 debug_rpc_ws_server,
69 rpc_ws_server,
70 pos_handler,
71 tokio_runtime,
72 eth_rpc_server_handle,
73 task_manager,
74 ) = initialize_not_light_node_modules(&mut conf, exit, NodeType::Full)?;
75 Ok(Box::new(ClientComponents {
76 data_manager_weak_ptr: Arc::downgrade(&data_man),
77 blockgen: Some(blockgen),
78 pos_handler: Some(pos_handler),
79 other_components: FullClientExtraComponents {
80 consensus,
81 debug_rpc_http_server,
82 rpc_http_server,
83 debug_rpc_tcp_server,
84 rpc_tcp_server,
85 debug_rpc_ws_server,
86 rpc_ws_server,
87 sync,
88 txpool,
89 pow,
90 eth_rpc_server_handle,
91 tokio_runtime,
92 task_manager,
93 },
94 }))
95 }
96}