rpc/client: correct ID unmarshaling in wsclient

We always use uint64 IDs in the client, so we should parse them as such and
not just ints that then are casted to uint64.
This commit is contained in:
Roman Khimov 2022-07-07 17:45:33 +03:00
parent adab83496c
commit 9aecfb7c94

View file

@ -205,12 +205,12 @@ readloop:
}
c.Notifications <- Notification{event, val}
} else if rr.ID != nil && (rr.Error != nil || rr.Result != nil) {
id, err := strconv.Atoi(string(rr.ID))
id, err := strconv.ParseUint(string(rr.ID), 10, 64)
if err != nil {
connCloseErr = fmt.Errorf("failed to retrieve response ID from string %s: %w", string(rr.ID), err)
break readloop // Malformed response (invalid response ID).
}
ch := c.getResponseChannel(uint64(id))
ch := c.getResponseChannel(id)
if ch == nil {
connCloseErr = fmt.Errorf("unknown response channel for response %d", id)
break readloop // Unknown response (unexpected response ID).