fix deadlock on starting discovery with custom AdvertiseAddr (#1363)
This commit is contained in:
parent
0e0c3cd859
commit
838acce91f
|
@ -215,7 +215,8 @@ func (n *StatusNode) discoverNode() (*enode.Node, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
discNode := n.gethNode.Server().Self()
|
||||
server := n.gethNode.Server()
|
||||
discNode := server.Self()
|
||||
|
||||
if n.config.AdvertiseAddr == "" {
|
||||
return discNode, nil
|
||||
|
@ -225,7 +226,7 @@ func (n *StatusNode) discoverNode() (*enode.Node, error) {
|
|||
|
||||
r := discNode.Record()
|
||||
r.Set(enr.IP(net.ParseIP(n.config.AdvertiseAddr)))
|
||||
if err := enode.SignV4(r, n.Server().PrivateKey); err != nil {
|
||||
if err := enode.SignV4(r, server.PrivateKey); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return enode.New(enode.ValidSchemes[r.IdentityScheme()], r)
|
||||
|
|
|
@ -277,6 +277,8 @@ func TestStatusNodeRendezvousDiscovery(t *testing.T) {
|
|||
// not necessarily with id, just valid multiaddr
|
||||
RendezvousNodes: []string{"/ip4/127.0.0.1/tcp/34012", "/ip4/127.0.0.1/tcp/34011"},
|
||||
},
|
||||
// use custom address to test the all possibilities
|
||||
AdvertiseAddr: "127.0.0.1",
|
||||
}
|
||||
n := New()
|
||||
require.NoError(t, n.Start(&config))
|
||||
|
@ -285,6 +287,28 @@ func TestStatusNodeRendezvousDiscovery(t *testing.T) {
|
|||
require.IsType(t, &discovery.Rendezvous{}, n.discovery)
|
||||
}
|
||||
|
||||
func TestStatusNodeStartDiscoveryManual(t *testing.T) {
|
||||
config := params.NodeConfig{
|
||||
Rendezvous: true,
|
||||
NoDiscovery: true,
|
||||
ClusterConfig: params.ClusterConfig{
|
||||
Enabled: true,
|
||||
// not necessarily with id, just valid multiaddr
|
||||
RendezvousNodes: []string{"/ip4/127.0.0.1/tcp/34012", "/ip4/127.0.0.1/tcp/34011"},
|
||||
},
|
||||
// use custom address to test the all possibilities
|
||||
AdvertiseAddr: "127.0.0.1",
|
||||
}
|
||||
n := New()
|
||||
require.NoError(t, n.StartWithOptions(&config, StartOptions{}))
|
||||
require.Nil(t, n.discovery)
|
||||
// start discovery manually
|
||||
require.NoError(t, n.StartDiscovery())
|
||||
require.NotNil(t, n.discovery)
|
||||
require.True(t, n.discovery.Running())
|
||||
require.IsType(t, &discovery.Rendezvous{}, n.discovery)
|
||||
}
|
||||
|
||||
func TestStatusNodeDiscoverNode(t *testing.T) {
|
||||
config := params.NodeConfig{
|
||||
NoDiscovery: true,
|
||||
|
|
Loading…
Reference in New Issue