indexer

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: GPL-3.0, GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomIndexer

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

BloomIndexer implements a core.ChainIndexer, building up a rotated bloom bits index for the Ethereum header bloom filters, permitting blazing fast filtering.

func (*BloomIndexer) Commit

func (b *BloomIndexer) Commit() error

Commit implements core.ChainIndexerBackend, finalizing the bloom section and writing it out into the database.

func (*BloomIndexer) Process

func (b *BloomIndexer) Process(ctx context.Context, header *types.Header) error

Process implements core.ChainIndexerBackend, adding a new header's bloom into the index.

func (*BloomIndexer) Prune

func (b *BloomIndexer) Prune(threshold uint64) error

Prune returns an empty error since we don't support pruning here.

func (*BloomIndexer) Reset

func (b *BloomIndexer) Reset(ctx context.Context, section uint64, lastSectionHead common.Hash) error

Reset implements core.ChainIndexerBackend, starting a new bloombits index section.

type ChainIndexer

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

ChainIndexer does a post-processing job for equally sized sections of the canonical chain (like BlooomBits and CHT structures). A ChainIndexer is connected to the blockchain through the event system by starting a ChainHeadEventLoop in a goroutine.

Further child ChainIndexers can be added which use the output of the parent section indexer. These child indexers receive new head notifications only after an entire section has been finished or in case of rollbacks that might affect already finished sections.

func NewBloomIndexer

func NewBloomIndexer(db ethdb.Database, size, confirms uint64) *ChainIndexer

NewBloomIndexer returns a chain indexer that generates bloom bits data for the canonical chain for fast logs filtering.

func NewChainIndexer

func NewChainIndexer(chainDb ethdb.Database, indexDb ethdb.Database, backend abstract.ChainIndexerBackend, section, confirm uint64, throttling time.Duration, kind string) *ChainIndexer

NewChainIndexer creates a new chain indexer to do background processing on chain segments of a given size after certain number of confirmations passed. The throttling parameter might be used to prevent database thrashing.

func (*ChainIndexer) AddCheckpoint

func (c *ChainIndexer) AddCheckpoint(section uint64, shead common.Hash)

AddCheckpoint adds a checkpoint. Sections are never processed and the chain is not expected to be available before this point. The indexer assumes that the backend has sufficient information available to process subsequent sections.

Note: knownSections == 0 and storedSections == checkpointSections until syncing reaches the checkpoint

func (*ChainIndexer) AddChildIndexer

func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer)

AddChildIndexer adds a child ChainIndexer that can use the output of this one

func (*ChainIndexer) Close

func (c *ChainIndexer) Close() error

Close tears down all goroutines belonging to the indexer and returns any error that might have occurred internally.

func (*ChainIndexer) Prune

func (c *ChainIndexer) Prune(threshold uint64) error

Prune deletes all chain data older than given threshold.

func (*ChainIndexer) SectionHead

func (c *ChainIndexer) SectionHead(section uint64) common.Hash

SectionHead retrieves the last block hash of a processed section from the index database.

func (*ChainIndexer) Sections

func (c *ChainIndexer) Sections() (uint64, uint64, common.Hash)

Sections returns the number of processed sections maintained by the indexer and also the information about the last header indexed for potential canonical verifications.

func (*ChainIndexer) Start

func (c *ChainIndexer) Start(chain abstract.ChainIndexerChain)

Start creates a goroutine to feed chain head events into the indexer for cascading background processing. Children do not need to be started, they are notified about new events by their parents.

Jump to

Keyboard shortcuts

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