lightningdevkit / lightning-liquidity

Other
27 stars 17 forks source link

Drop `APeerManager` dependency and replace with `process_msgs_callback` #73

Closed tnull closed 8 months ago

tnull commented 9 months ago

Fixes #72.

Previously, LiquidityManager (or at least its internal message queue) was holding a reference to PeerManager/impl APeerManager in order to be able to trigger message processing after new messages were enqueued.

However, this had two major drawbacks: firstly, it introduced an ugly (and hard to resolve) cycle in the type definitions as PeerManager depends on CustomMessageHandler, which in this case is LiquidityManager, itself depending on said PeerManager reference. Secondly, it introduced the complex PeerManager LDK object to the LSPS implementation which is otherwise not that depedent on LDK's internal types.

To resolve these issues, we heere replace the dependency on PeerManager/impl APeerManager with a simple generic callback that will be called every time new messages are enqueued.

Looking for feedback here. As a second step we could consider dropping the MessageQueue trait which was introduced as part of the prior refactor that moved the APeerManager bound from each individual message handler to the DefaultMessageQueue.