Skip to Content
밑바닥부터 시작하는 비트코인
book

밑바닥부터 시작하는 비트코인

by 류정필, 송재준
November 2019
Beginner to intermediate
408 pages
9h 29m
Korean
Hanbit Media, Inc.
Content preview from 밑바닥부터 시작하는 비트코인
밑바닥부터 시작하는 비트코인
286
그림
11-5
머클증명
11.8.1
머클트리 구조
라이트 노드는 먼저 머클트리의 일반적인 구조를 만듭니다. 머클트리는 단말 노드에서 루트 노
드 방향으로 생성되기 때문에 라이트 노드는 단말 노드의 개수만 알면 머클트리의 구조를 알
수 있습니다. [그림
11
-
5
]에서 머클트리는
16
개의 단말 노드를 가지고 있습니다. 라이트 노드
에서는 일단 다음과 같이
None
값으로 채워진 머클트리를 생성할 수 있습니다.
>>> import math
>>> total = 16
>>> max_depth = math.ceil(math.log(total, 2))
>>> merkle_tree = []
>>> for depth in range(max_depth + 1):
... num_items = math.ceil(total / 2**(max_depth - depth))
... level_hashes = [None] * num_items
... merkle_tree.append(level_hashes)
>>> for level in merkle_tree:
... print(level)
[None]
[None, None]
[None, None, None, None]
[None, None, None, None, None, None, None, None ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

밑바닥부터 시작하는 딥러닝

밑바닥부터 시작하는 딥러닝

사이토 고키
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791162248294