Merge pull request #91 from zcash-hackworks/immutable-GetDisplayPrevHash

GetDisplayPrevHash() should not change its argument
This commit is contained in:
Marshall Gaucher 2019-10-08 10:09:07 -07:00 committed by GitHub
commit 50a2667703
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -149,7 +149,7 @@ func main() {
if timeout_count > 0 { if timeout_count > 0 {
timeout_count-- timeout_count--
} }
phash = hex.EncodeToString(block.GetPrevHash()) phash = hex.EncodeToString(block.GetDisplayPrevHash())
//check for reorgs once we have initial block hash from startup //check for reorgs once we have initial block hash from startup
if hash != phash && reorg_count != -1 { if hash != phash && reorg_count != -1 {
reorg_count++ reorg_count++

View File

@ -44,13 +44,14 @@ func (b *Block) GetEncodableHash() []byte {
} }
func (b *Block) GetDisplayPrevHash() []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 // Reverse byte order
for i := 0; i < len(h)/2; i++ { for i := 0; i < len(rhash)/2; i++ {
j := len(h) - 1 - i j := len(rhash) - 1 - i
h[i], h[j] = h[j], h[i] rhash[i], rhash[j] = rhash[j], rhash[i]
} }
return h return rhash
} }
func (b *Block) HasSaplingTransactions() bool { func (b *Block) HasSaplingTransactions() bool {