Documentation ¶
Index ¶
- type DB
- func (d *DB) AddUndoLog(height uint32, sql string) error
- func (d *DB) BlockCount() (count uint32, err error)
- func (d *DB) BlockHash(height ...uint32) (blockHash string, err error)
- func (d *DB) CreateBlockInfo(block *tables.BlockParserInfo) error
- func (d *DB) CreateInscribeOrder(order *tables.InscribeOrder) error
- func (d *DB) DeleteBlockInfo(height uint32) error
- func (d *DB) DeleteSavepoint(id uint64) error
- func (d *DB) DeleteUndoLog() error
- func (d *DB) FindInscribeOrdersByReceiveAddress(address string, page, limit int) (orders []*tables.InscribeOrder, total int64, err error)
- func (d *DB) FindUndoLog() (*sql.Rows, error)
- func (d *DB) GetInscribeOrderByOrderId(orderId string) (order tables.InscribeOrder, err error)
- func (d *DB) GetInscribeOrdersByRevealAddress(address string) (order tables.InscribeOrder, err error)
- func (d *DB) ListSavepoint() (list []*tables.SavePoint, err error)
- func (d *DB) OldestSavepoint() (savepoint *tables.SavePoint, err error)
- func (d *DB) Transaction(fn func(tx *DB) error) error
- func (d *DB) UpdateInscribeOrderStatus(height uint32, newOrder *tables.InscribeOrder) error
- type DBOption
- type DBOptions
- type GormLogger
- func (g *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
- func (g *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
- func (g *GormLogger) LogMode(level logger.LogLevel) logger.Interface
- func (g *GormLogger) Print(data ...interface{})
- func (g *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (g *GormLogger) Warn(ctx context.Context, msg string, data ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
DB is a struct that embeds gorm.DB to provide additional database functionality.
func (*DB) AddUndoLog ¶
AddUndoLog is a method that adds an undo log to the database. It takes two parameters: height of type uint32 and sql of type string. The height parameter represents the height of the undo log. The sql parameter represents the SQL statement of the undo log.
The method first calls the OldestSavepoint method to get the oldest savepoint. If an error occurs during this operation, it returns the error. If the ID of the oldest savepoint is 0, it returns nil.
The method then creates a new UndoLog struct with the provided height and SQL statement, and calls the Create method to add the undo log to the database. If an error occurs during this operation, it returns the error.
The method returns an error if any operation fails, or nil if the operations succeed.
func (*DB) BlockCount ¶
BlockCount retrieves the total number of blocks in the database. It returns the count as an uint32 and any error encountered.
func (*DB) CreateBlockInfo ¶
func (d *DB) CreateBlockInfo(block *tables.BlockParserInfo) error
func (*DB) CreateInscribeOrder ¶
func (d *DB) CreateInscribeOrder(order *tables.InscribeOrder) error
func (*DB) DeleteBlockInfo ¶
func (*DB) DeleteSavepoint ¶
DeleteSavepoint is a method that deletes all savepoints from the database. It returns an error. The method creates a new SavePoint struct and uses its TableName method to get the name of the table. It then uses the Exec method of the DB struct to execute a SQL delete statement on the table. If an error occurs during the deletion, it returns the error.
func (*DB) DeleteUndoLog ¶
DeleteUndoLog is a method that deletes all undo logs from the database. It returns an error. The method creates a new UndoLog struct and uses its TableName method to get the name of the table. It then uses the Exec method of the DB struct to execute a SQL delete statement on the table. If an error occurs during the deletion, it returns the error.
func (*DB) FindInscribeOrdersByReceiveAddress ¶
func (*DB) FindUndoLog ¶
FindUndoLog is a method that retrieves all undo logs from the database in descending order of their IDs. It returns a slice of pointers to UndoLog structs and an error. The method uses the Order method of the DB struct to order the undo logs by their IDs in descending order. It then uses the Find method of the DB struct to retrieve the undo logs and assigns them to undoLogs. If an error occurs during the retrieval, it returns the undoLogs and the error.
func (*DB) GetInscribeOrderByOrderId ¶
func (d *DB) GetInscribeOrderByOrderId(orderId string) (order tables.InscribeOrder, err error)
func (*DB) GetInscribeOrdersByRevealAddress ¶
func (d *DB) GetInscribeOrdersByRevealAddress(address string) (order tables.InscribeOrder, err error)
func (*DB) ListSavepoint ¶
ListSavepoint is a method that retrieves a list of all savepoints from the database. It returns a slice of pointers to SavePoint structs and an error. The method uses the Find method of the DB struct to retrieve the savepoints and assigns them to the list. If an error occurs during the retrieval, it checks if the error is a ErrRecordNotFound error from the gorm package. If it is, it assigns nil to the error, effectively ignoring the error. The method then returns the list of savepoints and the error.
func (*DB) OldestSavepoint ¶
OldestSavepoint is a method that retrieves the oldest savepoint from the database. It returns a pointer to a SavePoint struct and an error. The method uses the First method of the DB struct to retrieve the oldest savepoint and assigns it to savepoint. If an error occurs during the retrieval, it returns the savepoint and the error.
func (*DB) Transaction ¶
Transaction is a method on DB that executes a function within a database transaction.
func (*DB) UpdateInscribeOrderStatus ¶
func (d *DB) UpdateInscribeOrderStatus(height uint32, newOrder *tables.InscribeOrder) error
type DBOption ¶
type DBOption func(*DBOptions)
DBOption is a function type that modifies DBOptions.
func WithAutoMigrateTables ¶
func WithAutoMigrateTables(tables ...interface{}) DBOption
WithAutoMigrateTables returns a DBOption that sets the tables to be auto migrated in the database.
func WithDBName ¶
WithDBName returns a DBOption that sets the name of the database.
func WithPassword ¶
WithPassword returns a DBOption that sets the password of the database.
type DBOptions ¶
type DBOptions struct {
// contains filtered or unexported fields
}
DBOptions is a struct that holds the configuration options for the database.
type GormLogger ¶
GormLogger is a struct that embeds btclog.Logger to provide additional logging functionality.
func (*GormLogger) Error ¶
func (g *GormLogger) Error(ctx context.Context, msg string, data ...interface{})
Error is a method on GormLogger that logs an error message.
func (*GormLogger) Info ¶
func (g *GormLogger) Info(ctx context.Context, msg string, data ...interface{})
Info is a method on GormLogger that logs an informational message.
func (*GormLogger) LogMode ¶
func (g *GormLogger) LogMode(level logger.LogLevel) logger.Interface
LogMode is a method on GormLogger that sets the log level.
func (*GormLogger) Print ¶
func (g *GormLogger) Print(data ...interface{})