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 efb36de commit e033149
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/libp2p/go-libp2p-kad-dht v0.24.2
github.com/tidwall/buntdb v1.2.10
github.com/urfave/cli/v2 v2.25.3
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63

)

Expand Down Expand Up @@ -145,6 +144,7 @@ require (
go.uber.org/fx v1.20.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
Expand Down
18 changes: 17 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 @@ -252,7 +253,22 @@ func main() {
if err != nil {
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)
}
}()

var cert tls.Certificate
if tlsCertFilepath != "" && tlsKeyFilepath != "" {
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 e033149

Please sign in to comment.