diff --git a/.gitignore b/.gitignore index 36cb694de..ab1320464 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,5 @@ _trial_temp/ /tests/integration/blockchain/files /tests/.coverage.* -/lbry/wallet/bin \ No newline at end of file +/lbry/blockchain/bin +/lbry/wallet/bin diff --git a/lbry/blockchain/__init__.py b/lbry/blockchain/__init__.py new file mode 100644 index 000000000..6c1cc0ec5 --- /dev/null +++ b/lbry/blockchain/__init__.py @@ -0,0 +1,2 @@ +from .sync import BlockSync +from .lbrycrd import Lbrycrd \ No newline at end of file diff --git a/lbry/blockchain/block.py b/lbry/blockchain/block.py new file mode 100644 index 000000000..150cb6e14 --- /dev/null +++ b/lbry/blockchain/block.py @@ -0,0 +1,47 @@ +import struct +from lbry.crypto.hash import double_sha256 +from lbry.wallet.transaction import Transaction +from lbry.wallet.bcd_data_stream import BCDataStream + + +ZERO_BLOCK = bytes((0,)*32) + + +class Block: + + __slots__ = ( + 'version', 'block_hash', 'prev_block_hash', + 'merkle_root', 'claim_trie_root', 'timestamp', + 'bits', 'nonce', 'txs' + ) + + def __init__(self, stream): + stream.read_uint32() # block size + header = stream.data.read(112) + version, = struct.unpack('