Documentation
¶
Index ¶
- type BalanceLookupPriority
- type BalanceLookupRequest
- type BalanceLookupService
- func (s *BalanceLookupService) FetchETHBalance(ctx context.Context, address common.Address) (*big.Int, error)
- func (s *BalanceLookupService) FetchTokenBalance(ctx context.Context, address common.Address, tokenContract common.Address) (*big.Int, error)
- func (s *BalanceLookupService) GetPendingLookups(maxCount int) []*BalanceLookupRequest
- func (s *BalanceLookupService) GetQueueStats() (highPrio, lowPrio int)
- func (s *BalanceLookupService) HasPendingLookups() bool
- func (s *BalanceLookupService) ProcessPendingLookups(ctx context.Context) (dbCommitCallback, error)
- func (s *BalanceLookupService) QueueAddressBalanceLookups(accountID uint64, address []byte)
- func (s *BalanceLookupService) QueueBalanceLookup(req *BalanceLookupRequest)
- type BlockRef
- type TxIndexer
- func (t *TxIndexer) GetBalanceLookupService() *BalanceLookupService
- func (t *TxIndexer) GetBalanceLookupStats() (highPrio, lowPrio int)
- func (t *TxIndexer) GetReadyClients() []*elclients.Client
- func (t *TxIndexer) GetSyncEpoch() phase0.Epoch
- func (t *TxIndexer) QueueAddressBalanceLookups(accountID uint64, address []byte)
- func (t *TxIndexer) Start() error
- func (t *TxIndexer) Stop() error
- type WithdrawalData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BalanceLookupPriority ¶
type BalanceLookupPriority uint8
BalanceLookupPriority defines the priority level for balance lookups.
const ( // LowPriority is for background verification lookups. LowPriority BalanceLookupPriority = 0 // HighPriority is for user-facing address page lookups. HighPriority BalanceLookupPriority = 1 )
type BalanceLookupRequest ¶
type BalanceLookupRequest struct {
AccountID uint64 // 0 if address not in DB
TokenID uint64 // 0 for native ETH
Address common.Address // Required for RPC calls
Contract common.Address // Token contract (zero for native ETH)
Decimals uint8 // Token decimals
Priority BalanceLookupPriority
Timestamp time.Time // When request was added
}
BalanceLookupRequest represents a request to look up a balance. AccountID can be 0 for addresses not yet in the database.
type BalanceLookupService ¶
type BalanceLookupService struct {
// contains filtered or unexported fields
}
BalanceLookupService manages balance lookup requests with priority queuing.
func NewBalanceLookupService ¶
func NewBalanceLookupService(logger logrus.FieldLogger, indexer *TxIndexer) *BalanceLookupService
NewBalanceLookupService creates a new balance lookup service.
func (*BalanceLookupService) FetchETHBalance ¶
func (s *BalanceLookupService) FetchETHBalance(ctx context.Context, address common.Address) (*big.Int, error)
FetchETHBalance fetches the native ETH balance for an address via eth_getBalance.
func (*BalanceLookupService) FetchTokenBalance ¶
func (s *BalanceLookupService) FetchTokenBalance(ctx context.Context, address common.Address, tokenContract common.Address) (*big.Int, error)
FetchTokenBalance fetches the ERC20 token balance for an address via balanceOf static call.
func (*BalanceLookupService) GetPendingLookups ¶
func (s *BalanceLookupService) GetPendingLookups(maxCount int) []*BalanceLookupRequest
GetPendingLookups returns up to maxCount lookups to process. High priority requests are returned first.
func (*BalanceLookupService) GetQueueStats ¶
func (s *BalanceLookupService) GetQueueStats() (highPrio, lowPrio int)
GetQueueStats returns current queue sizes.
func (*BalanceLookupService) HasPendingLookups ¶
func (s *BalanceLookupService) HasPendingLookups() bool
HasPendingLookups returns true if there are any pending lookups in the queues.
func (*BalanceLookupService) ProcessPendingLookups ¶
func (s *BalanceLookupService) ProcessPendingLookups(ctx context.Context) (dbCommitCallback, error)
ProcessPendingLookups processes pending balance lookups and returns updated balances. For known accounts (AccountID > 0), updates the balance directly. For unknown accounts (AccountID == 0), creates the account if balance > 0.
func (*BalanceLookupService) QueueAddressBalanceLookups ¶ added in v1.20.0
func (s *BalanceLookupService) QueueAddressBalanceLookups(accountID uint64, address []byte)
QueueAddressBalanceLookups queues balance lookups for an address page view. accountID should be 0 if the address is not in the database. Rate limited to prevent excessive RPC calls.
func (*BalanceLookupService) QueueBalanceLookup ¶
func (s *BalanceLookupService) QueueBalanceLookup(req *BalanceLookupRequest)
QueueBalanceLookup adds a balance lookup request to the queue. High priority requests are processed before low priority ones. Duplicate requests are deduplicated, with priority upgraded if needed.
type BlockRef ¶
type BlockRef struct {
Slot phase0.Slot
BlockUID uint64
BlockHash []byte
Block *beacon.Block // optional, may be nil for historical blocks
ProcessTime time.Time // earliest time this block can be processed (zero means immediate)
UpdateSyncEpoch *phase0.Epoch // if set, update DB sync state to this epoch after processing
IsRecent bool
}
BlockRef represents a reference to a block for EL indexing.
type TxIndexer ¶
type TxIndexer struct {
// contains filtered or unexported fields
}
TxIndexer is responsible for indexing EL transactions from beacon blocks.
func NewTxIndexer ¶
func NewTxIndexer( logger logrus.FieldLogger, indexerCtx *execution.IndexerCtx, ) *TxIndexer
NewTxIndexer creates a new TxIndexer instance.
func (*TxIndexer) GetBalanceLookupService ¶
func (t *TxIndexer) GetBalanceLookupService() *BalanceLookupService
GetBalanceLookupService returns the balance lookup service for direct access.
func (*TxIndexer) GetBalanceLookupStats ¶
GetBalanceLookupStats returns the current balance lookup queue statistics.
func (*TxIndexer) GetReadyClients ¶
GetReadyClients returns a list of ready EL clients that have reached the finalized block. Prefers archive clients if available.
func (*TxIndexer) GetSyncEpoch ¶
GetSyncEpoch returns the current sync epoch.
func (*TxIndexer) QueueAddressBalanceLookups ¶
QueueAddressBalanceLookups queues all balance lookups for an address page view. This is called by the address handler when a user views an address page. The lookups are rate-limited to prevent excessive RPC calls.