Documentation ¶
Index ¶
- func BuildPackedBlock(block *types.Block, txs []*db.PackedTransaction) *db.PackedBlock
- func BuildPackedTx(tx *types.Transaction, sender common.Address, receipt *types.Receipt) *db.PackedTransaction
- func FetchBlockByHash(client *ethclient.Client, hash common.Hash, number string, _db *gorm.DB, ...) bool
- func FetchBlockByNumber(client *ethclient.Client, number uint64, _db *gorm.DB, redis *d.RedisInfo, ...) bool
- func FetchTransactionByHash(client *ethclient.Client, block *types.Block, tx *types.Transaction, ...)
- func FindMissingBlocksInRange(found []uint64, from uint64, to uint64) []uint64
- func ProcessBlockContent(client *ethclient.Client, block *types.Block, _db *gorm.DB, redis *d.RedisInfo, ...) bool
- func PublishBlock(block *db.PackedBlock, redis *d.RedisInfo) bool
- func PublishEvent(blockNumber uint64, event *db.Events, redis *d.RedisInfo) bool
- func PublishEvents(blockNumber uint64, events []*db.Events, redis *d.RedisInfo) bool
- func PublishTx(blockNumber uint64, tx *db.PackedTransaction, redis *d.RedisInfo) bool
- func PublishTxs(blockNumber uint64, txs []*db.PackedTransaction, redis *d.RedisInfo) bool
- func RetryQueueManager(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, ...)
- func SubscribeToNewBlocks(connection *d.BlockChainNodeConnection, _db *gorm.DB, status *d.StatusHolder, ...)
- func SyncBlocksByRange(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, ...)
- func SyncMissingBlocksInDB(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, ...)
- func Syncer(client *ethclient.Client, _db *gorm.DB, redis *d.RedisInfo, ...)
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 ¶
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 ¶
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 ¶
PublishEvents - Iterate over all events & try to publish them on redis pubsub channel
func PublishTx ¶
PublishTx - Publishes tx & events in tx, related data to respective Redis pubsub channel
func PublishTxs ¶
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.