Created
June 7, 2018 08:54
-
-
Save dlgusdn616/f13d7fdb1d0bc630ae8aa884df887921 to your computer and use it in GitHub Desktop.
CBlock::CheckMerkleBranch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint256 CheckMerkleBranch(uint256 hash, const vector<uint256>& vMerkleBranch, int nIndex) | |
{ | |
if (nIndex == -1) | |
return 0; | |
foreach(const uint256& otherside, vMerkleBranch) | |
{ // 해시되는 순서를 지켜주기 위해 아래의 두 경우를 구분하여 처리 | |
if (nIndex & 1) // 트랜잭션의 인덱스가 홀수일 경우 | |
hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash)); | |
else // 트랜잭션의 인덱스가 짝수일 경우 | |
hash = Hash(BEGIN(hash), END(hash), BEGIN(otherside), END(otherside)); | |
nIndex >>= 1; // 해시되는 순서를 맞춰준다. | |
} | |
return hash; // it should be merkleRoot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment