forked from TrueCloudLab/neoneo-go
crypto: move merkle tree into the hash package
It's all about hashes, so it makes sense putting it there.
This commit is contained in:
parent
db5555bb15
commit
ee28fb08f6
3 changed files with 6 additions and 7 deletions
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/core/transaction"
|
||||
"github.com/CityOfZion/neo-go/pkg/crypto"
|
||||
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
||||
"github.com/CityOfZion/neo-go/pkg/io"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
"github.com/Workiva/go-datastructures/queue"
|
||||
|
@ -30,13 +30,13 @@ func (b *Block) Header() *Header {
|
|||
}
|
||||
}
|
||||
|
||||
func merkleTreeFromTransactions(txes []*transaction.Transaction) (*crypto.MerkleTree, error) {
|
||||
func merkleTreeFromTransactions(txes []*transaction.Transaction) (*hash.MerkleTree, error) {
|
||||
hashes := make([]util.Uint256, len(txes))
|
||||
for i, tx := range txes {
|
||||
hashes[i] = tx.Hash()
|
||||
}
|
||||
|
||||
return crypto.NewMerkleTree(hashes)
|
||||
return hash.NewMerkleTree(hashes)
|
||||
}
|
||||
|
||||
// rebuildMerkleRoot rebuilds the merkleroot of the block.
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package crypto
|
||||
package hash
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/CityOfZion/neo-go/pkg/crypto/hash"
|
||||
"github.com/CityOfZion/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
|
@ -66,7 +65,7 @@ func buildMerkleTree(leaves []*MerkleTreeNode) (*MerkleTreeNode, error) {
|
|||
b1 := parents[i].leftChild.hash.BytesBE()
|
||||
b2 := parents[i].rightChild.hash.BytesBE()
|
||||
b1 = append(b1, b2...)
|
||||
parents[i].hash = hash.DoubleSha256(b1)
|
||||
parents[i].hash = DoubleSha256(b1)
|
||||
}
|
||||
|
||||
return buildMerkleTree(parents)
|
|
@ -1,4 +1,4 @@
|
|||
package crypto
|
||||
package hash
|
||||
|
||||
import (
|
||||
"testing"
|
Loading…
Reference in a new issue