From 886250e660afb26000f4e9f3a6b7866b2de8a481 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Mon, 7 Oct 2019 14:00:10 -0600 Subject: [PATCH 1/2] 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 2ebc0b1..1a0d4d4 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 { From e4445ddace9bdda8ecf69eeefbd67374b06723e5 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Mon, 7 Oct 2019 21:02:38 -0600 Subject: [PATCH 2/2] fix constant REORG (due to fixed GetDisplayPrevHash()) --- cmd/ingest/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/ingest/main.go b/cmd/ingest/main.go index 1591701..028e41b 100644 --- a/cmd/ingest/main.go +++ b/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++