mirror of
https://github.com/callebtc/electronwall.git
synced 2026-02-21 23:24:28 +01:00
cancel context
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
|
||||
func (app *app) dispatchChannelAcceptor(ctx context.Context) {
|
||||
client := app.client
|
||||
|
||||
// wait group for channel acceptor
|
||||
defer ctx.Value(ctxKeyWaitGroup).(*sync.WaitGroup).Done()
|
||||
// get the lnd grpc connection
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/lightningnetwork/lnd/lnrpc"
|
||||
@@ -14,6 +15,8 @@ import (
|
||||
)
|
||||
|
||||
func (app *app) dispatchHTLCAcceptor(ctx context.Context) {
|
||||
// wait group for channel acceptor
|
||||
defer ctx.Value(ctxKeyWaitGroup).(*sync.WaitGroup).Done()
|
||||
conn := app.conn
|
||||
router := routerrpc.NewRouterClient(conn)
|
||||
|
||||
|
||||
5
main.go
5
main.go
@@ -49,6 +49,7 @@ func getClientConnection(ctx context.Context) (*grpc.ClientConn, error) {
|
||||
grpc.WithBlock(),
|
||||
grpc.WithPerRPCCredentials(cred),
|
||||
}
|
||||
log.Infof("Connecting to LND...")
|
||||
conn, err := grpc.DialContext(ctx, Configuration.Host, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -75,12 +76,12 @@ func main() {
|
||||
app.myPubkey, err = app.getMyPubkey(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("Could not get my pubkey: %s", err)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
ctx = context.WithValue(ctx, ctxKeyWaitGroup, &wg)
|
||||
wg.Add(1)
|
||||
wg.Add(2)
|
||||
|
||||
// channel acceptor
|
||||
go app.dispatchChannelAcceptor(ctx)
|
||||
|
||||
Reference in New Issue
Block a user