MCPcopy
hub / github.com/jimmysong/programmingbitcoin / load_cache

Method load_cache

code-ch08/tx.py:52–62  ·  view source on GitHub ↗
(cls, filename)

Source from the content-addressed store, hash-verified

50
51 @classmethod
52 def load_cache(cls, filename):
53 disk_cache = json.loads(open(filename, 'r').read())
54 for k, raw_hex in disk_cache.items():
55 raw = bytes.fromhex(raw_hex)
56 if raw[4] == 0:
57 raw = raw[:4] + raw[6:]
58 tx = Tx.parse(BytesIO(raw))
59 tx.locktime = little_endian_to_int(raw[-4:])
60 else:
61 tx = Tx.parse(BytesIO(raw))
62 cls.cache[k] = tx
63
64 @classmethod
65 def dump_cache(cls, filename):

Callers 1

setUpClassMethod · 0.45

Calls 3

little_endian_to_intFunction · 0.90
readMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected