@@ -3,6 +3,7 @@ use std::net::SocketAddr;
3
3
use jsonrpc_core:: types:: { Failure , Output , Success } ;
4
4
use serde:: de:: DeserializeOwned ;
5
5
use serde_json;
6
+ use serde_json:: Value ;
6
7
7
8
use super :: super :: common_rpc_types:: { BlackList , BlockId , NodeStatus , PendingParcel , StructuredLog , WhiteList } ;
8
9
use super :: agent:: { AgentSender , SendAgentRPC } ;
@@ -20,11 +21,12 @@ impl CodeChainRPC {
20
21
}
21
22
22
23
pub fn get_peers ( & self , status : NodeStatus ) -> Result < Vec < SocketAddr > , String > {
23
- self . call_rpc ( status, "net_getEstablishedPeers" )
24
+ self . call_rpc ( status, "net_getEstablishedPeers" , Vec :: new ( ) )
24
25
}
25
26
26
27
pub fn get_best_block_id ( & self , status : NodeStatus ) -> Result < Option < BlockId > , String > {
27
- let response: Option < ChainGetBestBlockIdResponse > = self . call_rpc ( status, "chain_getBestBlockId" ) ?;
28
+ let response: Option < ChainGetBestBlockIdResponse > =
29
+ self . call_rpc ( status, "chain_getBestBlockId" , Vec :: new ( ) ) ?;
28
30
29
31
Ok ( response. map ( |response| BlockId {
30
32
block_number : response. number ,
@@ -33,11 +35,11 @@ impl CodeChainRPC {
33
35
}
34
36
35
37
pub fn version ( & self , status : NodeStatus ) -> Result < Option < String > , String > {
36
- self . call_rpc ( status, "version" )
38
+ self . call_rpc ( status, "version" , Vec :: new ( ) )
37
39
}
38
40
39
41
pub fn commit_hash ( & self , status : NodeStatus ) -> Result < Option < String > , String > {
40
- self . call_rpc ( status, "commitHash" )
42
+ self . call_rpc ( status, "commitHash" , Vec :: new ( ) )
41
43
}
42
44
43
45
pub fn get_pending_parcels ( & self , _status : NodeStatus ) -> Result < Vec < PendingParcel > , String > {
@@ -46,26 +48,26 @@ impl CodeChainRPC {
46
48
}
47
49
48
50
pub fn get_whitelist ( & self , status : NodeStatus ) -> Result < Option < WhiteList > , String > {
49
- self . call_rpc ( status, "net_getWhitelist" )
51
+ self . call_rpc ( status, "net_getWhitelist" , Vec :: new ( ) )
50
52
}
51
53
52
54
pub fn get_blacklist ( & self , status : NodeStatus ) -> Result < Option < BlackList > , String > {
53
- self . call_rpc ( status, "net_getBlacklist" )
55
+ self . call_rpc ( status, "net_getBlacklist" , Vec :: new ( ) )
54
56
}
55
57
56
58
pub fn get_logs ( & self , status : NodeStatus ) -> Result < Option < Vec < StructuredLog > > , String > {
57
- self . call_rpc ( status, "slog" )
59
+ self . call_rpc ( status, "slog" , Vec :: new ( ) )
58
60
}
59
61
60
- fn call_rpc < T > ( & self , status : NodeStatus , method : & str ) -> Result < T , String >
62
+ fn call_rpc < T > ( & self , status : NodeStatus , method : & str , params : Vec < Value > ) -> Result < T , String >
61
63
where
62
64
T : Default + DeserializeOwned , {
63
65
if status != NodeStatus :: Run {
64
66
return Ok ( Default :: default ( ) )
65
67
}
66
68
67
69
let response =
68
- self . sender . codechain_call_rpc ( ( method. to_string ( ) , Vec :: new ( ) ) ) . map_err ( |err| format ! ( "{}" , err) ) ?;
70
+ self . sender . codechain_call_rpc ( ( method. to_string ( ) , params ) ) . map_err ( |err| format ! ( "{}" , err) ) ?;
69
71
70
72
let response: T = match response {
71
73
Output :: Success ( Success {
0 commit comments