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 *sql.DB, logger *zap.Logger) *SQLBackedNonceManager
NewSQLBackedNonceManager creates a new SQL-backed nonce manager with default concurrency settings
func (*SQLBackedNonceManager) FastForwardNonce ¶
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 ¶
func (s *SQLBackedNonceManager) GetNonce(ctx context.Context) (*noncemanager.NonceContext, error)
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).