Skip to content

Commit

Permalink
Merge pull request #57 from berachain/cal/fix-foundgap
Browse files Browse the repository at this point in the history
fix(noncer): Set found gap correctly
  • Loading branch information
Devon Bear authored Jan 28, 2024
2 parents 065adeb + 68ab12b commit 1e3eeb1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions core/transactor/tracker/noncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@ func (n *Noncer) Acquire(ctx context.Context) (uint64, error) {
defer n.mu.Unlock()
val := n.inFlight.Back()

var nextNonce uint64
foundGap := false
var (
nextNonce uint64
foundGap bool
)
if val != nil {
// Iterate through the inFlight objects to ensure there are no gaps
// TODO: convert to use a binary tree to go from O(n) to O(log(n))
for i := n.latestConfirmedNonce; i <= val.Value.(*InFlightTx).Nonce(); i++ {
if n.inFlight.Get(i) == nil {
// If a gap is found, use that
nextNonce = i
foundGap = false
foundGap = true
break
}
}
Expand Down

0 comments on commit 1e3eeb1

Please sign in to comment.