1
0
Fork 0
mirror of https://github.com/romanz/electrs.git synced 2025-02-24 15:02:21 +01:00

Don't pass serde_json::Value by mutable reference

This commit is contained in:
Roman Zeyde 2018-07-16 11:48:09 +03:00
parent 96d06eaeeb
commit c7948e9972
No known key found for this signature in database
GPG key ID: 87CAE5FA46917CBB

View file

@ -51,7 +51,7 @@ fn tx_from_value(value: Value) -> Result<Transaction> {
Ok(deserialize(&tx_bytes).chain_err(|| format!("failed to parse tx {}", tx_hex))?)
}
fn parse_jsonrpc_reply(reply: &mut Value, method: &str) -> Result<Value> {
fn parse_jsonrpc_reply(mut reply: Value, method: &str) -> Result<Value> {
if let Some(reply_obj) = reply.as_object_mut() {
if let Some(err) = reply_obj.get("error") {
if !err.is_null() {
@ -264,9 +264,9 @@ impl Daemon {
fn request(&self, method: &str, params: Value) -> Result<Value> {
let req = json!({"method": method, "params": params});
let mut reply = self.call_jsonrpc(method, &req)
let reply = self.call_jsonrpc(method, &req)
.chain_err(|| format!("RPC failed: {}", req))?;
parse_jsonrpc_reply(&mut reply, method)
parse_jsonrpc_reply(reply, method)
}
fn requests(&self, method: &str, params_list: &[Value]) -> Result<Vec<Value>> {
@ -279,7 +279,7 @@ impl Daemon {
.chain_err(|| format!("RPC failed: {}", reqs))?;
if let Some(replies_vec) = replies.as_array_mut() {
for reply in replies_vec {
results.push(parse_jsonrpc_reply(reply, method)?)
results.push(parse_jsonrpc_reply(reply.take(), method)?)
}
return Ok(results);
}