Skip to content

Commit

Permalink
feat: change state network dep
Browse files Browse the repository at this point in the history
  • Loading branch information
fearlessfe authored and GrapeBaBa committed Sep 17, 2024
1 parent f00c767 commit df86d19
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion cmd/shisui/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down
5 changes: 1 addition & 4 deletions portalnetwork/state/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion portalnetwork/state/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit df86d19

Please sign in to comment.