Documentation
¶
Index ¶
- type Config
- type Network
- type NoOpReorgDetector
- func (n *NoOpReorgDetector) AddBlockToTrack(ctx context.Context, id string, blockNum uint64, blockHash common.Hash) error
- func (n *NoOpReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality
- func (n *NoOpReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)
- func (n *NoOpReorgDetector) String() string
- func (n *NoOpReorgDetector) Subscribe(id string) (*Subscription, error)
- type ReorgDetector
- func (rd *ReorgDetector) AddBlockToTrack(ctx context.Context, id string, num uint64, hash common.Hash) error
- func (rd *ReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality
- func (rd *ReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)
- func (rd *ReorgDetector) IsDisabled() bool
- 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 NoOpReorgDetector ¶ added in v0.7.0
type NoOpReorgDetector struct {
}
NoOpReorgDetector is a no-operation implementation of sync.ReorgDetector that does nothing when called, used when reorg detection is not needed
func NewNoOpReorgDetector ¶ added in v0.7.0
func NewNoOpReorgDetector() *NoOpReorgDetector
NewNoOpReorgDetector creates a new no-op reorg detector
func (*NoOpReorgDetector) AddBlockToTrack ¶ added in v0.7.0
func (n *NoOpReorgDetector) AddBlockToTrack( ctx context.Context, id string, blockNum uint64, blockHash common.Hash, ) error
AddBlockToTrack implements sync.ReorgDetector interface
func (*NoOpReorgDetector) GetFinalizedBlockType ¶ added in v0.7.0
func (n *NoOpReorgDetector) GetFinalizedBlockType() aggkittypes.BlockNumberFinality
GetFinalizedBlockType implements sync.ReorgDetector interface
func (*NoOpReorgDetector) GetLastReorgEvent ¶ added in v0.7.0
func (n *NoOpReorgDetector) GetLastReorgEvent(ctx context.Context) (ReorgEvent, error)
GetLastReorgEvent returns an empty reorg event since no-op detector never detects reorgs
func (*NoOpReorgDetector) String ¶ added in v0.7.0
func (n *NoOpReorgDetector) String() string
String implements sync.ReorgDetector interface
func (*NoOpReorgDetector) Subscribe ¶ added in v0.7.0
func (n *NoOpReorgDetector) Subscribe(id string) (*Subscription, error)
Subscribe implements sync.ReorgDetector interface
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) 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) IsDisabled ¶ added in v0.0.2
func (rd *ReorgDetector) IsDisabled() bool
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