merkleblockの最初の6つ(version, previous block, merkle root, timestamp, bit, nonce)はブロックヘッダーと全く同じ
number of total transaction, number of hashes, hashes, flag bitsが異なる
merkleblockのparse
@classmethod
def parse(cls, s):
version = little_endian_to_int(s.read(4))
prev_block = s.read(32)[::-1]
merkle_root = s.read(32)[::-1]
timestamp = little_endian_to_int(s.read(4))
bits = s.read(4)
nonce = s.read(4)
total = little_endian_to_int(s.read(4))
num_hashes = read_varint(s)
hashes = []
for _ in range(num_hashes):
hashes.append(s.read(32)[::-1])
flags_length = read_varint(s)
flags = s.read(flag_length)
return cls(version, prev_block, merkle_root, timestamp, bits, nonce, total, hashes, flags)
### フラグビットとハッシュの使用
1. ノード値がハッシュフィールドで指定されている場合、フラグビットは0
2. ノードが内部ノーで、軽量クイライアンとによって計算されている場合、フラッグビットは1
3. ノードがリーフノードで、対象のトランザクションである場合、フラグは1でノード値もハッシュフィールドで指定される