So I'm trying to read the block files with Python.
From this link, What are the keys used in the blockchain levelDB (ie what are the key:value pairs)?, it tells you how to access the files with leveldb. So I wrote a class to read in the meta data.
class ReadBytes:
def __init__(self, bytes):
self.posistion = 0
self.bytes = bytes
def get_int(self, byte_count):
self.posistion += byte_count
return decode(self.bytes[self.posistion - byte_count:self.posistion][::-1], 256)
def get_var_int(self):
self.posistion += 1
value = byte_to_int(self.bytes[self.posistion - 1])
if value < 253:
return value
return self.get_int(pow(2, value - 252))
But from this link, https://github.com/bitcoin/bitcoin/blob/master/src/chain.h#L364, It turns out there is this thing call VarIntMode::NONNEGATIVE_SIGNED
that is tripping me up. I can read regular var int with my Python class, but how do I read the non-negative signed ones in Python?