From da85a1d80b91c6c619e97a7d5435818363a4e215 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Mon, 7 Oct 2019 14:00:10 -0600 Subject: [PATCH] GetDisplayPrevHash() should not change its argument --- parser/block.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parser/block.go b/parser/block.go index 0d60fed..1c02235 100644 --- a/parser/block.go +++ b/parser/block.go @@ -44,13 +44,14 @@ func (b *Block) GetEncodableHash() []byte { } func (b *Block) GetDisplayPrevHash() []byte { - h := b.hdr.HashPrevBlock + rhash := make([]byte, len(b.hdr.HashPrevBlock)) + copy(rhash, b.hdr.HashPrevBlock) // Reverse byte order - for i := 0; i < len(h)/2; i++ { - j := len(h) - 1 - i - h[i], h[j] = h[j], h[i] + for i := 0; i < len(rhash)/2; i++ { + j := len(rhash) - 1 - i + rhash[i], rhash[j] = rhash[j], rhash[i] } - return h + return rhash } func (b *Block) HasSaplingTransactions() bool {