indexer

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const BLOCK_RANGE_SIZE uint64 = 600

The indexer performs a reorg check every 60 blocks. Setting BLOCK_RANGE_SIZE to 600 (10 cycles of 60 blocks) allows us to retrieve a single page of blocks from the database, which will likely contain the reorg point.

Variables

View Source
var (
	ErrNoBlocksFound = errors.New("no blocks found")
	ErrGetBlock      = errors.New("failed to get block")
)
View Source
var (
	ErrEmptyBlockHash = errors.New("block hash is empty")
)

Functions

This section is empty.

Types

type Block added in v0.2.0

type Block struct {
	// contains filtered or unexported fields
}

type BlockTracker added in v0.1.1

type BlockTracker struct {
	// contains filtered or unexported fields
}

* BlockTracker keeps a database record of the latest block that has been indexed for a contract address and allows the user to increase the value. *

func NewBlockTracker added in v0.1.1

func NewBlockTracker(
	ctx context.Context,
	contractAddress string,
	queries *queries.Queries,
) (*BlockTracker, error)

Return a new BlockTracker initialized to the latest block from the DB

func (*BlockTracker) GetLatestBlock added in v0.1.1

func (bt *BlockTracker) GetLatestBlock() (uint64, []byte)

func (*BlockTracker) UpdateLatestBlock added in v0.1.1

func (bt *BlockTracker) UpdateLatestBlock(
	ctx context.Context,
	block uint64,
	hashBytes []byte,
) error

type ChainReorgHandler added in v0.2.0

type ChainReorgHandler interface {
	FindReorgPoint(detectedAt uint64) (uint64, []byte, error)
}

type IBlockTracker added in v0.1.1

type IBlockTracker interface {
	GetLatestBlock() (uint64, []byte)
	UpdateLatestBlock(ctx context.Context, block uint64, hash []byte) error
}

type Indexer added in v0.1.1

type Indexer struct {
	// contains filtered or unexported fields
}

func NewIndexer added in v0.1.1

func NewIndexer(
	ctx context.Context,
	log *zap.Logger,
) *Indexer

func (*Indexer) Close added in v0.1.1

func (i *Indexer) Close()

func (*Indexer) StartIndexer added in v0.1.1

func (i *Indexer) StartIndexer(
	db *sql.DB,
	cfg config.ContractsOptions,
	validationService mlsvalidate.MLSValidationService,
) error

type ReorgHandler added in v0.2.0

type ReorgHandler struct {
	// contains filtered or unexported fields
}

func NewChainReorgHandler added in v0.2.0

func NewChainReorgHandler(
	ctx context.Context,
	client blockchain.ChainClient,
	queries *queries.Queries,
) *ReorgHandler

func (*ReorgHandler) FindReorgPoint added in v0.2.0

func (r *ReorgHandler) FindReorgPoint(detectedAt uint64) (uint64, []byte, error)

TODO(borja): When reorg range has been calculated, alert clients. Tracked in https://github.com/xmtp/xmtpd/issues/437

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL