Skip to content

Commit

Permalink
Fix payments manager initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed Oct 16, 2023
1 parent facb6ec commit a67a08d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
17 changes: 16 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"os/signal"
"strings"
"sync"
"syscall"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -253,7 +254,21 @@ func main() {
return err
}

paymentsManager := paymentsmanager.PaymentsManager{}
paymentsManager, err := paymentsmanager.NewPaymentsManager(node)
if err != nil {
return err
}

wg := new(sync.WaitGroup)
defer wg.Wait()

paymentsManager.Start(wg)
defer func() {
err := paymentsManager.Stop()
if err != nil {
panic(err)
}
}()

cert, err := tls.LoadX509KeyPair(tlsCertFilepath, tlsKeyFilepath)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion paymentsmanager/http_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"encoding/json"
"errors"
"io"
"log/slog"
"math/big"
"net/http"
"regexp"
"strings"

"github.com/ethereum/go-ethereum/common"
"github.com/statechannels/go-nitro/crypto"
"golang.org/x/exp/slog"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions paymentsmanager/payments_manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package paymentsmanager

import (
"log/slog"
"math/big"
"sync"
"time"
Expand All @@ -10,7 +11,6 @@ import (
"github.com/statechannels/go-nitro/node"
"github.com/statechannels/go-nitro/payments"
"github.com/statechannels/go-nitro/types"
"golang.org/x/exp/slog"
)

const (
Expand Down Expand Up @@ -167,7 +167,7 @@ func (pm *PaymentsManager) run() {

vouchersMap.Add(voucherHash.Hex(), InFlightVoucher{voucher: voucher, amount: paymentAmount})
case <-pm.quitChan:
slog.Info("stopping voucher subscription loop")
slog.Info("stopping voucher subscription loop...")
return
}
}
Expand Down

0 comments on commit a67a08d

Please sign in to comment.