Skip to content

Commit e6024ab

Browse files
authored
Merge pull request #1349 from TheBlueMatt/2022-03-listen-send-sync
Require `chain::Listen` impls in block sync be `Send + Sync`
2 parents 2bba1d4 + 84a08db commit e6024ab

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lightning-block-sync/src/init.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ BlockSourceResult<ValidatedBlockHeader> {
121121
/// [`SpvClient`]: crate::SpvClient
122122
/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
123123
/// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor
124-
pub async fn synchronize_listeners<B: BlockSource, C: Cache>(
124+
pub async fn synchronize_listeners<'a, B: BlockSource, C: Cache, L: chain::Listen + ?Sized>(
125125
block_source: &mut B,
126126
network: Network,
127127
header_cache: &mut C,
128-
mut chain_listeners: Vec<(BlockHash, &dyn chain::Listen)>,
128+
mut chain_listeners: Vec<(BlockHash, &'a L)>,
129129
) -> BlockSourceResult<ValidatedBlockHeader> {
130130
let best_header = validate_best_block_header(block_source).await?;
131131

@@ -198,9 +198,9 @@ impl<'a, C: Cache> Cache for ReadOnlyCache<'a, C> {
198198
}
199199

200200
/// Wrapper for supporting dynamically sized chain listeners.
201-
struct DynamicChainListener<'a>(&'a dyn chain::Listen);
201+
struct DynamicChainListener<'a, L: chain::Listen + ?Sized>(&'a L);
202202

203-
impl<'a> chain::Listen for DynamicChainListener<'a> {
203+
impl<'a, L: chain::Listen + ?Sized> chain::Listen for DynamicChainListener<'a, L> {
204204
fn block_connected(&self, _block: &Block, _height: u32) {
205205
unreachable!()
206206
}
@@ -211,9 +211,9 @@ impl<'a> chain::Listen for DynamicChainListener<'a> {
211211
}
212212

213213
/// A set of dynamically sized chain listeners, each paired with a starting block height.
214-
struct ChainListenerSet<'a>(Vec<(u32, &'a dyn chain::Listen)>);
214+
struct ChainListenerSet<'a, L: chain::Listen + ?Sized>(Vec<(u32, &'a L)>);
215215

216-
impl<'a> chain::Listen for ChainListenerSet<'a> {
216+
impl<'a, L: chain::Listen + ?Sized> chain::Listen for ChainListenerSet<'a, L> {
217217
fn block_connected(&self, block: &Block, height: u32) {
218218
for (starting_height, chain_listener) in self.0.iter() {
219219
if height > *starting_height {

0 commit comments

Comments
 (0)