indexer

package
v0.0.0-...-fead75b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

README

indexer

This package is responsible of indexing events and txs based on the configuration input.

Package entrypoint : Run

This function checks for registered configurations and starts an indexing process for each of those configurations.

  • Configurations are based on the app_name field and are mapped to a hash of their content.
  • When a configuration is updated - the hash for the name changes - the indexer for that configuration is updated. You don't loose previous configuration hash but it will stop indexing for new events / txs.
  • An indexer subprocess starts at block starting_block and pull data from the synchronizer process.
  • For each block, the indexer checks if their are events / txs related to the given configuration
  • When data related to the configuration is found, events are dispatched through dispatcher package and block is stored as related - when you restart this indexer it will only pickup blocks where related data exists.

indexer.go

All indexing logic

snapshot.go

Code to store configuration snapshot (the blocks where contract have data related from the contract to index.)

blocks.go

Helper functions to fetch blocks from storage and stream them into a channel.

  • iterateBlocks
  • fetchBlock
  • addMissingBlock

config.go

Helper functions to check for configuration changes and fetch configurations from storage.

  • checkConfigChange
  • fetchConfigurations
  • getConfigurationDiffs

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

Run an indexer for each app registered

Types

type ContractIndex

type ContractIndex struct {
	Blocks      []uint64
	LatestBlock uint64
}

func NewContractIndex

func NewContractIndex(startBlock uint64) *ContractIndex

func (*ContractIndex) AddBlock

func (c *ContractIndex) AddBlock(block uint64)

func (*ContractIndex) Decode

func (c *ContractIndex) Decode(buf []byte) error

func (*ContractIndex) Encode

func (c *ContractIndex) Encode() (bytes.Buffer, error)

func (*ContractIndex) SetLatestBlock

func (c *ContractIndex) SetLatestBlock(block uint64)

type Indexer

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

Single contract indexer

func NewIndexer

func NewIndexer(config config.Config, client *starknet.FeederGatewayClient, storage storage.Storage, bus dispatcher.EventDispatcher) *Indexer

func (*Indexer) Index

func (i *Indexer) Index(contract config.Contract, block starknet.GetBlockResponse) error

func (*Indexer) Start

func (i *Indexer) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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