Remove block for negative checksums (and replace crcmod with native zlip module).

This commit is contained in:
Davide Casale
2023-07-28 17:53:39 +02:00
parent 875d1d61e0
commit f6c49f677d
3 changed files with 12 additions and 13 deletions

View File

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

View File

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

View File

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