sql

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package sql provides a SQL database-backed implementation of the NonceManager interface. It uses database transactions and row-level locking to ensure atomic nonce allocation even under high concurrency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SQLBackedNonceManager

type SQLBackedNonceManager struct {
	// contains filtered or unexported fields
}

SQLBackedNonceManager implements NonceManager using a SQL database for persistence. It provides thread-safe nonce allocation with configurable concurrency limits.

func NewSQLBackedNonceManager

func NewSQLBackedNonceManager(db *db.Handler, logger *zap.Logger) *SQLBackedNonceManager

NewSQLBackedNonceManager creates a new SQL-backed nonce manager with default concurrency settings

func (*SQLBackedNonceManager) FastForwardNonce

func (s *SQLBackedNonceManager) FastForwardNonce(ctx context.Context, nonce big.Int) error

FastForwardNonce sets the nonce sequence to start from the given value and removes all nonces below it. This is typically used when recovering from blockchain state issues.

func (*SQLBackedNonceManager) GetNonce

GetNonce atomically reserves the next available nonce from the database. It uses SELECT FOR UPDATE SKIP LOCKED to ensure no two transactions see the same nonce. The transaction stays open until Cancel() (rollback) or Consume() (delete + commit).

func (*SQLBackedNonceManager) Replenish

func (s *SQLBackedNonceManager) Replenish(ctx context.Context, nonce big.Int) error

Replenish ensures a sufficient number of nonces are available starting from the given nonce. It generates up to 10,000 nonces in a single batch operation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL