aperture+challenger: add error channel to challenger

To make sure we can capture errors in the challenger's invoice
subscription, we hand the main error channel to the challenger so it can
report back errors on it.
This commit is contained in:
Oliver Gugger
2020-09-23 10:07:42 +02:00
parent 5237b07a6e
commit e1269a7f86
3 changed files with 23 additions and 8 deletions

View File

@@ -49,6 +49,8 @@ type LndChallenger struct {
invoicesCancel func()
invoicesCond *sync.Cond
errChan chan<- error
quit chan struct{}
wg sync.WaitGroup
}
@@ -66,8 +68,8 @@ const (
// NewLndChallenger creates a new challenger that uses the given connection
// details to connect to an lnd backend to create payment challenges.
func NewLndChallenger(cfg *authConfig, genInvoiceReq InvoiceRequestGenerator) (
*LndChallenger, error) {
func NewLndChallenger(cfg *authConfig, genInvoiceReq InvoiceRequestGenerator,
errChan chan<- error) (*LndChallenger, error) {
if genInvoiceReq == nil {
return nil, fmt.Errorf("genInvoiceReq cannot be nil")
@@ -89,6 +91,7 @@ func NewLndChallenger(cfg *authConfig, genInvoiceReq InvoiceRequestGenerator) (
invoicesMtx: invoicesMtx,
invoicesCond: sync.NewCond(invoicesMtx),
quit: make(chan struct{}),
errChan: errChan,
}, nil
}