imports, whitespace
This commit is contained in:
@@ -46,9 +46,11 @@ MAX_TARGET = 0x00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||
class MissingHeader(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class InvalidHeader(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def serialize_header(header_dict: dict) -> bytes:
|
||||
s = (
|
||||
int.to_bytes(header_dict['version'], length=4, byteorder="little", signed=False)
|
||||
@@ -59,6 +61,7 @@ def serialize_header(header_dict: dict) -> bytes:
|
||||
+ int.to_bytes(int(header_dict['nonce']), length=4, byteorder="little", signed=False))
|
||||
return s
|
||||
|
||||
|
||||
def deserialize_header(s: bytes, height: int) -> dict:
|
||||
if not s:
|
||||
raise InvalidHeader('Invalid header: {}'.format(s))
|
||||
@@ -74,6 +77,7 @@ def deserialize_header(s: bytes, height: int) -> dict:
|
||||
h['block_height'] = height
|
||||
return h
|
||||
|
||||
|
||||
def hash_header(header: dict) -> str:
|
||||
if header is None:
|
||||
return '0' * 64
|
||||
@@ -161,6 +165,7 @@ def read_blockchains(config: 'SimpleConfig'):
|
||||
def get_best_chain() -> 'Blockchain':
|
||||
return blockchains[constants.net.GENESIS]
|
||||
|
||||
|
||||
# block hash -> chain work; up to and including that block
|
||||
_CHAINWORK_CACHE = {
|
||||
"0000000000000000000000000000000000000000000000000000000000000000": 0, # virtual block at height -1
|
||||
|
||||
Reference in New Issue
Block a user