[#179] resolver: Support `wss` connection scheme in `NNS.Dial`

WebSocket Secure scheme should also lead to using `neoclient.WSClient`
by `NNS`.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
remotes/fyrchik/split-info-format
Leonard Lyubich 2022-04-13 10:23:06 +03:00 committed by LeL
parent d51d18d5f3
commit 9c502a9cae
1 changed files with 3 additions and 2 deletions

View File

@ -54,7 +54,8 @@ func (x *neoWebSocket) call(contract util.Uint160, method string, prm []smartcon
// Dial connects to the address of the NNS server. If fails, the instance
// MUST NOT be used.
//
// If URL address scheme is 'ws', then WebSocket protocol is used, otherwise HTTP.
// If URL address scheme is 'ws' or 'wss', then WebSocket protocol is used,
// otherwise HTTP.
func (n *NNS) Dial(address string) error {
// multiSchemeClient unites neoClient and common interface of
// neoclient.Client and neoclient.WSClient. Interface is anonymous
@ -69,7 +70,7 @@ func (n *NNS) Dial(address string) error {
}
uri, err := url.Parse(address)
if err == nil && uri.Scheme == "ws" {
if err == nil && (uri.Scheme == "ws" || uri.Scheme == "wss") {
cWebSocket, err := neoclient.NewWS(context.Background(), address, neoclient.Options{})
if err != nil {
return fmt.Errorf("create Neo WebSocket client: %w", err)