Documentation
¶
Index ¶
- type Config
- type Header
- type HeaderWithSubscriberID
- type Network
- type ReorgDetector
- func (rd *ReorgDetector) AddBlockToTrack(ctx context.Context, id string, num uint64, hash common.Hash) error
- func (rd *ReorgDetector) GetDB() *sql.DB
- func (rd *ReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality
- func (rd *ReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)
- func (rd *ReorgDetector) GetTrackedBlockByBlockNumber(id string, blockNumber uint64) (*Header, error)
- func (rd *ReorgDetector) Start(ctx context.Context) (err error)
- func (rd *ReorgDetector) String() string
- func (rd *ReorgDetector) Subscribe(id string) (*Subscription, error)
- type ReorgEvent
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// DBPath is the path to the database
DBPath string `mapstructure:"DBPath"`
// CheckReorgsInterval is the interval to check for reorgs in tracked blocks
CheckReorgsInterval types.Duration `mapstructure:"CheckReorgsInterval"`
// FinalizedBlockType indicates the status of the blocks that will be queried in order to sync
// if finalizedBlock == "LatestBlock" then it's disabled and we assume the network has no chances of reorgs
FinalizedBlock aggkittypes.BlockNumberFinality `` //nolint:lll
/* 135-byte string literal not displayed */
}
Config is the configuration for the reorg detector
func (*Config) GetCheckReorgsInterval ¶
GetCheckReorgsInterval returns the interval to check for reorgs in tracked blocks
type HeaderWithSubscriberID ¶ added in v0.7.1
type ReorgDetector ¶
type ReorgDetector struct {
// contains filtered or unexported fields
}
func New ¶
func New(client aggkittypes.BaseEthereumClienter, cfg Config, network Network) (*ReorgDetector, error)
func (*ReorgDetector) AddBlockToTrack ¶
func (rd *ReorgDetector) AddBlockToTrack(ctx context.Context, id string, num uint64, hash common.Hash) error
AddBlockToTrack adds a block to the tracked list for a subscriber
func (*ReorgDetector) GetDB ¶ added in v0.7.1
func (rd *ReorgDetector) GetDB() *sql.DB
GetDB returns the database connection for testing purposes
func (*ReorgDetector) GetFinalizedBlockType ¶ added in v0.0.2
func (rd *ReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality
GetFinalizedBlockType returns the finalized block name
func (*ReorgDetector) GetLastReorgEvent ¶ added in v0.5.0
func (rd *ReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)
GetLastReorgEvent returns the the last ReorgEvent stored in reorg_event table
func (*ReorgDetector) GetTrackedBlockByBlockNumber ¶ added in v0.7.1
func (rd *ReorgDetector) GetTrackedBlockByBlockNumber(id string, blockNumber uint64) (*Header, error)
func to get the tracked blocks for a subscriber by block number and hash, it should be 1 or none, from headercache
func (*ReorgDetector) Start ¶
func (rd *ReorgDetector) Start(ctx context.Context) (err error)
Start starts the reorg detector
func (*ReorgDetector) String ¶ added in v0.0.2
func (rd *ReorgDetector) String() string
func (*ReorgDetector) Subscribe ¶
func (rd *ReorgDetector) Subscribe(id string) (*Subscription, error)
Subscribe subscribes to reorg events
type ReorgEvent ¶ added in v0.1.0
type ReorgEvent struct {
DetectedAt int64 `meddler:"detected_at"`
FromBlock uint64 `meddler:"from_block"`
ToBlock uint64 `meddler:"to_block"`
SubscriberID string `meddler:"subscriber_id"`
TrackedHash common.Hash `meddler:"tracked_hash,hash"`
CurrentHash common.Hash `meddler:"current_hash,hash"`
Version string `meddler:"version"`
}
type Subscription ¶
Subscription is a subscription to reorg events
Source Files
¶
Click to show internal directories.
Click to hide internal directories.