|
|
@ -270,8 +270,7 @@ func (b *Batcher) handleSweep(ctx context.Context, sweep *sweep,
|
|
|
|
// can't attach its notifier to the batch as that is no longer running.
|
|
|
|
// can't attach its notifier to the batch as that is no longer running.
|
|
|
|
// Instead we directly detect and return the spend here.
|
|
|
|
// Instead we directly detect and return the spend here.
|
|
|
|
if completed && *notifier != (SpendNotifier{}) {
|
|
|
|
if completed && *notifier != (SpendNotifier{}) {
|
|
|
|
go b.monitorSpendAndNotify(ctx, sweep, notifier)
|
|
|
|
return b.monitorSpendAndNotify(ctx, sweep, notifier)
|
|
|
|
return nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sweep.notifier = notifier
|
|
|
|
sweep.notifier = notifier
|
|
|
@ -509,10 +508,7 @@ func (b *Batcher) FetchUnconfirmedBatches(ctx context.Context) ([]*batch,
|
|
|
|
// monitorSpendAndNotify monitors the spend of a specific outpoint and writes
|
|
|
|
// monitorSpendAndNotify monitors the spend of a specific outpoint and writes
|
|
|
|
// the response back to the response channel.
|
|
|
|
// the response back to the response channel.
|
|
|
|
func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
|
|
|
|
func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
|
|
|
|
notifier *SpendNotifier) {
|
|
|
|
notifier *SpendNotifier) error {
|
|
|
|
|
|
|
|
|
|
|
|
b.wg.Add(1)
|
|
|
|
|
|
|
|
defer b.wg.Done()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
spendCtx, cancel := context.WithCancel(ctx)
|
|
|
|
spendCtx, cancel := context.WithCancel(ctx)
|
|
|
|
defer cancel()
|
|
|
|
defer cancel()
|
|
|
@ -522,17 +518,14 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
|
|
|
|
sweep.initiationHeight,
|
|
|
|
sweep.initiationHeight,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
select {
|
|
|
|
return err
|
|
|
|
case notifier.SpendErrChan <- err:
|
|
|
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ = b.writeToErrChan(ctx, err)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log.Infof("Batcher monitoring spend for swap %x", sweep.swapHash[:6])
|
|
|
|
b.wg.Add(1)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
defer b.wg.Done()
|
|
|
|
|
|
|
|
log.Infof("Batcher monitoring spend for swap %x",
|
|
|
|
|
|
|
|
sweep.swapHash[:6])
|
|
|
|
|
|
|
|
|
|
|
|
for {
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
select {
|
|
|
@ -560,6 +553,9 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (b *Batcher) writeToErrChan(ctx context.Context, err error) error {
|
|
|
|
func (b *Batcher) writeToErrChan(ctx context.Context, err error) error {
|
|
|
|