lightningdevkit / lightning-liquidity

Other
27 stars 17 forks source link

`enqueue` is a mutable behavior but with a immutable function type #76

Closed yanganto closed 10 months ago

yanganto commented 10 months ago

The enqueue function of the public trait MessageQueue is immutable. In general, we do mutate some data from the Queue, when we put things into it.

yanganto commented 10 months ago

It may be an intentional design to keep the mutability inside. The thing I should use is TestMessageQueue, but the test queue is private, and the trait is public.

tnull commented 10 months ago

It may be an intentional design to keep the mutability inside. The thing I should use is TestMessageQueue, but the test queue is private, and the trait is public.

It is in fact intentional. As noted in #73, the trait was introduced essentially as an intermediate step when moving the PeerManager dependency from all of the message handlers to just one place: the message queue. However, users probably wouldn't benefit from using a custom MessageQueue implementation, which is why we're considering to just remove it again and just use DefaultMessageQueue everywhere.

yanganto commented 10 months ago

Got it