@@ -24,18 +24,16 @@ import (
2424 "sync"
2525 "time"
2626
27- "github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
28-
2927 "github.com/XinFinOrg/XDPoSChain/XDCxlending/lendingstate"
30- "github.com/XinFinOrg/XDPoSChain/consensus"
31-
3228 "github.com/XinFinOrg/XDPoSChain/common"
29+ "github.com/XinFinOrg/XDPoSChain/common/prque"
30+ "github.com/XinFinOrg/XDPoSChain/consensus"
31+ "github.com/XinFinOrg/XDPoSChain/consensus/XDPoS"
3332 "github.com/XinFinOrg/XDPoSChain/core/state"
3433 "github.com/XinFinOrg/XDPoSChain/core/types"
3534 "github.com/XinFinOrg/XDPoSChain/event"
3635 "github.com/XinFinOrg/XDPoSChain/log"
3736 "github.com/XinFinOrg/XDPoSChain/params"
38- "gopkg.in/karalabe/cookiejar.v2/collections/prque"
3937)
4038
4139var (
@@ -671,7 +669,7 @@ func (pool *LendingPool) add(tx *types.LendingTransaction, local bool) (bool, er
671669 // If the transaction fails basic validation, discard it
672670 if err := pool .validateTx (tx , local ); err != nil {
673671 log .Debug ("Discarding invalid lending transaction" , "hash" , hash , "userAddress" , tx .UserAddress , "status" , tx .Status , "err" , err )
674- invalidTxCounter . Inc (1 )
672+ invalidTxMeter . Mark (1 )
675673 return false , err
676674 }
677675 from , _ := types .LendingSender (pool .signer , tx ) // already validated
@@ -685,12 +683,12 @@ func (pool *LendingPool) add(tx *types.LendingTransaction, local bool) (bool, er
685683 if list := pool .pending [from ]; list != nil && list .Overlaps (tx ) {
686684 inserted , old := list .Add (tx )
687685 if ! inserted {
688- pendingDiscardCounter . Inc (1 )
686+ pendingDiscardMeter . Mark (1 )
689687 return false , ErrPendingNonceTooLow
690688 }
691689 if old != nil {
692690 delete (pool .all , old .Hash ())
693- pendingReplaceCounter . Inc (1 )
691+ pendingReplaceMeter . Mark (1 )
694692 }
695693 pool .all [tx .Hash ()] = tx
696694 pool .journalTx (from , tx )
@@ -726,13 +724,13 @@ func (pool *LendingPool) enqueueTx(hash common.Hash, tx *types.LendingTransactio
726724 inserted , old := pool .queue [from ].Add (tx )
727725 if ! inserted {
728726 // An older transaction was better, discard this
729- queuedDiscardCounter . Inc (1 )
727+ pendingDiscardMeter . Mark (1 )
730728 return false , ErrPendingNonceTooLow
731729 }
732730 // Discard any previous transaction and mark this
733731 if old != nil {
734732 delete (pool .all , old .Hash ())
735- queuedReplaceCounter . Inc (1 )
733+ queuedReplaceMeter . Mark (1 )
736734 }
737735 pool .all [hash ] = tx
738736 return old != nil , nil
@@ -764,13 +762,13 @@ func (pool *LendingPool) promoteTx(addr common.Address, hash common.Hash, tx *ty
764762 if ! inserted {
765763 // An older transaction was better, discard this
766764 delete (pool .all , hash )
767- pendingDiscardCounter . Inc (1 )
765+ pendingDiscardMeter . Mark (1 )
768766 return
769767 }
770768 // Otherwise discard any previous transaction and mark this
771769 if old != nil {
772770 delete (pool .all , old .Hash ())
773- pendingReplaceCounter . Inc (1 )
771+ pendingReplaceMeter . Mark (1 )
774772 }
775773 // Failsafe to work around direct pending inserts (tests)
776774 if pool .all [hash ] == nil {
@@ -981,7 +979,7 @@ func (pool *LendingPool) promoteExecutables(accounts []common.Address) {
981979 hash := tx .Hash ()
982980 delete (pool .all , hash )
983981
984- queuedRateLimitCounter . Inc (1 )
982+ queuedRateLimitMeter . Mark (1 )
985983 log .Trace ("Removed cap-exceeding queued transaction" , "hash" , hash )
986984 }
987985 }
@@ -998,11 +996,11 @@ func (pool *LendingPool) promoteExecutables(accounts []common.Address) {
998996 if pending > pool .config .GlobalSlots {
999997 pendingBeforeCap := pending
1000998 // Assemble a spam order to penalize large transactors first
1001- spammers := prque .New ()
999+ spammers := prque .New (nil )
10021000 for addr , list := range pool .pending {
10031001 // Only evict transactions from high rollers
10041002 if ! pool .locals .contains (addr ) && uint64 (list .Len ()) > pool .config .AccountSlots {
1005- spammers .Push (addr , float32 (list .Len ()))
1003+ spammers .Push (addr , int64 (list .Len ()))
10061004 }
10071005 }
10081006 // Gradually drop transactions from offenders
@@ -1057,7 +1055,7 @@ func (pool *LendingPool) promoteExecutables(accounts []common.Address) {
10571055 }
10581056 }
10591057 }
1060- pendingRateLimitCounter . Inc (int64 (pendingBeforeCap - pending ))
1058+ pendingRateLimitMeter . Mark (int64 (pendingBeforeCap - pending ))
10611059 }
10621060 // If we've queued more transactions than the hard limit, drop oldest ones
10631061 queued := uint64 (0 )
@@ -1066,7 +1064,7 @@ func (pool *LendingPool) promoteExecutables(accounts []common.Address) {
10661064 }
10671065 if queued > pool .config .GlobalQueue {
10681066 // Sort all accounts with queued transactions by heartbeat
1069- addresses := make (addresssByHeartbeat , 0 , len (pool .queue ))
1067+ addresses := make (addressesByHeartbeat , 0 , len (pool .queue ))
10701068 for addr := range pool .queue {
10711069 if ! pool .locals .contains (addr ) { // don't drop locals
10721070 addresses = append (addresses , addressByHeartbeat {addr , pool .beats [addr ]})
@@ -1087,15 +1085,15 @@ func (pool *LendingPool) promoteExecutables(accounts []common.Address) {
10871085 pool .removeTx (tx .Hash ())
10881086 }
10891087 drop -= size
1090- queuedRateLimitCounter . Inc (int64 (size ))
1088+ queuedRateLimitMeter . Mark (int64 (size ))
10911089 continue
10921090 }
10931091 // Otherwise drop only last few transactions
10941092 txs := list .Flatten ()
10951093 for i := len (txs ) - 1 ; i >= 0 && drop > 0 ; i -- {
10961094 pool .removeTx (txs [i ].Hash ())
10971095 drop --
1098- queuedRateLimitCounter . Inc (1 )
1096+ queuedRateLimitMeter . Mark (1 )
10991097 }
11001098 }
11011099 }
0 commit comments