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

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

by 류정필, 송재준
November 2019
Beginner to intermediate
408 pages
9h 29m
Korean
Hanbit Media, Inc.
Content preview from 밑바닥부터 시작하는 비트코인
11
장
단순 지급 검증
287
None, None, None]
➊ 매 레벨마다 노드의 수가 절반씩 줄어들기 때문에 단말 노드 수에
log
2
를 한 값이 가장 큰
머클트리 레벨 번호가 됩니다. 각 레벨에서 노드 수가
2
의 거듭제곱이 아닌 경우를 위해
math
.
ceil
함수로 반올림하여 정확한 레벨의 개수를 구합니다.
len
(
bin
(
total
))-
2
로
구할 수도 있습니다.
➋ 머클트리는 루트 레벨을
0
번 인덱스에 갖고 있고, 그 아래 레벨의 노드는
1
번 인덱스에,
그다음은
2
번 인덱스에 순차적으로 가지게 됩니다. 다시 말하면 인덱스는 위로부터 아래
로의 깊이입니다.
➌ 총 레벨의 수는
0
번 레벨부터 시작하기 때문에
max
_
depth
에
1
을 더해야 합니다.
➍ 현재 레벨에서의 노드 개수는 가장 높은 레벨에서 한 레벨씩 올라올 때마나 절반씩 줄어
들기 때문에 전체 노드의 수를 총 레벨의 수와 현재 레벨의 수의 차이 (
max
_
depth
-
depth
)
만큼
2
로 계속 나눈 값입니다. 레벨에서 노드의 개수가 홀수가 되는 경우에도 정확한 값을
구하기 위해
math
.
ceil
을 호출합니다.
➎ 현재로서는 해시값을 모르므로
None
값으로 초기화합니다.
➏ 여기서
merkle
_
tree
변수는 해시값 리스트의 리스트입니다. 즉
2
차원 배열로 머클트리를
표현했습니다.
연습문제
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

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

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

사이토 고키
견고한 데이터 엔지니어링

견고한 데이터 엔지니어링

조 라이스, 맷 하우슬리
실리콘밸리 리더십

실리콘밸리 리더십

김정혜, 마이클 롭

Publisher Resources

ISBN: 9791162248294