decred / dcrlnd

Decred Lightning Network Daemon ⚡️
MIT License
36 stars 24 forks source link

channeldb: add inflight payments index #186

Closed matheusd closed 1 year ago

matheusd commented 1 year ago

This index is meant to improve startup time of dcrlnd installs by removing the need to iterate through the entire set of payments in the db before continuing with channel startup.

A new index is added to the channeldb, using the payment sequence number as key to mark a given payment as still in-flight.

Once the payment is settled or fails, the entry is removed from the index.

While the code is designed to be able to work both with and without the index, no option to conditionally enable the index is exposed by the package or to the user, thus the index is always used. In the future, if this index is deemed as slowling down usage (as opposed to speeding up startup), then an option may be added to the node.

Unit tests are included to test fetching of in-flight payments both with and without the index.

Before actually adding the index, a few upstream lnd PRs are brought in to make future work easier.