Documentation ¶
Index ¶
- func SqlFix(sql string, args ...string) string
- 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) BlockHeader() (height uint32, header *wire.BlockHeader, err error)
- func (d *DB) BlockHeight() (height uint32, err error)
- func (d *DB) CreateInscription(ins *tables.Inscriptions) error
- func (d *DB) DelSatRangesByOutpoint(height uint32, outpoint string) (satRange tables.OutpointSatRange, err error)
- func (d *DB) DeleteBlockInfoByHeight(height uint32) (info tables.BlockInfo, err error)
- func (d *DB) DeleteBySatPoint(height uint32, satpoint *tables.SatPointToSequenceNum) error
- func (d *DB) DeleteInscriptionById(height uint32, inscriptionId *tables.InscriptionId) (sequenceNum int64, err error)
- func (d *DB) DeleteMockInscriptions() error
- func (d *DB) DeleteMockProtocol() error
- func (d *DB) DeleteSavepoint(id uint64) error
- func (d *DB) DeleteUndoLog() error
- func (d *DB) DeleteValueByOutpoint(height uint32, outpoints ...string) (err error)
- func (d *DB) EmbedDB() bool
- func (d *DB) FindHoldersByTkId(tkid, protocol, operator string, page, pageSize int) (list []*FindHoldersByTkIdResp, err error)
- func (d *DB) FindInscriptionsByPage(page, size int) (list []*tables.InscriptionId, err error)
- func (d *DB) FindInscriptionsInBlock(height uint32) (list []*model.OutPoint, err error)
- func (d *DB) FindInscriptionsInBlockPage(height, page, size int) (list []*model.OutPoint, err error)
- func (d *DB) FindMintHistoryByTkId(tkid, protocol, operator string, page, pageSize int) (list []*FindMintHistoryByTkIdResp, err error)
- func (d *DB) FindProtocol(protocol, ticker, operator string, tkid ...string) (list []*tables.Protocol, err error)
- func (d *DB) FindTokenPageByTicker(protocol, ticker, operator string, page, pageSize int) (list []*tables.Protocol, err error)
- func (d *DB) FindUndoLog() (*sql.Rows, error)
- func (d *DB) FirstInscriptionByOwner(owner string) (firts tables.Inscriptions, err error)
- func (d *DB) GetInscriptionById(inscriptionId *tables.InscriptionId) (ins tables.Inscriptions, err error)
- func (d *DB) GetInscriptionByInscriptionNum(inscriptionNum int64) (ins tables.Inscriptions, err error)
- func (d *DB) GetInscriptionByOutpoint(outpoint *model.OutPoint) (list []*tables.InscriptionId, err error)
- func (d *DB) GetInscriptionBySequenceNum(sequenceNum int64) (ins tables.Inscriptions, err error)
- func (d *DB) GetProtocolByInscriptionId(inscriptionId *tables.InscriptionId) (p tables.Protocol, err error)
- func (d *DB) GetSatPointBySat(sat uint64) (res tables.SatSatPoint, err error)
- func (d *DB) GetStatisticCountByName(name tables.StatisticType) (count uint64, err error)
- func (d *DB) GetValueByOutpoint(outpoint string) (value int64, err error)
- func (d *DB) IncrementStatistic(height uint32, name tables.StatisticType, count uint64) error
- func (d *DB) InscriptionsByOutpoint(outpoint string) (res []*Inscription, err error)
- func (d *DB) InscriptionsNum() (total int64, err error)
- func (d *DB) InscriptionsStoredData() (total uint64, err error)
- func (d *DB) InscriptionsTotalFees() (total uint64, err error)
- func (d *DB) ListSavepoint() (list []*tables.SavePoint, err error)
- func (d *DB) NextSequenceNumber() (num int64, err error)
- func (d *DB) OldestSavepoint() (savepoint *tables.SavePoint, err error)
- func (d *DB) OutpointToSatRanges(outpoint string) (satRange tables.OutpointSatRange, err error)
- func (d *DB) SatToSatPoint(height uint32, satSatPoint *tables.SatSatPoint) error
- func (d *DB) SaveBlockInfo(block *tables.BlockInfo) error
- func (d *DB) SaveProtocol(height uint32, protocol *tables.Protocol) error
- func (d *DB) SaveSatToSequenceNumber(height uint32, sat uint64, sequenceNum int64) error
- func (d *DB) SearchInscriptions(params *FindProtocolsParams) (list []*tables.Inscriptions, total int64, err error)
- func (d *DB) SetOutpointToSatRange(height uint32, satRanges ...*tables.OutpointSatRange) (err error)
- func (d *DB) SetOutpointToValue(height uint32, values map[string]int64) (err error)
- func (d *DB) SetSatPointToSequenceNum(height uint32, satPoint *tables.SatPointToSequenceNum) error
- func (d *DB) SetStatistic(height uint32, name tables.StatisticType, count uint64) error
- func (d *DB) SumAddressNum(protocol, ticker, operator string, tkid ...string) (total uint64, err error)
- func (d *DB) SumMintAmountByAddress(address, protocol string, page, pageSize int) (list []*tables.ProtocolAmount, err error)
- func (d *DB) SumProtocolAmount(protocol, ticker, operator string, tkid ...string) (total uint64, err error)
- func (d *DB) Transaction(fn func(tx *DB) error) error
- type DBOption
- func WithAddr(addr string) DBOption
- func WithAutoMigrateTables(tables ...interface{}) DBOption
- func WithDBName(dbName string) DBOption
- func WithDataDir(dir string) DBOption
- func WithEmbedDB(embed bool) DBOption
- func WithPassword(password string) DBOption
- func WithServerPort(port string) DBOption
- func WithStatusPort(port string) DBOption
- func WithUser(user string) DBOption
- type DBOptions
- type FindHoldersByTkIdResp
- type FindMintHistoryByTkIdResp
- type FindProtocolsParams
- 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{})
- type Inscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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) BlockHash ¶
BlockHash retrieves the block hash for a given block height. If no height is provided, it retrieves the hash for the last block. It returns the block hash as a string and any error encountered.
func (*DB) BlockHeader ¶
func (d *DB) BlockHeader() (height uint32, header *wire.BlockHeader, err error)
BlockHeader retrieves the block header for a given block height.
func (*DB) BlockHeight ¶
BlockHeight retrieves the height of the last block in the database.
func (*DB) CreateInscription ¶
func (d *DB) CreateInscription(ins *tables.Inscriptions) error
CreateInscription creates a new inscription in the database. It returns any error encountered.
func (*DB) DelSatRangesByOutpoint ¶
func (d *DB) DelSatRangesByOutpoint(height uint32, outpoint string) (satRange tables.OutpointSatRange, err error)
DelSatRangesByOutpoint deletes the satoshi ranges for a given outpoint.
func (*DB) DeleteBlockInfoByHeight ¶
DeleteBlockInfoByHeight deletes a block info from the database by height.
func (*DB) DeleteBySatPoint ¶
func (d *DB) DeleteBySatPoint(height uint32, satpoint *tables.SatPointToSequenceNum) error
DeleteBySatPoint deletes records by a given SatPoint. It takes a SatPoint as a parameter. It returns any error encountered during the operation.
func (*DB) DeleteInscriptionById ¶
func (d *DB) DeleteInscriptionById(height uint32, inscriptionId *tables.InscriptionId) (sequenceNum int64, err error)
DeleteInscriptionById deletes an inscription by its outpoint. It returns the sequence number of the deleted inscription and any error encountered.
func (*DB) DeleteMockInscriptions ¶
func (*DB) DeleteMockProtocol ¶
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) DeleteValueByOutpoint ¶
DeleteValueByOutpoint deletes the values associated with a list of outpoints. It returns any error encountered during the operation.
func (*DB) FindHoldersByTkId ¶
func (d *DB) FindHoldersByTkId(tkid, protocol, operator string, page, pageSize int) (list []*FindHoldersByTkIdResp, err error)
FindHoldersByTkId finds the holders for a specific TkId and protocol. It returns a list of holders and any error encountered.
func (*DB) FindInscriptionsByPage ¶
func (d *DB) FindInscriptionsByPage(page, size int) (list []*tables.InscriptionId, err error)
FindInscriptionsByPage retrieves a page of inscription IDs. It returns a list of inscription IDs and any error encountered.
func (*DB) FindInscriptionsInBlock ¶
func (*DB) FindInscriptionsInBlockPage ¶
func (d *DB) FindInscriptionsInBlockPage(height, page, size int) (list []*model.OutPoint, err error)
FindInscriptionsInBlockPage retrieves a page of inscription IDs in a block. It returns a list of inscription IDs and any error encountered.
func (*DB) FindMintHistoryByTkId ¶
func (d *DB) FindMintHistoryByTkId(tkid, protocol, operator string, page, pageSize int) (list []*FindMintHistoryByTkIdResp, err error)
FindMintHistoryByTkId finds the mint history for a specific TkId and protocol. It returns a list of mint histories and any error encountered.
func (*DB) FindProtocol ¶
func (d *DB) FindProtocol(protocol, ticker, operator string, tkid ...string) (list []*tables.Protocol, err error)
FindProtocol finds protocols based on the provided parameters. It returns a list of matching protocols and any error encountered.
func (*DB) FindTokenPageByTicker ¶
func (d *DB) FindTokenPageByTicker(protocol, ticker, operator string, page, pageSize int) (list []*tables.Protocol, err error)
FindTokenPageByTicker retrieves a page of tokens by ticker for a specific protocol. It returns a list of tokens and any error encountered.
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) FirstInscriptionByOwner ¶
func (d *DB) FirstInscriptionByOwner(owner string) (firts tables.Inscriptions, err error)
func (*DB) GetInscriptionById ¶
func (d *DB) GetInscriptionById(inscriptionId *tables.InscriptionId) (ins tables.Inscriptions, err error)
GetInscriptionById retrieves an inscription by its outpoint. It returns the inscription and any error encountered.
func (*DB) GetInscriptionByInscriptionNum ¶
func (d *DB) GetInscriptionByInscriptionNum(inscriptionNum int64) (ins tables.Inscriptions, err error)
GetInscriptionByInscriptionNum retrieves an inscription by its sequence number. It returns the inscription and any error encountered.
func (*DB) GetInscriptionByOutpoint ¶
func (d *DB) GetInscriptionByOutpoint(outpoint *model.OutPoint) (list []*tables.InscriptionId, err error)
GetInscriptionByOutpoint retrieves an inscription by its outpoint.
func (*DB) GetInscriptionBySequenceNum ¶
func (d *DB) GetInscriptionBySequenceNum(sequenceNum int64) (ins tables.Inscriptions, err error)
GetInscriptionBySequenceNum retrieves an inscription by its sequence number. It returns the inscription and any error encountered.
func (*DB) GetProtocolByInscriptionId ¶
func (d *DB) GetProtocolByInscriptionId(inscriptionId *tables.InscriptionId) (p tables.Protocol, err error)
GetProtocolByInscriptionId retrieves a protocol by its outpoint. It returns the protocol and any error encountered.
func (*DB) GetSatPointBySat ¶
func (d *DB) GetSatPointBySat(sat uint64) (res tables.SatSatPoint, err error)
GetSatPointBySat retrieves a SatSatPoint by a given SAT. It takes a SAT as a parameter. It returns a SatSatPoint and any error encountered.
func (*DB) GetStatisticCountByName ¶
func (d *DB) GetStatisticCountByName(name tables.StatisticType) (count uint64, err error)
GetStatisticCountByName retrieves the count of a specific statistic by its name. It takes a name of type tables.StatisticType as a parameter. It returns the count of the statistic and any error encountered.
func (*DB) GetValueByOutpoint ¶
GetValueByOutpoint retrieves the value associated with a given outpoint. It returns the value as an int64 and any error encountered.
func (*DB) IncrementStatistic ¶
IncrementStatistic increments the count of a specific statistic by a given amount. It takes a name of type tables.StatisticType and a count of type uint32 as parameters. If the statistic does not exist, it creates a new one with the given name and count. If the statistic exists, it increments its count by the given amount. It returns any error encountered during the operation.
func (*DB) InscriptionsByOutpoint ¶
func (d *DB) InscriptionsByOutpoint(outpoint string) (res []*Inscription, err error)
InscriptionsByOutpoint retrieves inscriptions by a given outpoint. It takes an outpoint as a parameter. It returns a list of inscriptions and any error encountered.
func (*DB) InscriptionsNum ¶
func (*DB) InscriptionsStoredData ¶
func (*DB) InscriptionsTotalFees ¶
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) NextSequenceNumber ¶
NextSequenceNumber retrieves the next sequence number for inscriptions. It returns the next sequence number as an uint64 and any error encountered.
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) OutpointToSatRanges ¶
func (d *DB) OutpointToSatRanges(outpoint string) (satRange tables.OutpointSatRange, err error)
OutpointToSatRanges returns the satoshi ranges for a given outpoint.
func (*DB) SatToSatPoint ¶
func (d *DB) SatToSatPoint(height uint32, satSatPoint *tables.SatSatPoint) error
SatToSatPoint saves a SAT (Satisfiability) to a sequence number in the database.
func (*DB) SaveBlockInfo ¶
SaveBlockInfo saves a block info to the database. If a block with the same height already exists, it updates the existing record. It returns any error encountered.
func (*DB) SaveProtocol ¶
SaveProtocol saves a protocol to the database. It returns any error encountered during the operation.
func (*DB) SaveSatToSequenceNumber ¶
SaveSatToSequenceNumber saves a SAT (Satisfiability) to a sequence number in the database. It takes a SAT and a sequence number as parameters, both of type uint64. It returns any error encountered during the operation.
func (*DB) SearchInscriptions ¶
func (d *DB) SearchInscriptions(params *FindProtocolsParams) (list []*tables.Inscriptions, total int64, err error)
func (*DB) SetOutpointToSatRange ¶
func (d *DB) SetOutpointToSatRange(height uint32, satRanges ...*tables.OutpointSatRange) (err error)
SetOutpointToSatRange sets the satoshi range for a set of outpoints. It takes a map where the keys are outpoints and the values are the corresponding satoshi ranges. It returns any error encountered during the operation.
func (*DB) SetOutpointToValue ¶
SetOutpointToValue sets the values for a set of outpoints. It takes a map where the keys are outpoints and the values are the corresponding values. It returns any error encountered during the operation.
func (*DB) SetSatPointToSequenceNum ¶
func (d *DB) SetSatPointToSequenceNum(height uint32, satPoint *tables.SatPointToSequenceNum) error
SetSatPointToSequenceNum sets a SatPoint to a sequence number in the database. It takes a SatPoint and a sequence number as parameters. It returns any error encountered during the operation.
func (*DB) SetStatistic ¶
SetStatistic sets the count of a specific statistic to a given amount.
func (*DB) SumAddressNum ¶
func (d *DB) SumAddressNum(protocol, ticker, operator string, tkid ...string) (total uint64, err error)
SumAddressNum counts the number of distinct addresses for a specific protocol. It returns the total count and any error encountered.
func (*DB) SumMintAmountByAddress ¶
func (d *DB) SumMintAmountByAddress(address, protocol string, page, pageSize int) (list []*tables.ProtocolAmount, err error)
SumMintAmountByAddress sums the amount for a specific address and protocol. It returns a list of protocol amounts and any error encountered.
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 WithDataDir ¶
WithDataDir returns a DBOption that sets the data directory of the database.
func WithEmbedDB ¶
WithEmbedDB returns a DBOption that sets whether to use an embedded database or not.
func WithPassword ¶
WithPassword returns a DBOption that sets the password of the database.
func WithServerPort ¶
WithServerPort returns a DBOption that sets the server port of the database.
func WithStatusPort ¶
WithStatusPort returns a DBOption that sets the status port 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 FindHoldersByTkIdResp ¶
type FindHoldersByTkIdResp struct { Amount uint64 `gorm:"column:amount" json:"amount"` // The amount held by the holder Address string `gorm:"column:address" json:"address"` // The address of the holder }
FindHoldersByTkIdResp is a struct that represents the response for finding holders by TkId.
type FindMintHistoryByTkIdResp ¶
type FindMintHistoryByTkIdResp struct { tables.InscriptionId `gorm:"embedded" json:"inscription_id"` Amount uint64 `gorm:"column:amount" json:"amount"` // The amount of the mint To string `gorm:"column:to" json:"to_address"` // The address to which the mint was made Miner string `gorm:"column:miner" json:"miner"` // The miner of the mint }
FindMintHistoryByTkIdResp is a struct that represents the response for finding mint history by TkId.
type FindProtocolsParams ¶
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{})
type Inscription ¶
type Inscription struct { *tables.Inscriptions *tables.SatPointToSequenceNum }
Inscription is a struct that embeds tables.Inscriptions and util.SatPoint.