From 0e2bda4f210ff0bc098e1c49f99297beeed24ca1 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 9 Mar 2020 16:31:05 +0300 Subject: [PATCH] core: drop txHash from SpentCoinState It's a key for it, makes no sense storing it as data. --- pkg/core/dao.go | 2 +- pkg/core/spent_coin_state.go | 7 +------ pkg/core/spent_coin_state_test.go | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/pkg/core/dao.go b/pkg/core/dao.go index d64b1426c..4973a3b76 100644 --- a/pkg/core/dao.go +++ b/pkg/core/dao.go @@ -219,7 +219,7 @@ func (dao *dao) GetSpentCoinsOrNew(hash util.Uint256, height uint32) (*SpentCoin if err != storage.ErrKeyNotFound { return nil, err } - spent = NewSpentCoinState(hash, height) + spent = NewSpentCoinState(height) } return spent, nil } diff --git a/pkg/core/spent_coin_state.go b/pkg/core/spent_coin_state.go index b7702f9c6..85f0e4008 100644 --- a/pkg/core/spent_coin_state.go +++ b/pkg/core/spent_coin_state.go @@ -3,12 +3,10 @@ package core import ( "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/io" - "github.com/nspcc-dev/neo-go/pkg/util" ) // SpentCoinState represents the state of a spent coin. type SpentCoinState struct { - txHash util.Uint256 txHeight uint32 // A mapping between the index of the prevIndex and block height. @@ -23,9 +21,8 @@ type spentCoin struct { } // NewSpentCoinState returns a new SpentCoinState object. -func NewSpentCoinState(hash util.Uint256, height uint32) *SpentCoinState { +func NewSpentCoinState(height uint32) *SpentCoinState { return &SpentCoinState{ - txHash: hash, txHeight: height, items: make(map[uint16]uint32), } @@ -33,7 +30,6 @@ func NewSpentCoinState(hash util.Uint256, height uint32) *SpentCoinState { // DecodeBinary implements Serializable interface. func (s *SpentCoinState) DecodeBinary(br *io.BinReader) { - br.ReadBytes(s.txHash[:]) s.txHeight = br.ReadU32LE() s.items = make(map[uint16]uint32) @@ -51,7 +47,6 @@ func (s *SpentCoinState) DecodeBinary(br *io.BinReader) { // EncodeBinary implements Serializable interface. func (s *SpentCoinState) EncodeBinary(bw *io.BinWriter) { - bw.WriteBytes(s.txHash[:]) bw.WriteU32LE(s.txHeight) bw.WriteVarUint(uint64(len(s.items))) for k, v := range s.items { diff --git a/pkg/core/spent_coin_state_test.go b/pkg/core/spent_coin_state_test.go index b6a289974..4fce2b386 100644 --- a/pkg/core/spent_coin_state_test.go +++ b/pkg/core/spent_coin_state_test.go @@ -10,7 +10,6 @@ import ( func TestEncodeDecodeSpentCoinState(t *testing.T) { spent := &SpentCoinState{ - txHash: random.Uint256(), txHeight: 1001, items: map[uint16]uint32{ 1: 3,