Documentation ¶
Index ¶
- func RunMigrations(driverName string, db *sql.DB, direction migrate.MigrationDirection) error
- type AddressMeddler
- type BigIntMeddler
- type HashMeddler
- type SqlStorage
- func (s *SqlStorage) Add(_ context.Context, mTx types.MonitoredTx) error
- func (s *SqlStorage) Empty(ctx context.Context) error
- func (s *SqlStorage) Get(_ context.Context, id common.Hash) (types.MonitoredTx, error)
- func (s *SqlStorage) GetByBlock(ctx context.Context, fromBlock, toBlock *uint64) ([]types.MonitoredTx, error)
- func (s *SqlStorage) GetByStatus(_ context.Context, statuses []types.MonitoredTxStatus) ([]types.MonitoredTx, error)
- func (s *SqlStorage) Remove(ctx context.Context, id common.Hash) error
- func (s *SqlStorage) Update(ctx context.Context, mTx types.MonitoredTx) error
- type TimeRFC3339Meddler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RunMigrations ¶
RunMigrations applies database migrations in the specified direction (up or down).
Types ¶
type AddressMeddler ¶
type AddressMeddler struct{}
AddressMeddler encodes or decodes the field value to or from JSON.
func (AddressMeddler) PostRead ¶
func (m AddressMeddler) PostRead(fieldPtr, scanTarget interface{}) error
PostRead is called after a Scan operation for fields that have the AddressMeddler.
func (AddressMeddler) PreRead ¶
func (m AddressMeddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)
PreRead is called before a Scan operation for fields that have the AddressMeddler.
func (AddressMeddler) PreWrite ¶
func (m AddressMeddler) PreWrite(fieldPtr interface{}) (saveValue interface{}, err error)
PreWrite is called before an Insert or Update operation for fields that have the AddressMeddler.
type BigIntMeddler ¶
type BigIntMeddler struct{}
BigIntMeddler encodes or decodes a *big.Int field to/from a string, handling both decimal and hexadecimal representations.
func (BigIntMeddler) PostRead ¶
func (m BigIntMeddler) PostRead(fieldPtr, scanTarget interface{}) error
PostRead is called after a Scan operation for fields that have the BigIntMeddler. It converts the sql.NullString or NULL from the database into a *big.Int.
func (BigIntMeddler) PreRead ¶
func (m BigIntMeddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)
PreRead is called before a Scan operation for fields that have the BigIntMeddler. It gives a pointer to a string buffer to grab the raw data from the database.
func (BigIntMeddler) PreWrite ¶
func (m BigIntMeddler) PreWrite(fieldPtr interface{}) (saveValue interface{}, err error)
PreWrite is called before an Insert or Update operation for fields that have the BigIntMeddler. It converts the *big.Int field into a string for storage in the database or returns nil for NULL.
type HashMeddler ¶
type HashMeddler struct{}
HashMeddler encodes or decodes the field value to or from string
func (HashMeddler) PostRead ¶
func (m HashMeddler) PostRead(fieldPtr, scanTarget interface{}) error
PostRead is called after a Scan operation for fields that have the HashMeddler
func (HashMeddler) PreRead ¶
func (m HashMeddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)
PreRead is called before a Scan operation for fields that have the HashMeddler
func (HashMeddler) PreWrite ¶
func (m HashMeddler) PreWrite(fieldPtr interface{}) (saveValue interface{}, err error)
PreWrite is called before an Insert or Update operation for fields that have the HashMeddler
type SqlStorage ¶
type SqlStorage struct {
// contains filtered or unexported fields
}
SqlStorage encapsulates logic for MonitoredTx CRUD operations.
func NewStorage ¶
func NewStorage(driverName, dbPath string) (*SqlStorage, error)
NewStorage creates and returns a new instance of SqlStorage with the given database path. It first opens a connection to the SQLite database and then runs the necessary migrations. If any error occurs during the database connection or migration process, it returns an error.
func (*SqlStorage) Add ¶
func (s *SqlStorage) Add(_ context.Context, mTx types.MonitoredTx) error
Add persist a monitored transaction into the SQL database.
func (*SqlStorage) Empty ¶
func (s *SqlStorage) Empty(ctx context.Context) error
Empty clears all the records from the monitored_txs table.
func (*SqlStorage) Get ¶
func (s *SqlStorage) Get(_ context.Context, id common.Hash) (types.MonitoredTx, error)
Get retrieves a monitored transaction from the database by its ID. If the transaction is not found, it returns an ErrNotFound error.
func (*SqlStorage) GetByBlock ¶
func (s *SqlStorage) GetByBlock(ctx context.Context, fromBlock, toBlock *uint64) ([]types.MonitoredTx, error)
GetByBlock loads all monitored transactions that have the blockNumber between fromBlock and toBlock.
func (*SqlStorage) GetByStatus ¶
func (s *SqlStorage) GetByStatus(_ context.Context, statuses []types.MonitoredTxStatus) ([]types.MonitoredTx, error)
GetByStatus retrieves monitored transactions from the database that match the provided statuses. If no statuses are provided, it returns all transactions. The transactions are ordered by their creation date (oldest first).
func (*SqlStorage) Remove ¶
Remove deletes a monitored transaction from the database by its ID. If the transaction does not exist, it returns an ErrNotFound error.
func (*SqlStorage) Update ¶
func (s *SqlStorage) Update(ctx context.Context, mTx types.MonitoredTx) error
Update a persisted monitored tx
type TimeRFC3339Meddler ¶
type TimeRFC3339Meddler struct{}
TimeRFC3339Meddler encodes or decodes time.Time to/from a consistent RFC3339 format for the database.
func (TimeRFC3339Meddler) PostRead ¶
func (m TimeRFC3339Meddler) PostRead(fieldPtr, scanTarget interface{}) error
PostRead is called after a Scan operation for fields that have the TimeRFC3339Meddler.
func (TimeRFC3339Meddler) PreRead ¶
func (m TimeRFC3339Meddler) PreRead(fieldAddr interface{}) (scanTarget interface{}, err error)
PreRead is called before a Scan operation for fields that have the TimeRFC3339Meddler.
func (TimeRFC3339Meddler) PreWrite ¶
func (m TimeRFC3339Meddler) PreWrite(fieldPtr interface{}) (saveValue interface{}, err error)
PreWrite is called before an Insert or Update operation for fields that have the TimeRFC3339Meddler.