Documentation
¶
Index ¶
Constants ¶
const Chain = "evm"
Chain is the identifier for EVM chains.
Variables ¶
var ErrReorgDetected = errors.New("reorg detected")
ErrReorgDetected signals that the chain rewound; caller should restart from the updated cursor.
Functions ¶
Types ¶
type BlockClient ¶
type BlockClient interface {
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
}
BlockClient captures the subset of ethclient used by the scanner.
type NormalizedEvent ¶
type NormalizedEvent struct {
Chain string
SourceID string
RuleID string
Height uint64
Hash string
TxHash string
LogIndex *uint
Contract string
Name string
Args map[string]any
}
NormalizedEvent represents a decoded on-chain event in a uniform shape.
type RPCClient ¶
RPCClient is a thin wrapper over ethclient.Client that satisfies BlockClient.
func NewRPCClient ¶
NewRPCClient builds an RPC client to an EVM node.
type RuleMatcher ¶
type RuleMatcher struct {
// contains filtered or unexported fields
}
RuleMatcher filters and decodes logs for a given rule.
func NewRuleMatcher ¶
NewRuleMatcher builds a matcher for a log rule using available ABIs. Supports only log rules.
func (*RuleMatcher) Match ¶
func (m *RuleMatcher) Match(log types.Log) (*NormalizedEvent, bool, error)
Match checks the log against the matcher; returns a normalized event on success.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner processes blocks sequentially with confirmation safety.
func NewScanner ¶
func NewScanner(client BlockClient, store *storage.Store, source config.Source, confirmations uint64, abis map[string]*abi.ABI, rules []config.Rule) (*Scanner, error)
NewScanner builds a scanner for a given source and its log rules.
func (*Scanner) ProcessNext ¶
func (s *Scanner) ProcessNext(ctx context.Context) ([]NormalizedEvent, error)
ProcessNext handles the next eligible block (respecting confirmations) and returns matched events. It advances the cursor on success. If a reorg is detected, ErrReorgDetected is returned after rewinding.