Description
Today on start up, we'll block to read out all the invoices from the backing node (LndChallenger.Start
):
Lines 81 to 109 in 9fd44c9
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:
Lines 319 to 337 in 9fd44c9