Correct interpretation of DBStateValue Genesis hash.

This commit is contained in:
Jonathan Moody 2022-11-22 09:52:02 -06:00
parent 79aed85b17
commit 6a4239e1b8

View file

@ -282,6 +282,9 @@ func DBStateKeyUnpack(key []byte) *DBStateKey {
func DBStateValueUnpack(value []byte) *DBStateValue {
genesis := (*chainhash.Hash)(value[:32])
tip := (*chainhash.Hash)(value[32+4+4 : 32+4+4+32])
// HACK: Python scribe writes bytes of genesis hash in external byte-order.
// Instances of chainhash.Hash should use the internal byte-order.
internal.ReverseBytesInPlace(genesis[:])
x := &DBStateValue{
Genesis: genesis,
Height: binary.BigEndian.Uint32(value[32:]),