From 4c02b0d43115f5d792908dd30580eaf241e8fc58 Mon Sep 17 00:00:00 2001 From: Michael Mallan Date: Wed, 4 Sep 2024 10:53:29 +0100 Subject: [PATCH] bitcoin: use mut ref for start_rescan --- src/bitcoin/d/mod.rs | 2 +- src/bitcoin/mod.rs | 6 +++--- src/commands/mod.rs | 2 +- src/jsonrpc/api.rs | 4 ++-- src/jsonrpc/server.rs | 4 ++-- src/testutils.rs | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/bitcoin/d/mod.rs b/src/bitcoin/d/mod.rs index 41e25216..fe26b732 100644 --- a/src/bitcoin/d/mod.rs +++ b/src/bitcoin/d/mod.rs @@ -1096,7 +1096,7 @@ impl BitcoinD { } pub fn start_rescan( - &self, + &mut self, desc: &LianaDescriptor, timestamp: u32, ) -> Result<(), BitcoindError> { diff --git a/src/bitcoin/mod.rs b/src/bitcoin/mod.rs index effc0320..6e47f148 100644 --- a/src/bitcoin/mod.rs +++ b/src/bitcoin/mod.rs @@ -109,7 +109,7 @@ pub trait BitcoinInterface: Send { /// Trigger a rescan of the block chain for transactions related to this descriptor since /// the given date. fn start_rescan( - &self, + &mut self, desc: &descriptors::LianaDescriptor, timestamp: u32, ) -> Result<(), String>; @@ -367,7 +367,7 @@ impl BitcoinInterface for d::BitcoinD { } fn start_rescan( - &self, + &mut self, desc: &descriptors::LianaDescriptor, timestamp: u32, ) -> Result<(), String> { @@ -481,7 +481,7 @@ impl BitcoinInterface for sync::Arc> } fn start_rescan( - &self, + &mut self, desc: &descriptors::LianaDescriptor, timestamp: u32, ) -> Result<(), String> { diff --git a/src/commands/mod.rs b/src/commands/mod.rs index 6e2b2063..092e87e7 100644 --- a/src/commands/mod.rs +++ b/src/commands/mod.rs @@ -986,7 +986,7 @@ impl DaemonControl { /// Trigger a rescan of the block chain for transactions involving our main descriptor between /// the given date and the current tip. /// The date must be after the genesis block time and before the current tip blocktime. - pub fn start_rescan(&self, timestamp: u32) -> Result<(), CommandError> { + pub fn start_rescan(&mut self, timestamp: u32) -> Result<(), CommandError> { let mut db_conn = self.db.connection(); let genesis_timestamp = self.bitcoin.genesis_block_timestamp(); diff --git a/src/jsonrpc/api.rs b/src/jsonrpc/api.rs index 5835e2e9..3ff137af 100644 --- a/src/jsonrpc/api.rs +++ b/src/jsonrpc/api.rs @@ -266,7 +266,7 @@ fn list_transactions(control: &DaemonControl, params: Params) -> Result Result { +fn start_rescan(control: &mut DaemonControl, params: Params) -> Result { let timestamp: u32 = params .get(0, "timestamp") .ok_or_else(|| Error::invalid_params("Missing 'timestamp' parameter."))? @@ -365,7 +365,7 @@ fn get_labels(control: &DaemonControl, params: Params) -> Result Result { +pub fn handle_request(control: &mut DaemonControl, req: Request) -> Result { let result = match req.method.as_str() { "broadcastspend" => { let params = req diff --git a/src/jsonrpc/server.rs b/src/jsonrpc/server.rs index 424adc2a..49b0d925 100644 --- a/src/jsonrpc/server.rs +++ b/src/jsonrpc/server.rs @@ -81,7 +81,7 @@ fn read_command( // Handle all messages from this connection. fn connection_handler( - control: DaemonControl, + mut control: DaemonControl, mut stream: net::UnixStream, shutdown: sync::Arc, ) -> Result<(), io::Error> { @@ -106,7 +106,7 @@ fn connection_handler( log::trace!("JSONRPC request: {:?}", serde_json::to_string(&req)); let response = - api::handle_request(&control, req).unwrap_or_else(|e| Response::error(req_id, e)); + api::handle_request(&mut control, req).unwrap_or_else(|e| Response::error(req_id, e)); log::trace!("JSONRPC response: {:?}", serde_json::to_string(&response)); if let Err(e) = serde_json::to_writer(&stream, &response) { log::error!("Error writing response: '{}'", e); diff --git a/src/testutils.rs b/src/testutils.rs index ffea3ddc..c5800b90 100644 --- a/src/testutils.rs +++ b/src/testutils.rs @@ -109,7 +109,7 @@ impl BitcoinInterface for DummyBitcoind { todo!() } - fn start_rescan(&self, _: &descriptors::LianaDescriptor, _: u32) -> Result<(), String> { + fn start_rescan(&mut self, _: &descriptors::LianaDescriptor, _: u32) -> Result<(), String> { todo!() }