diff --git a/pkg/core/blockchainer.go b/pkg/core/blockchainer.go index 6ead1cd03..76c032c61 100644 --- a/pkg/core/blockchainer.go +++ b/pkg/core/blockchainer.go @@ -19,7 +19,6 @@ type Blockchainer interface { AddHeaders(...*block.Header) error AddBlock(*block.Block) error AddStateRoot(r *state.MPTRoot) error - BlockHeight() uint32 CalculateClaimable(value util.Fixed8, startHeight, endHeight uint32) (util.Fixed8, util.Fixed8, error) Close() HeaderHeight() uint32 diff --git a/pkg/core/mempool/feer.go b/pkg/core/mempool/feer.go index 89b63dab5..f425ddd2a 100644 --- a/pkg/core/mempool/feer.go +++ b/pkg/core/mempool/feer.go @@ -7,6 +7,7 @@ import ( // Feer is an interface that abstract the implementation of the fee calculation. type Feer interface { + BlockHeight() uint32 NetworkFee(t *transaction.Transaction) util.Fixed8 IsLowPriority(util.Fixed8) bool FeePerByte(t *transaction.Transaction) util.Fixed8 diff --git a/pkg/core/mempool/mem_pool.go b/pkg/core/mempool/mem_pool.go index 7dc38e2d4..8f1895132 100644 --- a/pkg/core/mempool/mem_pool.go +++ b/pkg/core/mempool/mem_pool.go @@ -4,7 +4,6 @@ import ( "errors" "sort" "sync" - "time" "github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/util" @@ -26,7 +25,7 @@ var ( // item represents a transaction in the the Memory pool. type item struct { txn *transaction.Transaction - timeStamp time.Time + blockStamp uint32 perByteFee util.Fixed8 netFee util.Fixed8 isLowPrio bool @@ -162,7 +161,7 @@ func dropInputFromSortedSlice(slice *[]*transaction.Input, input *transaction.In func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error { var pItem = &item{ txn: t, - timeStamp: time.Now().UTC(), + blockStamp: fee.BlockHeight(), perByteFee: fee.FeePerByte(t), netFee: fee.NetworkFee(t), } diff --git a/pkg/core/mempool/mem_pool_test.go b/pkg/core/mempool/mem_pool_test.go index 5cfcf7b70..2d4059281 100644 --- a/pkg/core/mempool/mem_pool_test.go +++ b/pkg/core/mempool/mem_pool_test.go @@ -18,6 +18,10 @@ type FeerStub struct { perByteFee util.Fixed8 } +func (fs *FeerStub) BlockHeight() uint32 { + return 0 +} + func (fs *FeerStub) NetworkFee(*transaction.Transaction) util.Fixed8 { return fs.netFee } diff --git a/pkg/rpc/server/server_helper_test.go b/pkg/rpc/server/server_helper_test.go index 61bcc2e0d..9a84e44ce 100644 --- a/pkg/rpc/server/server_helper_test.go +++ b/pkg/rpc/server/server_helper_test.go @@ -85,6 +85,10 @@ func initServerWithInMemoryChain(t *testing.T) (*core.Blockchain, *Server, *http type FeerStub struct{} +func (fs *FeerStub) BlockHeight() uint32 { + return 0 +} + func (fs *FeerStub) NetworkFee(*transaction.Transaction) util.Fixed8 { return 0 }