From: Matt Corallo Date: Wed, 22 Sep 2021 03:57:53 +0000 (+0000) Subject: Make `ChainMonitor::get_claimable_balances` take a slice of refs X-Git-Tag: v0.0.101~3^2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=d718822874160cf4bc67455b1821cfee44ec9f3d;p=rust-lightning Make `ChainMonitor::get_claimable_balances` take a slice of refs For the same reason as `get_route`, a slice of objects isn't practical to map to bindings - the objects in the bindings space are structs with a pointer and some additional metadata. Thus, to create a slice of them, we'd need to take ownership of the objects behind the pointer, place them into a slace, and then restore them to the pointer. This would be a lot of memory copying and marshalling, not to mention wouldn't be thread-safe, which the same function otherwise would be if we used a slice of references instead of a slice of objects. --- diff --git a/lightning/src/chain/chainmonitor.rs b/lightning/src/chain/chainmonitor.rs index 101ad6652..0d3f87645 100644 --- a/lightning/src/chain/chainmonitor.rs +++ b/lightning/src/chain/chainmonitor.rs @@ -150,7 +150,7 @@ where C::Target: chain::Filter, /// /// See [`ChannelMonitor::get_claimable_balances`] for more details on the exact criteria for /// inclusion in the return value. - pub fn get_claimable_balances(&self, ignored_channels: &[ChannelDetails]) -> Vec { + pub fn get_claimable_balances(&self, ignored_channels: &[&ChannelDetails]) -> Vec { let mut ret = Vec::new(); let monitors = self.monitors.read().unwrap(); for (_, monitor) in monitors.iter().filter(|(funding_outpoint, _)| {