core/tx: microoptimize block/tx hashing

Don't hash the data twice.
This commit is contained in:
Roman Khimov 2019-12-12 18:01:30 +03:00
parent 7e83078d13
commit 89d7f6d26e
2 changed files with 2 additions and 2 deletions

View file

@ -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.

View file

@ -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
}