Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfigSet = Config{ PollPeriod: 5 * time.Second, PageSize: 100, LogPollerStartingLookback: 24 * time.Hour, BlockTime: 2500 * time.Millisecond, }
Functions ¶
This section is empty.
Types ¶
type FilterStore ¶
type FilterStore interface {
// RegisterFilter adds a new filter or overwrites an existing one with the same name.
RegisterFilter(ctx context.Context, flt types.Filter) error
// UnregisterFilter removes a filter by its unique name.
UnregisterFilter(ctx context.Context, name string) error
// HasFilter checks if a filter with the given name exists.
HasFilter(ctx context.Context, name string) (bool, error)
// GetDistinctAddresses returns a slice of unique addresses that are being monitored.
GetDistinctAddresses(ctx context.Context) ([]*address.Address, error)
// GetFiltersForAddressAndMsgType returns filters for a specific address and message type.
GetFiltersForAddressAndMsgType(ctx context.Context, addr *address.Address, msgType tlb.MsgType) ([]types.Filter, error)
}
FilterStore defines an interface for storing and retrieving log filter specifications.
type LogStore ¶
type LogStore interface {
SaveLog(log types.Log)
// GetLogs retrieves raw logs for a given address and event signature without any parsing or filtering.
// This is a simple method that returns the raw cell data for further processing.
GetLogs(srcAddr *address.Address, sig uint32) ([]types.Log, error)
}
LogStore defines the interface for storing and retrieving logs.
type QueryBuilder ¶
type QueryBuilder[T any] interface { // WithSource sets the TON contract address to filter logs by. WithSource(addr *address.Address) QueryBuilder[T] // WithEventSig sets the event signature (topic or opcode) to filter logs by. WithEventSig(sig uint32) QueryBuilder[T] // SkipBytes advances the internal byte cursor, ignoring a specified number of bytes. SkipBytes(bytes uint) QueryBuilder[T] // FilterBytes applies conditions to the next `sizeInBytes` at the current cursor position, // then advances the cursor. FilterBytes(sizeInBytes uint, conditions ...query.Condition) QueryBuilder[T] // FilterTyped adds a high-level filter function that operates on the parsed event data. FilterTyped(filter func(T) bool) QueryBuilder[T] // Limit sets the maximum number of results to return. Limit(limit int) QueryBuilder[T] // Offset sets the number of results to skip from the beginning. Offset(offset int) QueryBuilder[T] // OrderBy specifies the sorting order for the results. OrderBy(field query.SortField, order query.SortOrder) QueryBuilder[T] // Execute runs the constructed query and returns the results. Execute(ctx context.Context, store LogStore) (query.Result[T], error) }
QueryBuilder defines the interface for constructing and executing log queries. The generic type T represents the expected event structure that logs will be parsed into.
func NewQuery ¶
func NewQuery[T any]() QueryBuilder[T]
NewQuery creates a new query builder for constructing log queries with two-phase filtering. It initializes a query builder for a specific event type T with the given source address and event signature.
Parameters:
- srcAddress: The source contract address to filter logs by (required). This specifies which contract's logs to search through.
- eventSig: The event signature (topic or opcode) to filter logs by (required). This identifies the specific type of event/message to look for in the logs.
Returns a QueryBuilder[T] that can be further configured with additional filters, sorting, and pagination options before execution.
type Service ¶
type Service interface {
services.Service
RegisterFilter(ctx context.Context, flt types.Filter) error
UnregisterFilter(ctx context.Context, name string) error
HasFilter(ctx context.Context, name string) (bool, error)
GetStore() LogStore
Replay(ctx context.Context, fromBlock uint32) error
}
Service defines the public interface for the TON log polling service.
func NewService ¶
func NewService(lggr logger.Logger, opts *ServiceOptions) Service
NewService creates a new TON log polling service instance
type ServiceOptions ¶
type ServiceOptions struct {
Config Config
Client ton.APIClientWrapped
Filters FilterStore
TxLoader TxLoader
TxParser TxParser
Store LogStore
}
type TxLoader ¶
type TxLoader interface {
// LoadTxsForAddresses retrieves all transactions from the specified source addresses
// within the given block range (prevBlock, toBlock] - exclusive of prevBlock, inclusive of toBlock.
LoadTxsForAddresses(ctx context.Context, blockRange *types.BlockRange, srcAddrs []*address.Address) ([]types.TxWithBlock, error)
}
TxLoader defines the interface for loading transactions from the TON blockchain.
type TxParser ¶
type TxParser interface {
// It processes transactions by examining their messages, applying registered filters, and extracting
// relevant event data. The parser handles different message types (internal, external out) and
// extracts event signatures (opcodes for internal messages, topics for external out messages)
// along with the message body data to create structured log entries.
ParseTransactions(ctx context.Context, txs []types.TxWithBlock) ([]types.Log, error)
}
TxParser defines the interface for parsing raw blockchain transactions into structured logs.