[#179] resolver: Use Client with WSClient in NNS

WebSocket client (`WSClient` type) from Neo Go library shows better
performance than HTTP one (`Client` type).

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2022-04-12 11:19:32 +03:00 committed by LeL
parent 146fc4f07a
commit 75a5b6588d

View file

@ -29,16 +29,16 @@ type NNS struct {
}
// client is a core implementation of internal NNS.neoClient which is used by NNS.Dial.
type client neoclient.Client
type client neoclient.WSClient
func (x *client) invoke(contract util.Uint160, method string, prm []smartcontract.Parameter) (*result.Invoke, error) {
return (*neoclient.Client)(x).InvokeFunction(contract, method, prm, nil)
return (*neoclient.WSClient)(x).InvokeFunction(contract, method, prm, nil)
}
// Dial connects to the address of the NNS server. If fails, the instance
// SHOULD NOT be used.
func (n *NNS) Dial(address string) error {
cli, err := neoclient.New(context.Background(), address, neoclient.Options{})
cli, err := neoclient.NewWS(context.Background(), address, neoclient.Options{})
if err != nil {
return fmt.Errorf("create neo client: %w", err)
}