diff --git a/pkg/consensus/consensus_test.go b/pkg/consensus/consensus_test.go index db31c204d..7243bce01 100644 --- a/pkg/consensus/consensus_test.go +++ b/pkg/consensus/consensus_test.go @@ -239,6 +239,6 @@ func newTestChain(t *testing.T) *core.Blockchain { type feer struct{} func (fs *feer) NetworkFee(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) } -func (fs *feer) IsLowPriority(*transaction.Transaction) bool { return false } +func (fs *feer) IsLowPriority(util.Fixed8) bool { return false } func (fs *feer) FeePerByte(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) } func (fs *feer) SystemFee(*transaction.Transaction) util.Fixed8 { return util.Fixed8(0) } diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 1c3869c89..2aa323562 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -1019,10 +1019,10 @@ func (bc *Blockchain) SystemFee(t *transaction.Transaction) util.Fixed8 { return bc.GetConfig().SystemFee.TryGetValue(t.Type) } -// IsLowPriority flags a transaction as low priority if the network fee is less than +// IsLowPriority checks given fee for being less than configured // LowPriorityThreshold. -func (bc *Blockchain) IsLowPriority(t *transaction.Transaction) bool { - return bc.NetworkFee(t) < util.Fixed8FromFloat(bc.GetConfig().LowPriorityThreshold) +func (bc *Blockchain) IsLowPriority(fee util.Fixed8) bool { + return fee < util.Fixed8FromFloat(bc.GetConfig().LowPriorityThreshold) } // GetMemPool returns the memory pool of the blockchain. diff --git a/pkg/core/mempool/feer.go b/pkg/core/mempool/feer.go index f92c0e1d1..74b3fb036 100644 --- a/pkg/core/mempool/feer.go +++ b/pkg/core/mempool/feer.go @@ -8,7 +8,7 @@ import ( // Feer is an interface that abstract the implementation of the fee calculation. type Feer interface { NetworkFee(t *transaction.Transaction) util.Fixed8 - IsLowPriority(t *transaction.Transaction) bool + IsLowPriority(util.Fixed8) bool FeePerByte(t *transaction.Transaction) util.Fixed8 SystemFee(t *transaction.Transaction) util.Fixed8 } diff --git a/pkg/core/mempool/mem_pool.go b/pkg/core/mempool/mem_pool.go index a2f3ef9af..3facd377a 100644 --- a/pkg/core/mempool/mem_pool.go +++ b/pkg/core/mempool/mem_pool.go @@ -128,8 +128,8 @@ func (mp *Pool) Add(t *transaction.Transaction, fee Feer) error { timeStamp: time.Now().UTC(), perByteFee: fee.FeePerByte(t), netFee: fee.NetworkFee(t), - isLowPrio: fee.IsLowPriority(t), } + pItem.isLowPrio = fee.IsLowPriority(pItem.netFee) mp.lock.Lock() if !mp.verifyInputs(t) { mp.lock.Unlock() diff --git a/pkg/core/mempool/mem_pool_test.go b/pkg/core/mempool/mem_pool_test.go index 4cd529a06..f60829a2a 100644 --- a/pkg/core/mempool/mem_pool_test.go +++ b/pkg/core/mempool/mem_pool_test.go @@ -22,7 +22,7 @@ func (fs *FeerStub) NetworkFee(*transaction.Transaction) util.Fixed8 { return fs.netFee } -func (fs *FeerStub) IsLowPriority(*transaction.Transaction) bool { +func (fs *FeerStub) IsLowPriority(util.Fixed8) bool { return fs.lowPriority } diff --git a/pkg/network/helper_test.go b/pkg/network/helper_test.go index 1ab191d87..468819736 100644 --- a/pkg/network/helper_test.go +++ b/pkg/network/helper_test.go @@ -122,7 +122,7 @@ func (chain testChain) GetMemPool() *mempool.Pool { panic("TODO") } -func (chain testChain) IsLowPriority(*transaction.Transaction) bool { +func (chain testChain) IsLowPriority(util.Fixed8) bool { panic("TODO") }