From 4e114333257c24d85680082a978f20d43a344d54 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Fri, 26 Aug 2022 10:18:01 -0400 Subject: [PATCH 1/2] Payload of HashXHistoryValue should be an array of uint32 representing "txnums". --- db/prefixes/prefixes.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/db/prefixes/prefixes.go b/db/prefixes/prefixes.go index 4161f35..eee6495 100644 --- a/db/prefixes/prefixes.go +++ b/db/prefixes/prefixes.go @@ -513,7 +513,7 @@ type HashXHistoryKey struct { } type HashXHistoryValue struct { - HashXes []uint16 `struct-while:"!_eof" json:"hashxes"` + TxNums []uint32 `struct-while:"!_eof" json:"tx_nums"` } func (k *HashXHistoryKey) String() string { @@ -538,10 +538,10 @@ func (k *HashXHistoryKey) PackKey() []byte { } func (v *HashXHistoryValue) PackValue() []byte { - n := len(v.HashXes) - value := make([]byte, n*2) - for i, x := range v.HashXes { - binary.BigEndian.PutUint16(value[i*2:], x) + n := len(v.TxNums) + value := make([]byte, n*4) + for i, x := range v.TxNums { + binary.BigEndian.PutUint32(value[i*4:], x) } return value @@ -600,13 +600,13 @@ func HashXHistoryKeyUnpack(key []byte) *HashXHistoryKey { } func HashXHistoryValueUnpack(value []byte) *HashXHistoryValue { - n := len(value) / 2 - hashxes := make([]uint16, n) + n := len(value) / 4 + txnums := make([]uint32, n) for i := 0; i < n; i++ { - hashxes[i] = binary.BigEndian.Uint16(value[i*2:]) + txnums[i] = binary.BigEndian.Uint32(value[i*4:]) } return &HashXHistoryValue{ - HashXes: hashxes, + TxNums: txnums, } } From e46ac7c913d684d59950b28d91b737f77fef4814 Mon Sep 17 00:00:00 2001 From: Jonathan Moody <103143855+moodyjon@users.noreply.github.com> Date: Thu, 1 Sep 2022 12:58:41 -0500 Subject: [PATCH 2/2] HashXHistoryValue TxNums are unique in that they are little-endian (at least when written by Python scribe on ARM64 Mac or x86). --- db/prefixes/prefixes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/prefixes/prefixes.go b/db/prefixes/prefixes.go index eee6495..b6d4a7d 100644 --- a/db/prefixes/prefixes.go +++ b/db/prefixes/prefixes.go @@ -541,7 +541,7 @@ func (v *HashXHistoryValue) PackValue() []byte { n := len(v.TxNums) value := make([]byte, n*4) for i, x := range v.TxNums { - binary.BigEndian.PutUint32(value[i*4:], x) + binary.LittleEndian.PutUint32(value[i*4:], x) } return value @@ -603,7 +603,7 @@ func HashXHistoryValueUnpack(value []byte) *HashXHistoryValue { n := len(value) / 4 txnums := make([]uint32, n) for i := 0; i < n; i++ { - txnums[i] = binary.BigEndian.Uint32(value[i*4:]) + txnums[i] = binary.LittleEndian.Uint32(value[i*4:]) } return &HashXHistoryValue{ TxNums: txnums,