mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 13:38:35 +00:00
core/tx: microoptimize block/tx hashing
Don't hash the data twice.
This commit is contained in:
parent
7e83078d13
commit
89d7f6d26e
2 changed files with 2 additions and 2 deletions
|
@ -107,8 +107,8 @@ func (b *BlockBase) GetHashableData() []byte {
|
|||
// the modification of transaction will influence the hash value of the block.
|
||||
func (b *BlockBase) createHash() {
|
||||
bb := b.GetHashableData()
|
||||
b.hash = hash.DoubleSha256(bb)
|
||||
b.verificationHash = hash.Sha256(bb)
|
||||
b.hash = hash.Sha256(b.verificationHash.BytesBE())
|
||||
}
|
||||
|
||||
// encodeHashableFields will only encode the fields used for hashing.
|
||||
|
|
|
@ -178,8 +178,8 @@ func (t *Transaction) createHash() error {
|
|||
}
|
||||
|
||||
b := buf.Bytes()
|
||||
t.hash = hash.DoubleSha256(b)
|
||||
t.verificationHash = hash.Sha256(b)
|
||||
t.hash = hash.Sha256(t.verificationHash.BytesBE())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue