export HashMerkleBranches
ok @davecgh
This commit is contained in:
parent
79beb22aef
commit
0cdaefd4cc
2 changed files with 24 additions and 23 deletions
10
merkle.go
10
merkle.go
|
@ -24,10 +24,10 @@ func nextPowerOfTwo(n int) int {
|
|||
return 1 << exponent // 2^exponent
|
||||
}
|
||||
|
||||
// hashMerkleBranches takes two hashes, treated as the left and right tree
|
||||
// HashMerkleBranches takes two hashes, treated as the left and right tree
|
||||
// nodes, and returns the hash of their concatenation. This is a helper
|
||||
// function used to during generatation of a merkle tree.
|
||||
func hashMerkleBranches(left *btcwire.ShaHash, right *btcwire.ShaHash) *btcwire.ShaHash {
|
||||
// function used to aid in the generation of a merkle tree.
|
||||
func HashMerkleBranches(left *btcwire.ShaHash, right *btcwire.ShaHash) *btcwire.ShaHash {
|
||||
// Concatenate the left and right nodes.
|
||||
var sha [btcwire.HashSize * 2]byte
|
||||
copy(sha[:btcwire.HashSize], left.Bytes())
|
||||
|
@ -92,13 +92,13 @@ func BuildMerkleTreeStore(transactions []*btcutil.Tx) []*btcwire.ShaHash {
|
|||
// When there is no right child, the parent is generated by
|
||||
// hashing the concatenation of the left child with itself.
|
||||
case merkles[i+1] == nil:
|
||||
newSha := hashMerkleBranches(merkles[i], merkles[i])
|
||||
newSha := HashMerkleBranches(merkles[i], merkles[i])
|
||||
merkles[offset] = newSha
|
||||
|
||||
// The normal case sets the parent node to the double sha256
|
||||
// of the concatentation of the left and right children.
|
||||
default:
|
||||
newSha := hashMerkleBranches(merkles[i], merkles[i+1])
|
||||
newSha := HashMerkleBranches(merkles[i], merkles[i+1])
|
||||
merkles[offset] = newSha
|
||||
}
|
||||
offset++
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
|
||||
github.com/conformal/btcchain/validate.go checkSerializedHeight 100.00% (17/17)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.removeOrphanBlock 100.00% (16/16)
|
||||
github.com/conformal/btcchain/difficulty.go BigToCompact 100.00% (16/16)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.removeOrphanBlock 100.00% (16/16)
|
||||
github.com/conformal/btcchain/txlookup.go disconnectTransactions 100.00% (13/13)
|
||||
github.com/conformal/btcchain/difficulty.go CompactToBig 100.00% (12/12)
|
||||
github.com/conformal/btcchain/validate.go CountSigOps 100.00% (9/9)
|
||||
github.com/conformal/btcchain/validate.go BlockChain.CheckConnectBlock 100.00% (7/7)
|
||||
github.com/conformal/btcchain/checkpoints.go init 100.00% (6/6)
|
||||
github.com/conformal/btcchain/merkle.go hashMerkleBranches 100.00% (5/5)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.IsKnownOrphan 100.00% (5/5)
|
||||
github.com/conformal/btcchain/difficulty.go CalcWork 100.00% (5/5)
|
||||
github.com/conformal/btcchain/merkle.go HashMerkleBranches 100.00% (5/5)
|
||||
github.com/conformal/btcchain/difficulty.go ShaHashToBig 100.00% (5/5)
|
||||
github.com/conformal/btcchain/difficulty.go CalcWork 100.00% (5/5)
|
||||
github.com/conformal/btcchain/merkle.go nextPowerOfTwo 100.00% (4/4)
|
||||
github.com/conformal/btcchain/chain.go newBlockNode 100.00% (3/3)
|
||||
github.com/conformal/btcchain/process.go BlockChain.blockExists 100.00% (3/3)
|
||||
github.com/conformal/btcchain/chain.go New 100.00% (2/2)
|
||||
github.com/conformal/btcchain/checkpoints.go newShaHashFromStr 100.00% (2/2)
|
||||
github.com/conformal/btcchain/timesorter.go timeSorter.Swap 100.00% (1/1)
|
||||
github.com/conformal/btcchain/chain.go New 100.00% (2/2)
|
||||
github.com/conformal/btcchain/log.go DisableLog 100.00% (1/1)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.HaveBlock 100.00% (1/1)
|
||||
github.com/conformal/btcchain/log.go init 100.00% (1/1)
|
||||
github.com/conformal/btcchain/timesorter.go timeSorter.Less 100.00% (1/1)
|
||||
github.com/conformal/btcchain/timesorter.go timeSorter.Swap 100.00% (1/1)
|
||||
github.com/conformal/btcchain/timesorter.go timeSorter.Len 100.00% (1/1)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.DisableCheckpoints 100.00% (1/1)
|
||||
github.com/conformal/btcchain/scriptval.go newTxValidator 100.00% (1/1)
|
||||
github.com/conformal/btcchain/scriptval.go txValidator.sendResult 100.00% (1/1)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.DisableCheckpoints 100.00% (1/1)
|
||||
github.com/conformal/btcchain/params.go BlockChain.chainParams 100.00% (1/1)
|
||||
github.com/conformal/btcchain/log.go DisableLog 100.00% (1/1)
|
||||
github.com/conformal/btcchain/validate.go CalcBlockSubsidy 100.00% (1/1)
|
||||
github.com/conformal/btcchain/txlookup.go fetchTxStoreMain 95.65% (22/23)
|
||||
github.com/conformal/btcchain/merkle.go BuildMerkleTreeStore 93.33% (14/15)
|
||||
|
@ -33,12 +33,12 @@ github.com/conformal/btcchain/chain.go BlockChain.getReorganizeNodes 92.86%
|
|||
github.com/conformal/btcchain/scriptval.go txValidator.Validate 88.46% (23/26)
|
||||
github.com/conformal/btcchain/scriptval.go checkBlockScripts 88.24% (15/17)
|
||||
github.com/conformal/btcchain/txlookup.go BlockChain.fetchTxStore 86.96% (20/23)
|
||||
github.com/conformal/btcchain/validate.go BlockChain.checkBIP0030 85.71% (12/14)
|
||||
github.com/conformal/btcchain/validate.go IsCoinBase 85.71% (6/7)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.connectBestChain 85.29% (29/34)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.reorganizeChain 85.29% (29/34)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.connectBestChain 85.29% (29/34)
|
||||
github.com/conformal/btcchain/process.go BlockChain.processOrphans 84.21% (16/19)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.connectBlock 83.33% (10/12)
|
||||
github.com/conformal/btcchain/validate.go BlockChain.checkBIP0030 82.35% (14/17)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.calcPastMedianTime 82.35% (14/17)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.isMajorityVersion 80.00% (8/10)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.addOrphanBlock 77.78% (14/18)
|
||||
|
@ -57,12 +57,12 @@ github.com/conformal/btcchain/params.go ChainParams 60.00% (3/5)
|
|||
github.com/conformal/btcchain/validate.go isBIP0030Node 60.00% (3/5)
|
||||
github.com/conformal/btcchain/scriptval.go txValidator.validateHandler 59.26% (16/27)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.loadBlockNode 53.85% (14/26)
|
||||
github.com/conformal/btcchain/validate.go checkProofOfWork 53.33% (8/15)
|
||||
github.com/conformal/btcchain/validate.go CheckProofOfWork 53.33% (8/15)
|
||||
github.com/conformal/btcchain/process.go BlockChain.ProcessBlock 52.27% (23/44)
|
||||
github.com/conformal/btcchain/accept.go BlockChain.maybeAcceptBlock 51.28% (40/78)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.getPrevNodeFromNode 50.00% (4/8)
|
||||
github.com/conformal/btcchain/notifications.go BlockChain.sendNotification 50.00% (2/4)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.LatestCheckpoint 50.00% (2/4)
|
||||
github.com/conformal/btcchain/notifications.go BlockChain.sendNotification 50.00% (2/4)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.pruneBlockNodes 41.18% (7/17)
|
||||
github.com/conformal/btcchain/validate.go IsFinalizedTransaction 28.57% (4/14)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.verifyCheckpoint 22.22% (2/9)
|
||||
|
@ -72,25 +72,26 @@ github.com/conformal/btcchain/blocklocator.go BlockChain.BlockLocatorFromHash
|
|||
github.com/conformal/btcchain/checkpoints.go BlockChain.IsCheckpointCandidate 0.00% (0/32)
|
||||
github.com/conformal/btcchain/validate.go CountP2SHSigOps 0.00% (0/26)
|
||||
github.com/conformal/btcchain/difficulty.go BlockChain.calcEasiestDifficulty 0.00% (0/15)
|
||||
github.com/conformal/btcchain/difficulty.go BlockChain.findPrevTestNetDifficulty 0.00% (0/12)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.removeBlockNode 0.00% (0/12)
|
||||
github.com/conformal/btcchain/difficulty.go BlockChain.findPrevTestNetDifficulty 0.00% (0/12)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.GetOrphanRoot 0.00% (0/11)
|
||||
github.com/conformal/btcchain/scriptval.go ValidateTransactionScripts 0.00% (0/11)
|
||||
github.com/conformal/btcchain/log.go SetLogWriter 0.00% (0/10)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.IsCurrent 0.00% (0/9)
|
||||
github.com/conformal/btcchain/chain.go removeChildNode 0.00% (0/8)
|
||||
github.com/conformal/btcchain/blocklocator.go BlockChain.LatestBlockLocator 0.00% (0/6)
|
||||
github.com/conformal/btcchain/txlookup.go BlockChain.FetchTransactionStore 0.00% (0/6)
|
||||
github.com/conformal/btcchain/blocklocator.go BlockChain.LatestBlockLocator 0.00% (0/6)
|
||||
github.com/conformal/btcchain/checkpoints.go isNonstandardTransaction 0.00% (0/5)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.checkpointData 0.00% (0/4)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.Checkpoints 0.00% (0/3)
|
||||
github.com/conformal/btcchain/chain.go addChildrenWork 0.00% (0/3)
|
||||
github.com/conformal/btcchain/checkpoints.go BlockChain.Checkpoints 0.00% (0/3)
|
||||
github.com/conformal/btcchain/notifications.go NotificationType.String 0.00% (0/3)
|
||||
github.com/conformal/btcchain/log.go UseLogger 0.00% (0/1)
|
||||
github.com/conformal/btcchain/process.go RuleError.Error 0.00% (0/1)
|
||||
github.com/conformal/btcchain/log.go newLogClosure 0.00% (0/1)
|
||||
github.com/conformal/btcchain/difficulty.go BlockChain.CalcNextRequiredDifficulty 0.00% (0/1)
|
||||
github.com/conformal/btcchain/log.go logClosure.String 0.00% (0/1)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.DisableVerify 0.00% (0/1)
|
||||
github.com/conformal/btcchain ------------------------------------- 56.57% (706/1248)
|
||||
github.com/conformal/btcchain/log.go newLogClosure 0.00% (0/1)
|
||||
github.com/conformal/btcchain/log.go UseLogger 0.00% (0/1)
|
||||
github.com/conformal/btcchain/chain.go BlockChain.CalcPastMedianTime 0.00% (0/1)
|
||||
github.com/conformal/btcchain/difficulty.go BlockChain.CalcNextRequiredDifficulty 0.00% (0/1)
|
||||
github.com/conformal/btcchain ------------------------------------- 56.50% (704/1246)
|
||||
|
||||
|
|
Loading…
Reference in a new issue