Skip to content

Commit

Permalink
add nil check
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Aug 23, 2024
1 parent 25cd3d7 commit fd126e9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions types/mempool/priority_nonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,17 @@ func (i *PriorityNonceIterator[C]) Next() Iterator {

key := cursor.Key().(txMeta[C])

weight := i.mempool.priorityIndex.GetScore(key.nonce, key.sender).Weight

// We've reached a transaction with a priority lower than the next highest
// priority in the pool.
if i.mempool.cfg.TxPriority.Compare(key.priority, i.nextPriority) < 0 {
return i.iteratePriority()
}
nextElem := i.priorityNode.Next()
if nextElem != nil && i.mempool.cfg.TxPriority.Compare(key.priority, i.nextPriority) == 0 {
var weight C
if score := i.mempool.priorityIndex.GetScore(key.nonce, key.sender); score != nil {
weight = score.Weight
}
// Weight is incorporated into the priority index key only (not sender index)
// so we must fetch it here from the scores map.
if i.mempool.cfg.TxPriority.Compare(weight, nextElem.Key().(txMeta[C]).weight) < 0 {
Expand Down

0 comments on commit fd126e9

Please sign in to comment.