Make the `P2PGossipSync` `UtxoLookup` exchangable without &mut self
authorMatt Corallo <git@bluematt.me>
Sun, 30 Apr 2023 00:48:57 +0000 (00:48 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 23 Aug 2023 21:48:03 +0000 (21:48 +0000)
commitb315856e686dd9e72a7ff93616f314ca6a037b56
tree466d9dbaa97302d047934799ae4aa809ac5fc8c7
parent01857b51a1e798ef344af845351b1c05c1c8a677
Make the `P2PGossipSync` `UtxoLookup` exchangable without &mut self

Because a `UtxoLookup` implementation is likely to need a reference
to the `PeerManager` which contains a reference to the
`P2PGossipSync`, it is likely to be impossible to get a mutable
reference to the `P2PGossipSync` by the time we want to add a
`UtxoLookup` without a ton of boilerplate and trait wrapping.

Instead, we simply place the `UtxoLookup` in a `RwLock`, allowing
us to modify it without a mutable self reference.

The lifetime bounds updates in tests required in this commit are
entirely unclear to me, but do allow tests to continue building, so
somehow make rustc happier.
lightning/src/ln/functional_test_utils.rs
lightning/src/routing/gossip.rs
lightning/src/routing/router.rs