Skip to content
This repository was archived by the owner on Apr 5, 2019. It is now read-only.

Commit d66e74f

Browse files
committed
Pass parameters to the call_rpc function
1 parent 1e4ca63 commit d66e74f

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/agent/codechain_rpc.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::net::SocketAddr;
33
use jsonrpc_core::types::{Failure, Output, Success};
44
use serde::de::DeserializeOwned;
55
use serde_json;
6+
use serde_json::Value;
67

78
use super::super::common_rpc_types::{BlackList, BlockId, NodeStatus, PendingParcel, StructuredLog, WhiteList};
89
use super::agent::{AgentSender, SendAgentRPC};
@@ -20,11 +21,12 @@ impl CodeChainRPC {
2021
}
2122

2223
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())
2425
}
2526

2627
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())?;
2830

2931
Ok(response.map(|response| BlockId {
3032
block_number: response.number,
@@ -33,11 +35,11 @@ impl CodeChainRPC {
3335
}
3436

3537
pub fn version(&self, status: NodeStatus) -> Result<Option<String>, String> {
36-
self.call_rpc(status, "version")
38+
self.call_rpc(status, "version", Vec::new())
3739
}
3840

3941
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())
4143
}
4244

4345
pub fn get_pending_parcels(&self, _status: NodeStatus) -> Result<Vec<PendingParcel>, String> {
@@ -46,26 +48,26 @@ impl CodeChainRPC {
4648
}
4749

4850
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())
5052
}
5153

5254
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())
5456
}
5557

5658
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())
5860
}
5961

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>
6163
where
6264
T: Default + DeserializeOwned, {
6365
if status != NodeStatus::Run {
6466
return Ok(Default::default())
6567
}
6668

6769
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))?;
6971

7072
let response: T = match response {
7173
Output::Success(Success {

0 commit comments

Comments
 (0)