Skip to content

Commit

Permalink
client/eth/rpc: fix HTTP provider panic
Browse files Browse the repository at this point in the history
  • Loading branch information
norwnd authored and chappjc committed Mar 25, 2023
1 parent 4519576 commit f303e5f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions client/asset/eth/multirpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ func connectProviders(ctx context.Context, endpoints []string, log dex.Logger, c
var ec *ethclient.Client
var rpcClient *rpc.Client
var sub ethereum.Subscription
var wsSubscribed bool
var h chan *types.Header
host := providerIPC
if !strings.HasSuffix(endpoint, ".ipc") {
Expand Down Expand Up @@ -466,6 +467,8 @@ func connectProviders(ctx context.Context, endpoints []string, log dex.Logger, c
} else {
log.Errorf("Connected to websocket, but headers subscription not supported. Attempting HTTP fallback")
}
} else {
wsSubscribed = true
}
} else {
if replaced {
Expand Down Expand Up @@ -512,7 +515,7 @@ func connectProviders(ctx context.Context, endpoints []string, log dex.Logger, c
p := &provider{
host: host,
endpointAddr: endpoint,
ws: sub != nil,
ws: wsSubscribed,
net: net,
ec: &combinedRPCClient{
Client: ec,
Expand All @@ -525,7 +528,7 @@ func connectProviders(ctx context.Context, endpoints []string, log dex.Logger, c
var wg sync.WaitGroup

// Start websocket listen loop.
if sub != nil {
if wsSubscribed {
wg.Add(1)
go func() {
p.subscribeHeaders(ctx, sub, h, log)
Expand Down

0 comments on commit f303e5f

Please sign in to comment.