Bitfinex: Fix websocket panic when seqNo is not sent (#1356)

This commit is contained in:
Bea
2023-10-09 13:22:06 +07:00
committed by GitHub
parent cd293c43b7
commit 2799f40401
3 changed files with 11 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

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

View File

@@ -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{}: