feat: change state network dep

This commit is contained in:
fearlessfe 2024-09-16 22:09:23 +08:00 committed by Chen Kai
parent f00c767e54
commit df86d197c1
3 changed files with 5 additions and 6 deletions

View file

@ -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()
}

View file

@ -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,

View file

@ -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)
}