mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-18 14:24:21 +01:00
Remove block for negative checksums (and replace crcmod with native zlip module).
This commit is contained in:
@@ -150,6 +150,5 @@ class PublicChannelsHandler:
|
||||
serializers.Liquidation.parse(*stream[0][0]))
|
||||
|
||||
def __checksum_handler(self, subscription: "Book", value: int):
|
||||
if not value < 0:
|
||||
return self.__event_emitter.emit( \
|
||||
"checksum", subscription, value)
|
||||
return self.__event_emitter.emit( \
|
||||
"checksum", subscription, value & 0xFFFFFFFF)
|
||||
|
||||
@@ -4,7 +4,7 @@ from collections import OrderedDict
|
||||
|
||||
from typing import List, Dict
|
||||
|
||||
import crcmod
|
||||
import zlib
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
|
||||
@@ -58,13 +58,13 @@ class OrderBook:
|
||||
values.extend([ bid[0], bid[2] ])
|
||||
values.extend([ ask[0], ask[2] ])
|
||||
|
||||
local = ":".join(str(value) for value in values).encode("UTF-8")
|
||||
local = ":".join(str(value) for value in values)
|
||||
|
||||
crc32 = crcmod.mkCrcFun(0x104C11DB7, initCrc=0, xorOut=0xFFFFFFFF)
|
||||
crc32 = zlib.crc32(local.encode("UTF-8"))
|
||||
|
||||
return crc32(local) == checksum
|
||||
return crc32 == checksum
|
||||
|
||||
SYMBOLS = [ "tBTCUSD", "tLTCUSD", "tLTCBTC", "tETHUSD", "tETHBTC" ]
|
||||
SYMBOLS = [ "tLTCBTC", "tETHUSD", "tETHBTC" ]
|
||||
|
||||
order_book = OrderBook(symbols=SYMBOLS)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ from collections import OrderedDict
|
||||
|
||||
from typing import List, Dict
|
||||
|
||||
import crcmod
|
||||
import zlib
|
||||
|
||||
from bfxapi import Client, PUB_WSS_HOST
|
||||
|
||||
@@ -58,13 +58,13 @@ class RawOrderBook:
|
||||
values.extend([ bid[0], bid[2] ])
|
||||
values.extend([ ask[0], ask[2] ])
|
||||
|
||||
local = ":".join(str(value) for value in values).encode("UTF-8")
|
||||
local = ":".join(str(value) for value in values)
|
||||
|
||||
crc32 = crcmod.mkCrcFun(0x104C11DB7, initCrc=0, xorOut=0xFFFFFFFF)
|
||||
crc32 = zlib.crc32(local.encode("UTF-8"))
|
||||
|
||||
return crc32(local) == checksum
|
||||
return crc32 == checksum
|
||||
|
||||
SYMBOLS = [ "tBTCUSD", "tLTCUSD", "tLTCBTC", "tETHUSD", "tETHBTC" ]
|
||||
SYMBOLS = [ "tLTCBTC", "tETHUSD", "tETHBTC" ]
|
||||
|
||||
raw_order_book = RawOrderBook(symbols=SYMBOLS)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user