mirror of
				https://github.com/0glabs/0g-chain.git
				synced 2025-11-04 09:37:44 +00:00 
			
		
		
		
	fix insert issue
This commit is contained in:
		
							parent
							
								
									9b171dbd4c
								
							
						
					
					
						commit
						c70b0a1c2b
					
				@ -2,12 +2,13 @@ package app
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"context"
 | 
						"context"
 | 
				
			||||||
	"errors"
 | 
					 | 
				
			||||||
	"fmt"
 | 
					 | 
				
			||||||
	"math"
 | 
					 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						"fmt"
 | 
				
			||||||
 | 
						"math"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/huandu/skiplist"
 | 
						"github.com/huandu/skiplist"
 | 
				
			||||||
 | 
						"github.com/pkg/errors"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sdk "github.com/cosmos/cosmos-sdk/types"
 | 
						sdk "github.com/cosmos/cosmos-sdk/types"
 | 
				
			||||||
	"github.com/cosmos/cosmos-sdk/types/mempool"
 | 
						"github.com/cosmos/cosmos-sdk/types/mempool"
 | 
				
			||||||
@ -235,8 +236,8 @@ func (mp *PriorityNonceMempool) Insert(ctx context.Context, tx sdk.Tx) error {
 | 
				
			|||||||
		if mempoolSize >= mp.maxTx {
 | 
							if mempoolSize >= mp.maxTx {
 | 
				
			||||||
			lowestPriority := mp.GetLowestPriority()
 | 
								lowestPriority := mp.GetLowestPriority()
 | 
				
			||||||
			// find one to replace
 | 
								// find one to replace
 | 
				
			||||||
			if priority <= lowestPriority {
 | 
								if lowestPriority > 0 && priority <= lowestPriority {
 | 
				
			||||||
				return errMempoolTxGasPriceTooLow
 | 
									return errors.Wrapf(errMempoolTxGasPriceTooLow, "tx with priority %d is too low, current lowest priority is %d", priority, lowestPriority)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			var maxIndexSize int
 | 
								var maxIndexSize int
 | 
				
			||||||
@ -547,6 +548,10 @@ func (mp *PriorityNonceMempool) Remove(tx sdk.Tx) error {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (mp *PriorityNonceMempool) GetLowestPriority() int64 {
 | 
					func (mp *PriorityNonceMempool) GetLowestPriority() int64 {
 | 
				
			||||||
 | 
						if mp.priorityIndex.Len() == 0 {
 | 
				
			||||||
 | 
							return 0
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	min := int64(math.MaxInt64)
 | 
						min := int64(math.MaxInt64)
 | 
				
			||||||
	for priority, count := range mp.priorityCounts {
 | 
						for priority, count := range mp.priorityCounts {
 | 
				
			||||||
		if count > 0 {
 | 
							if count > 0 {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user