ethblocklistener

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockListener

type BlockListener interface {
	ReconcileConfirmationsForTransaction(ctx context.Context, txHash string, existingConfirmations []*ethrpc.MinimalBlockInfo, targetConfirmationCount uint64) (*ConfirmationUpdateResult, *ethrpc.TxReceiptJSONRPC, error)
	GetMonitoredHeadLength() int // provides a getter on the configuration for unstable head length - as this information is important to consumers (might be multiple from this block listener)
	AddConsumer(ctx context.Context, c *BlockUpdateConsumer)
	RemoveConsumer(ctx context.Context, id *fftypes.UUID)
	GetHighestBlock(ctx context.Context) (uint64, bool)
	GetBlockInfoByNumber(ctx context.Context, blockNumber uint64, allowCache bool, expectedParentHashStr string, expectedBlockHashStr string) (*ethrpc.BlockInfoJSONRPC, error)
	GetBlockInfoByHash(ctx context.Context, hash0xString string) (*ethrpc.BlockInfoJSONRPC, error)
	GetEVMBlockWithTxHashesByHash(ctx context.Context, hash0xString string) (b *ethrpc.EVMBlockWithTxHashesJSONRPC, err error)
	GetEVMBlockWithTransactionsByHash(ctx context.Context, hash0xString string) (b *ethrpc.EVMBlockWithTransactionsJSONRPC, err error)
	GetEVMBlockWithTxHashesByNumber(ctx context.Context, numberLookup string) (b *ethrpc.EVMBlockWithTxHashesJSONRPC, err error)
	GetEVMBlockWithTransactionsByNumber(ctx context.Context, numberLookup string) (b *ethrpc.EVMBlockWithTransactionsJSONRPC, err error)
	FetchBlockReceiptsAsync(blockNumber uint64, blockHash ethtypes.HexBytes0xPrefix, cb func([]*ethrpc.TxReceiptJSONRPC, error))
	SnapshotMonitoredHeadChain() []*ethrpc.BlockInfoJSONRPC // snapshot the whole view, with complete blocks, using the read-lock.
	WaitClosed()
	GetBackend() rpcbackend.RPC
	UTSetBackend(rpcbackend.RPC)
}

func NewBlockListener

func NewBlockListener(ctx context.Context, retry *retry.Retry, conf *BlockListenerConfig, httpConf *ffresty.Config, wsConf *wsclient.WSConfig) (bl BlockListener, err error)

func NewBlockListenerSupplyBackend

func NewBlockListenerSupplyBackend(ctx context.Context, retry *retry.Retry, conf *BlockListenerConfig, httpBackend rpcbackend.RPC, wsBackend rpcbackend.WebSocketRPCClient) (_ BlockListener, err error)

type BlockListenerConfig

type BlockListenerConfig struct {
	MonitoredHeadLength           int                      `json:"monitoredHeadLength"`
	BlockPollingInterval          time.Duration            `json:"blockPollingInterval"`
	HederaCompatibilityMode       bool                     `json:"hederaCompatibilityMode"`
	BlockCacheSize                int                      `json:"blockCacheSize"`
	IncludeLogsBloom              bool                     `json:"includeLogsBloom"`
	UseGetBlockReceipts           bool                     `json:"useGetBlockReceipts"`
	MaxAsyncBlockFetchConcurrency int                      `json:"maxAsyncBlockFetchConcurrency"`
	ChainTrackingMode             ffcapi.ChainTrackingMode `json:"chainTrackingMode,omitempty"`
}

type BlockUpdateConsumer

type BlockUpdateConsumer struct {
	ID      *fftypes.UUID // could be an event stream ID for example - must be unique
	Ctx     context.Context
	Updates chan<- *ffcapi.BlockHashEvent // FFTM change events
}

type ConfirmationUpdateResult added in v1.4.3

type ConfirmationUpdateResult struct {
	Confirmations            []*ethrpc.MinimalBlockInfo `json:"confirmations,omitempty"`  // the confirmation list
	Rebuilt                  bool                       `json:"rebuilt,omitempty"`        // when true, it means the existing confirmations contained invalid blocks, the new confirmations are rebuilt from scratch
	NewFork                  bool                       `json:"newFork,omitempty"`        // when true, it means a new fork was detected based on the existing confirmations
	Confirmed                bool                       `json:"confirmed,omitempty"`      // when true, it means the confirmation list is complete and the transaction is confirmed
	TargetConfirmationCount  uint64                     `json:"targetConfirmationCount"`  // the target number of confirmations for this reconcile request
	CurrentConfirmationCount uint64                     `json:"currentConfirmationCount"` // the current number of confirmations for this reconcile request
}

a linked list of accumulated confirmations for a transaction the list is sorted by block number

  • the first block is the block that contains the transaction hash
  • the last block is the most recent confirmation

this list can be used as input to the future reconcile request to avoid re-fetching the blocks if they are no longer in the in-memory partial chain WARNING: mutation to this list is not expected, invalid modifications will cause inefficiencies in the reconciliation process

`rebuilt` will be true if an invalid confirmation list is detected by the reconciliation process

Jump to

Keyboard shortcuts

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