indexer

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InsertBatchSize              = 1000 // Number of rows to insert in a single batch parameters_amount_per_row * InsertBatchSize <= 65535
	InsertMaxParametersPerBatch  = 65535
	SeerCrawlerLabel             string
	MOONSTREAM_DB_V3_INDEXES_URI string
	SeerCrawlerRawLabel          string
)

Functions

func BlocksTableName

func BlocksTableName(blockchain string) string

func CheckVariablesForIndexer

func CheckVariablesForIndexer() error

func InitDBConnection

func InitDBConnection()

init initializes the DBConnection variable with a new PostgreSQLpgx instance.

func IsBlockchainWithL1Chain

func IsBlockchainWithL1Chain(blockchain string) bool

func LabelsTableName

func LabelsTableName(blockchain string) string

func PrintContractSignatures

func PrintContractSignatures(abiString string) (interface{}, error)

Print contract function and event signatures from the ABI

func ReadIndicesFromFile

func ReadIndicesFromFile(filePath string) ([]interface{}, error)

ReadIndicesFromFile reads indices from a JSON file into a slice of interface{}.

func TransactionsTableName

func TransactionsTableName(blockchain string) string

func WriteIndicesToDatabase

func WriteIndicesToDatabase(blockchain string, blocks []BlockIndex) error

WriteIndicesToDatabase writes the given indices to the database

func WriteIndicesToFile

func WriteIndicesToFile(indices []interface{}, filePath string) error

Types

type AbiEntry

type AbiEntry struct {
	AbiJSON string `json:"abi"`
	Abi     *abi.ABI
	AbiName string `json:"abi_name"`
	AbiType string `json:"abi_type"`
	Once    sync.Once
}

type AbiJob

type AbiJob struct {
	ID                    string
	Address               []byte
	UserID                string
	CustomerID            string
	AbiSelector           string
	Chain                 string
	AbiName               string
	Status                string
	HistoricalCrawlStatus string
	Progress              int
	MoonwormTaskPickedup  bool
	Abi                   string
	AbiType               string
	CreatedAt             time.Time
	UpdatedAt             time.Time
	DeploymentBlockNumber *uint64
}

func FilterABIJobs

func FilterABIJobs(abiJobs []AbiJob, ids []string) []AbiJob

type AbiJobsDeployInfo

type AbiJobsDeployInfo struct {
	DeployedBlockNumber uint64
	IDs                 []string
}

type BlockCache

type BlockCache struct {
	BlockNumber    uint64
	BlockTimestamp uint64
	BlockHash      string
}

type BlockIndex

type BlockIndex struct {
	BlockNumber    uint64
	BlockHash      string
	BlockTimestamp uint64
	ParentHash     string
	RowID          uint64
	Path           string
	L1BlockNumber  uint64
	// contains filtered or unexported fields
}

func NewBlockIndex

func NewBlockIndex(chain string, blockNumber uint64, blockHash string, blockTimestamp uint64, parentHash string, row_id uint64, path string, l1BlockNumber uint64) BlockIndex

NewBlockIndex creates a new instance of BlockIndex with the chain set.

func (*BlockIndex) SetChain

func (b *BlockIndex) SetChain(chain string)

type CustomerUpdates

type CustomerUpdates struct {
	CustomerID string                          `json:"customer_id"`
	Abis       map[string]map[string]*AbiEntry `json:"abis"`
	LastBlock  uint64                          `json:"last_block"`
	Path       string                          `json:"path"`
}

type EventLabel

type EventLabel struct {
	Address         string
	BlockNumber     uint64
	BlockHash       string
	CallerAddress   string
	Label           string
	LabelName       string
	LabelType       string
	OriginAddress   string
	TransactionHash string
	LabelData       string
	BlockTimestamp  uint64
	LogIndex        uint64
}

type IndexType

type IndexType string
const (
	BlockIndexType       IndexType = "blocks"
	TransactionIndexType IndexType = "transactions"
	LogIndexType         IndexType = "logs"
)

type PostgreSQLpgx

type PostgreSQLpgx struct {
	// contains filtered or unexported fields
}
var DBConnection *PostgreSQLpgx

func NewPostgreSQLpgx

func NewPostgreSQLpgx() (*PostgreSQLpgx, error)

func NewPostgreSQLpgxWithCustomURI

func NewPostgreSQLpgxWithCustomURI(uri string) (*PostgreSQLpgx, error)

func (*PostgreSQLpgx) CleanIndexes

func (p *PostgreSQLpgx) CleanIndexes(blockchain string, batchLimit uint64, sleepTime int) error

func (*PostgreSQLpgx) Close

func (p *PostgreSQLpgx) Close()

func (*PostgreSQLpgx) CreateJobsFromAbi

func (p *PostgreSQLpgx) CreateJobsFromAbi(chain string, address string, abiFile string, customerID string, userID string, deployBlock uint64) error

func (*PostgreSQLpgx) EnsureCorrectSelectors

func (p *PostgreSQLpgx) EnsureCorrectSelectors(blockchain string, WriteToDB bool, outputFilePath string, ids []string) error

func (*PostgreSQLpgx) FindBatchPath

func (p *PostgreSQLpgx) FindBatchPath(blockchain string, blockNumber uint64) (string, uint64, uint64, error)

func (*PostgreSQLpgx) GetAbiJobsWithoutDeployBlocks

func (p *PostgreSQLpgx) GetAbiJobsWithoutDeployBlocks(blockchain string) (map[string]map[string][]string, error)

func (*PostgreSQLpgx) GetCustomersIDs

func (p *PostgreSQLpgx) GetCustomersIDs(blockchain string) ([]string, error)

func (*PostgreSQLpgx) GetEdgeDBBlock

func (p *PostgreSQLpgx) GetEdgeDBBlock(ctx context.Context, blockchain, side string) (BlockIndex, error)

GetEdgeDBBlock fetch first or last block for specified blockchain

func (*PostgreSQLpgx) GetLatestDBBlockNumber

func (p *PostgreSQLpgx) GetLatestDBBlockNumber(blockchain string) (uint64, error)

func (*PostgreSQLpgx) GetPool

func (p *PostgreSQLpgx) GetPool() *pgxpool.Pool

func (*PostgreSQLpgx) ReadABIJobs

func (p *PostgreSQLpgx) ReadABIJobs(blockchain string) ([]AbiJob, error)

func (*PostgreSQLpgx) ReadBlockIndex

func (p *PostgreSQLpgx) ReadBlockIndex(ctx context.Context, startBlock uint64, endBlock uint64) ([]BlockIndex, error)

func (*PostgreSQLpgx) ReadIndexOnRange

func (p *PostgreSQLpgx) ReadIndexOnRange(tableName string, startBlock uint64, endBlock uint64) ([]interface{}, error)

func (*PostgreSQLpgx) ReadLastLabel

func (p *PostgreSQLpgx) ReadLastLabel(blockchain string) (uint64, error)

func (*PostgreSQLpgx) ReadUpdates

func (p *PostgreSQLpgx) ReadUpdates(blockchain string, fromBlock uint64, customerIds []string) (uint64, uint64, string, []CustomerUpdates, error)

func (*PostgreSQLpgx) SelectAbiJobs

func (p *PostgreSQLpgx) SelectAbiJobs(blockchain string, addresses []string, customersIds []string, autoJobs bool) ([]CustomerUpdates, map[string]AbiJobsDeployInfo, error)

func (*PostgreSQLpgx) UpdateAbiJobsDeployBlock

func (p *PostgreSQLpgx) UpdateAbiJobsDeployBlock(blockNumber uint64, ids []string) error

func (*PostgreSQLpgx) UpdateAbiJobsStatus

func (p *PostgreSQLpgx) UpdateAbiJobsStatus(blockchain string) error

func (*PostgreSQLpgx) UpdateAbisAsDone

func (p *PostgreSQLpgx) UpdateAbisAsDone(ids []string) error

func (*PostgreSQLpgx) UpdateAbisProgress

func (p *PostgreSQLpgx) UpdateAbisProgress(ids []string, process int) error

func (*PostgreSQLpgx) WriteEvents

func (p *PostgreSQLpgx) WriteEvents(tx pgx.Tx, blockchain string, events []EventLabel) error

func (*PostgreSQLpgx) WriteIndexes

func (p *PostgreSQLpgx) WriteIndexes(blockchain string, blocksIndexPack []BlockIndex) error

func (*PostgreSQLpgx) WriteLabes

func (p *PostgreSQLpgx) WriteLabes(
	blockchain string,
	transactions []TransactionLabel,
	events []EventLabel,
) error

func (*PostgreSQLpgx) WriteTransactions

func (p *PostgreSQLpgx) WriteTransactions(tx pgx.Tx, blockchain string, transactions []TransactionLabel) error

type TaskForLog

type TaskForLog struct {
	Address  string `json:"address"`
	Selector string `json:"selector"`
	ABI      string `json:"abi"`
}

type TaskForTransaction

type TaskForTransaction struct {
	Address  string `json:"address"`
	Selector string `json:"selector"`
	ABI      string `json:"abi"`
}

type TransactionLabel

type TransactionLabel struct {
	Address         string
	BlockNumber     uint64
	BlockHash       string
	CallerAddress   string
	Label           string
	LabelName       string
	LabelType       string
	OriginAddress   string
	TransactionHash string
	LabelData       string
	BlockTimestamp  uint64
}

type UnnestInsertValueStruct

type UnnestInsertValueStruct struct {
	Type   string        `json:"type"`   // e.g. "BIGINT" or "TEXT" or any other PostgreSQL data type
	Values []interface{} `json:"values"` // e.g. [1, 2, 3, 4, 5]
}

https://klotzandrew.com/blog/postgres-passing-65535-parameter-limit/ insted of batching

Jump to

Keyboard shortcuts

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