mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-01-05 19:35:48 +00:00
mempool: replace timeStamp with blockStamp
Time is not really relevant for us here and we don't use this timestamp in any way. Yet it occupies 24 bytes and we do two clock_gettime calls to get it. Replace it with blockStamp which is going to be used in the future for transaction retransmissions. It allows to improve single-node TPS by another 3%.
This commit is contained in:
parent
49d176010e
commit
06f3c34981
5 changed files with 11 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue