mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-25 07:26:48 +00:00
Bitfinex: Fix websocket panic when seqNo is not sent (#1356)
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -14,6 +14,7 @@ var (
|
||||
errSetCannotBeEmpty = errors.New("set cannot be empty")
|
||||
errSubNotFound = errors.New("could not find matching subscription")
|
||||
errTypeAssert = errors.New("type assertion failed")
|
||||
errNoSeqNo = errors.New("no sequence number")
|
||||
)
|
||||
|
||||
// AccountV2Data stores account v2 data
|
||||
|
||||
@@ -499,7 +499,9 @@ func (b *Bitfinex) handleWSChecksum(chanID int, d []interface{}) error {
|
||||
} else { //nolint:revive // using lexical variable requires else statement
|
||||
token = int(f)
|
||||
}
|
||||
|
||||
if len(d) < 4 {
|
||||
return errNoSeqNo
|
||||
}
|
||||
var seqNo int64
|
||||
if f, ok := d[3].(float64); !ok {
|
||||
return common.GetTypeAssertError("float64", d[3], "seqNo")
|
||||
@@ -525,12 +527,13 @@ func (b *Bitfinex) handleWSBookUpdate(c *stream.ChannelSubscription, chanID int,
|
||||
if len(obSnapBundle) == 0 {
|
||||
return errors.New("no data within orderbook snapshot")
|
||||
}
|
||||
|
||||
if len(d) < 3 {
|
||||
return errNoSeqNo
|
||||
}
|
||||
sequenceNo, ok := d[2].(float64)
|
||||
if !ok {
|
||||
return errors.New("type assertion failure")
|
||||
}
|
||||
|
||||
var fundingRate bool
|
||||
switch id := obSnapBundle[0].(type) {
|
||||
case []interface{}:
|
||||
|
||||
Reference in New Issue
Block a user