lightninglabs / lightninglabs/aperture
aperture: add support for async invoice loading on start up
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 268
- Forks
- 78
- Avg merge
- 22h 25m
- Merged PRs (30d)
- 1
Description
Today on start up, we'll block to read out _all_ the invoices from the backing node (`LndChallenger.Start`): https://github.com/lightninglabs/aperture/blob/9fd44c9e8f23fcca37b0111398f7990bbd12ddf7/challenger/lnd.go#L81-L109
If the node is very old, or has a ton of invoices, this can take quite some time, potentially 10 minutes+.
We should modify this logic to allow the service to start up while we continue to load the invoices in the background using a goroutine.
## Steps To Completion
Only when we need to actually access the produced `invoiceStates` map should we block until the map has been fully populated. We'll likely want to create a new concurrent safe wrapper map that's able to signal any waiters once new elements have been added (see the condition variable usage), with the added ability to _block_ while the map is being populated.
With that in place, we'll `LndChallenger.VerifyInvoiceStatus` shouldn't need to change too much. It already uses the condition variable to be notified when an entry it added to the map. It just needs to be updated to use the new abstractions mentioned above.
As the start up might take some time, we'll want to update this section to account for a longer timeout:
https://github.com/lightninglabs/aperture/blob/9fd44c9e8f23fcca37b0111398f7990bbd12ddf7/challenger/lnd.go#L319-L337
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in challenger/lnd.go at LndChallenger.Start and review the condition-variable usage around invoiceStates and VerifyInvoiceStatus. The service should start while invoice loading continues in a goroutine, while accesses block until the map is populated; also inspect the timeout section around lines 319-337 and update it for the longer startup work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100