refactor GetDisplayPrevHash(), part of block header

This commit is contained in:
Larry Ruane 2019-11-01 13:47:32 -06:00 committed by Larry Ruane
parent a18cb41c92
commit 7b78663312
2 changed files with 12 additions and 8 deletions

View File

@ -44,14 +44,7 @@ func (b *Block) GetEncodableHash() []byte {
} }
func (b *Block) GetDisplayPrevHash() []byte { func (b *Block) GetDisplayPrevHash() []byte {
rhash := make([]byte, len(b.hdr.HashPrevBlock)) return b.hdr.GetDisplayPrevHash()
copy(rhash, b.hdr.HashPrevBlock)
// Reverse byte order
for i := 0; i < len(rhash)/2; i++ {
j := len(rhash) - 1 - i
rhash[i], rhash[j] = rhash[j], rhash[i]
}
return rhash
} }
func (b *Block) HasSaplingTransactions() bool { func (b *Block) HasSaplingTransactions() bool {

View File

@ -227,3 +227,14 @@ func (hdr *blockHeader) GetEncodableHash() []byte {
return digest[:] return digest[:]
} }
func (hdr *blockHeader) GetDisplayPrevHash() []byte {
rhash := make([]byte, len(hdr.HashPrevBlock))
copy(rhash, hdr.HashPrevBlock)
// Reverse byte order
for i := 0; i < len(rhash)/2; i++ {
j := len(rhash) - 1 - i
rhash[i], rhash[j] = rhash[j], rhash[i]
}
return rhash
}