-
Notifications
You must be signed in to change notification settings - Fork 44
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
RPC and WS endpoints share the same port #187
Changes from all commits
4b7c101
7fed2b7
513e359
b71a89e
1c72189
8fc945b
c85fe15
50b9fb4
0cb5c81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ func TestEtherAmount(t *testing.T) { | |
|
||
func TestToDecimals(t *testing.T) { | ||
val := NewEtherAmount(123456) | ||
require.Equal(t, fmt.Sprint(val.ToDecimals(5)), "1.23456") | ||
require.Equal(t, "1.23456", FmtFloat(val.ToDecimals(5))) | ||
val = NewEtherAmount(1234567890) | ||
require.Equal(t, fmt.Sprint(val.ToDecimals(6)), "1234.56789") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The expected/actual values here were reversed and it seemed like as good a place as any to use the |
||
require.Equal(t, "1234.56789", FmtFloat(val.ToDecimals(6))) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,19 @@ func newDiscovery(ctx context.Context, h libp2phost.Host, bnsFunc func() []peer. | |
dual.DHTOption(kaddht.Mode(kaddht.ModeAutoServer)), | ||
} | ||
|
||
// | ||
// There is libp2p bug when calling `dual.New` with a cancelled context creating a panic, | ||
// so we added the extra guard below: | ||
// Panic: https://github.com/jbenet/goprocess/blob/v0.1.4/impl-mutex.go#L99 | ||
// Caller: https://github.com/libp2p/go-libp2p-kad-dht/blob/v0.17.0/dht.go#L222 | ||
// | ||
select { | ||
case <-ctx.Done(): | ||
return nil, ctx.Err() | ||
default: | ||
// not cancelled, continue on | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was mildly painful. We were introducing a context cancel in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good to know, also yeah that's painful |
||
|
||
dht, err := dual.New(ctx, h, dhtOpts...) | ||
if err != nil { | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start()
now blocks and it internally uses the context that was passed torpcCfg
.