Documentation
¶
Index ¶
- Constants
- type Event
- type EventCriteria
- type EventFilter
- type LogDB
- func (db *LogDB) Close() (err error)
- func (db *LogDB) EnableMetrics()
- func (db *LogDB) FilterEvents(ctx context.Context, filter *EventFilter) ([]*Event, error)
- func (db *LogDB) FilterTransfers(ctx context.Context, filter *TransferFilter) ([]*Transfer, error)
- func (db *LogDB) HasBlockID(id thor.Bytes32) (bool, error)
- func (db *LogDB) NewWriter() *Writer
- func (db *LogDB) NewWriterSyncOff() *Writer
- func (db *LogDB) NewestBlockID() (thor.Bytes32, error)
- func (db *LogDB) Path() string
- type Options
- type Order
- type Range
- type Transfer
- type TransferCriteria
- type TransferFilter
- type Writer
Constants ¶
const (
MaxBlockNumber = blockNumMask
)
Adjust these constants based on your bit allocation requirements 64th bit is the sign bit so we have 63 bits to use
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event struct {
BlockNumber uint32
LogIndex uint32
BlockID thor.Bytes32
BlockTime uint64
TxID thor.Bytes32
TxIndex uint32
TxOrigin thor.Address // contract caller
ClauseIndex uint32
Address thor.Address // always a contract address
Topics [5]*thor.Bytes32
Data []byte
}
Event represents tx.Event that can be stored in db.
type EventCriteria ¶
type EventFilter ¶
type EventFilter struct {
CriteriaSet []*EventCriteria
Range *Range
Options *Options
Order Order // default asc
}
EventFilter filter
type LogDB ¶
type LogDB struct {
// contains filtered or unexported fields
}
func NewMem ¶
NewMem create a log db in ram. Unlike the file-based database, this implementation: 1. Uses synchronous=off for faster writes in memory 2. Uses a single connection with minimal transaction overhead 3. Optimizes for in-memory performance Note: In-memory database uses cache=shared so all connections share data
func (*LogDB) EnableMetrics ¶ added in v2.4.4
func (db *LogDB) EnableMetrics()
EnableMetrics registers a pull collector exporting the readDB connection pool stats, sampled on scrape at most once per readDBStatsSampleInterval. No-op unless Prometheus is initialized; call once per LogDB.
func (*LogDB) FilterEvents ¶
func (*LogDB) FilterTransfers ¶
func (*LogDB) HasBlockID ¶
HasBlockID query whether given block id related logs were written. Uses writeDB since this is called during write operations.
func (*LogDB) NewWriterSyncOff ¶
NewWriterSyncOff creates a log writer which applied 'pragma synchronous = off'.
func (*LogDB) NewestBlockID ¶
NewestBlockID query newest written block id. Uses writeDB since this is called during write operations.
type Transfer ¶
type Transfer struct {
BlockNumber uint32
LogIndex uint32
BlockID thor.Bytes32
BlockTime uint64
TxID thor.Bytes32
TxIndex uint32
TxOrigin thor.Address
ClauseIndex uint32
Sender thor.Address
Recipient thor.Address
Amount *big.Int
}
Transfer represents tx.Transfer that can be stored in db.
type TransferCriteria ¶
type TransferFilter ¶
type TransferFilter struct {
CriteriaSet []*TransferCriteria
Range *Range
Options *Options
Order Order // default asc
}
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is the transactional log writer.
func (*Writer) Truncate ¶
Truncate truncates the database by deleting logs after blockNum (included).
func (*Writer) UncommittedCount ¶
UncommittedCount returns the count of uncommitted logs.