utxonursery: test restart behaviour

This commit is contained in:
Joost Jager committed 2018-09-23 15:52:45 -07:00
1 parent 83a5ea0c31
commit 9f6fb1e128
3 files changed
+168 -28

No files matched your search

+18 -5
View File
@@ -181,9 +181,15 @@ type NurseryConfig struct {
// determining outputs in the chain as confirmed.
ConfDepth uint32
// DB provides access to a user's channels, such that they can be marked
// fully closed after incubation has concluded.
DB *channeldb.DB
// FetchClosedChannels provides access to a user's channels, such that
// they can be marked fully closed after incubation has concluded.
FetchClosedChannels func(pendingOnly bool) (
[]*channeldb.ChannelCloseSummary, error)
// FetchClosedChannel provides access to the close summary to extract a
// height hint from.
FetchClosedChannel func(chanID *wire.OutPoint) (
*channeldb.ChannelCloseSummary, error)
// Estimator is used when crafting sweep transactions to estimate the
// necessary fee relative to the expected size of the sweep transaction.
@@ -266,7 +272,7 @@ func (u *utxoNursery) Start() error {
// Load any pending close channels, which represents the super set of
// all channels that may still be incubating.
pendingCloseChans, err := u.cfg.DB.FetchClosedChannels(true)
pendingCloseChans, err := u.cfg.FetchClosedChannels(true)
if err != nil {
newBlockChan.Cancel()
return err
@@ -346,6 +352,13 @@ func (u *utxoNursery) IncubateOutputs(chanPoint wire.OutPoint,
incomingHtlcs []lnwallet.IncomingHtlcResolution,
broadcastHeight uint32) error {
// Add to wait group because nursery might shut down during execution of
// this function. Otherwise it could happen that nursery thinks it is
// shut down, but in this function new goroutines were started and stay
// around.
u.wg.Add(1)
defer u.wg.Done()
numHtlcs := len(incomingHtlcs) + len(outgoingHtlcs)
var (
hasCommit bool
@@ -624,7 +637,7 @@ func (u *utxoNursery) reloadPreschool() error {
chanPoint := kid.OriginChanPoint()
// Load the close summary for this output's channel point.
closeSummary, err := u.cfg.DB.FetchClosedChannel(chanPoint)
closeSummary, err := u.cfg.FetchClosedChannel(chanPoint)
if err == channeldb.ErrClosedChannelNotFound {
// This should never happen since the close summary
// should only be removed after the channel has been