diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 878261691..d6a33f9d8 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -531,7 +531,7 @@ func (bc *Blockchain) addHeaders(verify bool, headers ...*block.Header) error { return buf.Err } - key := storage.AppendPrefix(storage.DataBlock, h.Hash().BytesLE()) + key := storage.AppendPrefix(storage.DataBlock, h.Hash().BytesBE()) batch.Put(key, buf.Bytes()) buf.Reset() lastHeader = h diff --git a/pkg/core/blockchain_test.go b/pkg/core/blockchain_test.go index d9dfa0e85..bb30d48c0 100644 --- a/pkg/core/blockchain_test.go +++ b/pkg/core/blockchain_test.go @@ -114,7 +114,7 @@ func TestAddBlock(t *testing.T) { require.NoError(t, bc.persist()) for _, block := range blocks { - key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesLE()) + key := storage.AppendPrefix(storage.DataBlock, block.Hash().BytesBE()) _, err := bc.dao.Store.Get(key) require.NoErrorf(t, err, "block %s not persisted", block.Hash()) } diff --git a/pkg/core/dao/dao.go b/pkg/core/dao/dao.go index 78ff94153..bdbb70a25 100644 --- a/pkg/core/dao/dao.go +++ b/pkg/core/dao/dao.go @@ -510,7 +510,7 @@ func makeStorageItemKey(id int32, key []byte) []byte { // GetBlock returns Block by the given hash if it exists in the store. func (dao *Simple) GetBlock(hash util.Uint256) (*block.Block, error) { - key := storage.AppendPrefix(storage.DataBlock, hash.BytesLE()) + key := storage.AppendPrefix(storage.DataBlock, hash.BytesBE()) b, err := dao.Store.Get(key) if err != nil { return nil, err @@ -586,7 +586,7 @@ func (dao *Simple) GetHeaderHashes() ([]util.Uint256, error) { // GetTransaction returns Transaction and its height by the given hash // if it exists in the store. It does not return dummy transactions. func (dao *Simple) GetTransaction(hash util.Uint256) (*transaction.Transaction, uint32, error) { - key := storage.AppendPrefix(storage.DataTransaction, hash.BytesLE()) + key := storage.AppendPrefix(storage.DataTransaction, hash.BytesBE()) b, err := dao.Store.Get(key) if err != nil { return nil, 0, err @@ -637,7 +637,7 @@ func read2000Uint256Hashes(b []byte) ([]util.Uint256, error) { // Transaction hash. It returns an error in case if transaction is in chain // or in the list of conflicting transactions. func (dao *Simple) HasTransaction(hash util.Uint256) error { - key := storage.AppendPrefix(storage.DataTransaction, hash.BytesLE()) + key := storage.AppendPrefix(storage.DataTransaction, hash.BytesBE()) bytes, err := dao.Store.Get(key) if err != nil { return nil @@ -656,7 +656,7 @@ func (dao *Simple) HasTransaction(hash util.Uint256) error { // the purpose of value serialization. func (dao *Simple) StoreAsBlock(block *block.Block, buf *io.BufBinWriter) error { var ( - key = storage.AppendPrefix(storage.DataBlock, block.Hash().BytesLE()) + key = storage.AppendPrefix(storage.DataBlock, block.Hash().BytesBE()) ) if buf == nil { buf = io.NewBufBinWriter() @@ -688,7 +688,7 @@ func (dao *Simple) StoreAsCurrentBlock(block *block.Block, buf *io.BufBinWriter) // StoreAsTransaction stores given TX as DataTransaction. It can reuse given // buffer for the purpose of value serialization. func (dao *Simple) StoreAsTransaction(tx *transaction.Transaction, index uint32, buf *io.BufBinWriter) error { - key := storage.AppendPrefix(storage.DataTransaction, tx.Hash().BytesLE()) + key := storage.AppendPrefix(storage.DataTransaction, tx.Hash().BytesBE()) if buf == nil { buf = io.NewBufBinWriter() }