Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client/eth/rpc: fix HTTP provider panic #2252

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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