diff --git a/cmd/shisui/main.go b/cmd/shisui/main.go index b2f033f6170f..16243775bd1c 100644 --- a/cmd/shisui/main.go +++ b/cmd/shisui/main.go @@ -290,7 +290,8 @@ func initState(config Config, server *rpc.Server, conn discover.UDPConn, localNo if err != nil { return err } - historyNetwork := state.NewStateNetwork(protocol, server) + client := rpc.DialInProc(server) + historyNetwork := state.NewStateNetwork(protocol, client) return historyNetwork.Start() } diff --git a/portalnetwork/state/network.go b/portalnetwork/state/network.go index 3a497fff9b68..193be375bff6 100644 --- a/portalnetwork/state/network.go +++ b/portalnetwork/state/network.go @@ -29,11 +29,8 @@ type StateNetwork struct { client *rpc.Client } -func NewStateNetwork(portalProtocol *discover.PortalProtocol, rpcServer *rpc.Server) *StateNetwork { +func NewStateNetwork(portalProtocol *discover.PortalProtocol, client *rpc.Client) *StateNetwork { ctx, cancel := context.WithCancel(context.Background()) - - client := rpc.DialInProc(rpcServer) - return &StateNetwork{ portalProtocol: portalProtocol, closeCtx: ctx, diff --git a/portalnetwork/state/network_test.go b/portalnetwork/state/network_test.go index 3ec2e54fda55..1aec2e5c13b3 100644 --- a/portalnetwork/state/network_test.go +++ b/portalnetwork/state/network_test.go @@ -65,7 +65,8 @@ func TestValidateAccountTrieNode(t *testing.T) { header: tt.BlockHeader, } server.RegisterName("portal", api) - bn := NewStateNetwork(nil, server) + client := rpc.DialInProc(server) + bn := NewStateNetwork(nil, client) err = bn.validateContent(hexutil.MustDecode(tt.ContentKey), hexutil.MustDecode(tt.ContentValueOffer)) require.NoError(t, err) }