Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Drop APeerManager dependency and replace with process_msgs_callback #73

Merged

Conversation

tnull
Copy link
Collaborator

@tnull tnull commented Dec 20, 2023

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.

@tnull tnull force-pushed the 2023-12-drop-apeermanager-dependency branch 5 times, most recently from dc3e5f4 to 8c5d552 Compare December 20, 2023 13:52
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.
@tnull tnull merged commit 2a9c244 into lightningdevkit:main Jan 2, 2024
3 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to avoid cycle trait dependency in LiquidityManager?
2 participants