block

package
v0.0.0-...-c096a92 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPackedBlock

func BuildPackedBlock(block *types.Block, txs []*db.PackedTransaction) *db.PackedBlock

BuildPackedBlock - Builds struct holding whole block data i.e. block header, block body i.e. tx(s), event log(s)

func BuildPackedTx

func BuildPackedTx(tx *types.Transaction, sender common.Address, receipt *types.Receipt) *db.PackedTransaction

BuildPackedTx - Putting all information, the service will keep for one tx into a single structure, so that it becomes easier to pass to & from functions

func FetchBlockByHash

func FetchBlockByHash(client *ethclient.Client, hash common.Hash, number string, _db *gorm.DB, redis *d.RedisInfo, queue *q.BlockProcessorQueue, _status *d.StatusHolder) bool

FetchBlockByHash - Fetching block content using blockHash

func FetchBlockByNumber

func FetchBlockByNumber(client *ethclient.Client, number uint64, _db *gorm.DB, redis *d.RedisInfo, publishable bool, queue *q.BlockProcessorQueue, _status *d.StatusHolder) bool

FetchBlockByNumber - Fetching block content using block number

func FetchTransactionByHash

func FetchTransactionByHash(client *ethclient.Client, block *types.Block, tx *types.Transaction, _db *gorm.DB, redis *d.RedisInfo, _status *d.StatusHolder, returnValChan chan *db.PackedTransaction)

FetchTransactionByHash - Fetching specific transaction related data, tries to publish data if required & lets listener go routine know about all tx, event data it collected while processing this tx, which will be attempted to be stored in database

func FindMissingBlocksInRange

func FindMissingBlocksInRange(found []uint64, from uint64, to uint64) []uint64

FindMissingBlocksInRange - Given ascending ordered block numbers read from DB attempts to find out which numbers are missing in [from, to] range inclusive

func ProcessBlockContent

func ProcessBlockContent(client *ethclient.Client, block *types.Block, _db *gorm.DB, redis *d.RedisInfo, publishable bool, queue *q.BlockProcessorQueue, status *d.StatusHolder, startingAt time.Time) bool

ProcessBlockContent - Processes everything inside this block i.e. block data, tx data, event data

func PublishBlock

func PublishBlock(block *db.PackedBlock, redis *d.RedisInfo) bool

PublishBlock - Attempts to publish block data to Redis pubsub channel

func PublishEvent

func PublishEvent(blockNumber uint64, event *db.Events, redis *d.RedisInfo) bool

PublishEvent - Publishing event/ log entry to redis pub-sub topic, to be captured by subscribers and sent to client application, who are interested in this piece of data after applying filter

func PublishEvents

func PublishEvents(blockNumber uint64, events []*db.Events, redis *d.RedisInfo) bool

PublishEvents - Iterate over all events & try to publish them on redis pubsub channel

func PublishTx

func PublishTx(blockNumber uint64, tx *db.PackedTransaction, redis *d.RedisInfo) bool

PublishTx - Publishes tx & events in tx, related data to respective Redis pubsub channel

func PublishTxs

func PublishTxs(blockNumber uint64, txs []*db.PackedTransaction, redis *d.RedisInfo) bool

PublishTxs - Publishes all transactions in a block to redis pubsub channel

func RetryQueueManager

func RetryQueueManager(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, queue *q.BlockProcessorQueue, status *d.StatusHolder)

RetryQueueManager - Pop oldest block number from Redis backed retry queue and try to fetch it in different go routine

Sleeps for 500 milliseconds then repeat

func SubscribeToNewBlocks

func SubscribeToNewBlocks(connection *d.BlockChainNodeConnection, _db *gorm.DB, status *d.StatusHolder, redis *d.RedisInfo, queue *q.BlockProcessorQueue)

SubscribeToNewBlocks - Listen for new block header available, then fetch block content including all transactions in different worker

func SyncBlocksByRange

func SyncBlocksByRange(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, queue *q.BlockProcessorQueue, fromBlock uint64, toBlock uint64, status *d.StatusHolder)

SyncBlocksByRange - Fetch & persist all blocks in range(fromBlock, toBlock), both inclusive

Range can be either ascending or descending, depending upon that proper arguments to be passed to `Syncer` function during invokation

func SyncMissingBlocksInDB

func SyncMissingBlocksInDB(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, queue *q.BlockProcessorQueue, status *d.StatusHolder)

SyncMissingBlocksInDB - Checks with database for what blocks are present & what are not, fetches missing blocks & related data iteratively

func Syncer

func Syncer(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, queue *q.BlockProcessorQueue, fromBlock uint64, toBlock uint64, status *d.StatusHolder, jd func(*workerpool.WorkerPool, *d.Job, *q.BlockProcessorQueue))

Syncer - Given ascending block number range i.e. fromBlock <= toBlock attempts to fetch missing blocks in that range while running n workers concurrently, where n = number of cores this machine has

Waits for all of them to complete

Types

This section is empty.

Jump to

Keyboard shortcuts

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