Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlobStore ¶
type BlobStore interface {
// Read returns the data stored under key. A missing key returns (nil, nil).
Read(ctx context.Context, key string) ([]byte, error)
// Write stores data under key, replacing any existing value.
Write(ctx context.Context, key string, blob []byte) error
// Move atomically transfers data from srcKey to dstKey, replacing any
// existing value under dstKey.
Move(ctx context.Context, srcKey, dstKey string) error
}
BlobStore provides keyed byte storage.
type ChainReader ¶
type ChainReader interface {
FilterLogs(context.Context, ethereum.FilterQuery) ([]types.Log, error)
HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
}
ChainReader provides access to Ethereum logs and block headers.
type Config ¶
type Config struct {
// MaxBlockRange is the maximum block span per backfill request.
MaxBlockRange uint64
// FinalityDepth is the block depth considered finalized.
FinalityDepth uint64
// CheckpointInterval is the minimum number of blocks between staged checkpoints.
CheckpointInterval uint64
// MaxConcurrency bounds concurrent header fetches.
MaxConcurrency int
}
Config holds the indexer's tunables.
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
FileStore implements BlobStore using files in a directory.
func NewFileStore ¶
NewFileStore creates a FileStore rooted at dir.
type Filter ¶
type Filter struct {
// FromBlock is the first block to index.
FromBlock uint64
// Addresses restrict logs to the given contract addresses.
// See [ethereum.FilterQuery.Addresses].
Addresses []common.Address
// Topics restrict logs by indexed event topics.
// See [ethereum.FilterQuery.Topics].
Topics [][]common.Hash
}
Filter specifies which logs the indexer fetches.
type Handler ¶
type Handler interface {
// Filter specifies which logs the indexer fetches.
Filter() Filter
// Snapshot returns the current handler state.
Snapshot(context.Context) ([]byte, error)
// Restore restores a previously captured state.
Restore(context.Context, []byte) error
// Process applies matching logs in block order.
Process(context.Context, []types.Log) error
}
Handler defines the application-specific indexing logic.
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
Indexer indexes Ethereum logs from a finalized block onward, handling reorgs and checkpointing.
func OpenContext ¶
OpenContext returns an Indexer synced to the finalized head.
type Options ¶
type Options struct {
// Client provides access to Ethereum logs and block headers.
Client ChainReader
// Handler receives logs and owns the indexed state.
Handler Handler
// Store persists checkpoints and cached log batches.
Store BlobStore
// LogFunc receives indexer log events.
LogFunc func(msg string, args ...any)
Config Config
}
Options configures an Indexer.
Click to show internal directories.
Click to hide internal directories.