Browse Source

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

GetDisplayPrevHash() should not change its argument
service_pr
Marshall Gaucher 5 years ago
committed by GitHub
parent
commit
50a2667703
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      cmd/ingest/main.go
  2. 11
      parser/block.go

2
cmd/ingest/main.go

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

11
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 {

Loading…
Cancel
Save