Documentation
¶
Index ¶
- Variables
- type ContractConfig
- type LogQuery
- type SetSyncSegment
- func (s *SetSyncSegment) Add(segment SyncSegment)
- func (f *SetSyncSegment) AddLogQuery(logQuery *LogQuery) error
- func (f *SetSyncSegment) Clone() *SetSyncSegment
- func (f *SetSyncSegment) Finished() bool
- func (f *SetSyncSegment) GetAddressesForBlockRange(blockRange aggkitcommon.BlockRange) []common.Address
- func (s *SetSyncSegment) GetByContract(addr common.Address) (SyncSegment, bool)
- func (f *SetSyncSegment) GetLowestFromBlockSegment() *SyncSegment
- func (f *SetSyncSegment) IsAvailable(query LogQuery) bool
- func (f *SetSyncSegment) NextQuery(syncBlockChunkSize uint32, maxBlockNumber uint64) (*LogQuery, error)
- func (f *SetSyncSegment) Remove(segmentToRemove *SyncSegment)
- func (s *SetSyncSegment) Segments() []SyncSegment
- func (s *SetSyncSegment) SegmentsByContract(addrs []common.Address) []SyncSegment
- func (s *SetSyncSegment) String() string
- func (f *SetSyncSegment) SubtractLogQuery(logQuery *LogQuery) error
- func (f *SetSyncSegment) SubtractSegments(segments *SetSyncSegment) error
- func (f *SetSyncSegment) TotalBlocks() uint64
- func (f *SetSyncSegment) UpdateBlockRange(segment *SyncSegment, newBlockRange aggkitcommon.BlockRange)
- func (f *SetSyncSegment) UpdateTargetBlockToNumber(ctx context.Context, blockNotifierGetter ethermantypes.BlockNotifierManager) error
- type SetSyncerConfig
- type Storager
- type SyncSegment
- type SyncerID
Constants ¶
This section is empty.
Variables ¶
var (
ErrFinished = fmt.Errorf("no more segments to sync")
)
Functions ¶
This section is empty.
Types ¶
type ContractConfig ¶
type ContractConfig struct {
Address common.Address
FromBlock uint64
ToBlock aggkittypes.BlockNumberFinality
RequiredBlockHeader bool
Syncers []SyncerID
}
ContractConfig represents the configuration for a specific contract to be synced, the same as SyncerConfig but for individual contracts
func NewContractConfigFromSyncerConfig ¶
func NewContractConfigFromSyncerConfig(address common.Address, syncerConfig aggkittypes.SyncerConfig) *ContractConfig
func (*ContractConfig) Update ¶
func (c *ContractConfig) Update(syncerConfig aggkittypes.SyncerConfig)
type LogQuery ¶
type LogQuery struct {
Addrs []common.Address
BlockRange aggkitcommon.BlockRange
}
LogQuery defines a query for logs
func NewLogQuery ¶
NewLogQuery creates a new LogQuery
func NewLogQueryFromEthereumFilter ¶
func NewLogQueryFromEthereumFilter(query ethereum.FilterQuery) LogQuery
NewLogQueryFromEthereumFilter creates a new LogQuery from an Ethereum FilterQuery
func (*LogQuery) ToRPCFilterQuery ¶
func (l *LogQuery) ToRPCFilterQuery() ethereum.FilterQuery
ToRPCFilterQuery converts the LogQuery to an Ethereum FilterQuery
type SetSyncSegment ¶
type SetSyncSegment struct {
// contains filtered or unexported fields
}
func NewSetSyncSegment ¶
func NewSetSyncSegment() SetSyncSegment
NewSetSyncSegment creates a new empty SetSyncSegment
func NewSetSyncSegmentFromLogQuery ¶
func NewSetSyncSegmentFromLogQuery(logQuery *LogQuery) SetSyncSegment
NewSetSyncSegmentFromLogQuery creates a new SetSyncSegment from a LogQuery
func (*SetSyncSegment) Add ¶
func (s *SetSyncSegment) Add(segment SyncSegment)
Add adds a new SyncSegment to the SetSyncSegment, merging block ranges if the contract address already exists
func (*SetSyncSegment) AddLogQuery ¶
func (f *SetSyncSegment) AddLogQuery(logQuery *LogQuery) error
AddLogQuery adds all segments from the LogQuery to the SetSyncSegment used to update the syncedSegments after a successful FilterLogs
func (*SetSyncSegment) Clone ¶
func (f *SetSyncSegment) Clone() *SetSyncSegment
func (*SetSyncSegment) Finished ¶
func (f *SetSyncSegment) Finished() bool
func (*SetSyncSegment) GetAddressesForBlockRange ¶
func (f *SetSyncSegment) GetAddressesForBlockRange(blockRange aggkitcommon.BlockRange) []common.Address
func (*SetSyncSegment) GetByContract ¶
func (s *SetSyncSegment) GetByContract(addr common.Address) (SyncSegment, bool)
GetByContract returns the SyncSegment for the given contract address
func (*SetSyncSegment) GetLowestFromBlockSegment ¶
func (f *SetSyncSegment) GetLowestFromBlockSegment() *SyncSegment
func (*SetSyncSegment) IsAvailable ¶
func (f *SetSyncSegment) IsAvailable(query LogQuery) bool
IsAvailable checks if the required LogQuery data is already synced
func (*SetSyncSegment) NextQuery ¶
func (f *SetSyncSegment) NextQuery(syncBlockChunkSize uint32, maxBlockNumber uint64) (*LogQuery, error)
NextQuery generates the next LogQuery to sync based on the lowest FromBlock pending to synchronize
func (*SetSyncSegment) Remove ¶
func (f *SetSyncSegment) Remove(segmentToRemove *SyncSegment)
func (*SetSyncSegment) Segments ¶
func (s *SetSyncSegment) Segments() []SyncSegment
Segments returns all SyncSegments in the SetSyncSegment
func (*SetSyncSegment) SegmentsByContract ¶
func (s *SetSyncSegment) SegmentsByContract(addrs []common.Address) []SyncSegment
SegmentsByContract returns segments for the given contract addresses
func (*SetSyncSegment) String ¶
func (s *SetSyncSegment) String() string
String returns a string representation of the SetSyncSegment
func (*SetSyncSegment) SubtractLogQuery ¶
func (f *SetSyncSegment) SubtractLogQuery(logQuery *LogQuery) error
SubtractLogQuery removes the block ranges defined in the logQuery from the current SetSyncSegment This is used to update the pendingSync after doing a FilterLogs query
func (*SetSyncSegment) SubtractSegments ¶
func (f *SetSyncSegment) SubtractSegments(segments *SetSyncSegment) error
SubtractSegments removes the block ranges defined in segments from the current SetSyncSegment This is the pending data to synchronize
func (*SetSyncSegment) TotalBlocks ¶
func (f *SetSyncSegment) TotalBlocks() uint64
TotalBlocks returns the total number pending blocks to synchronize
func (*SetSyncSegment) UpdateBlockRange ¶
func (f *SetSyncSegment) UpdateBlockRange(segment *SyncSegment, newBlockRange aggkitcommon.BlockRange)
func (*SetSyncSegment) UpdateTargetBlockToNumber ¶
func (f *SetSyncSegment) UpdateTargetBlockToNumber(ctx context.Context, blockNotifierGetter ethermantypes.BlockNotifierManager) error
UpdateTargetBlockToNumber updates the ToBlock to real blockNumber
type SetSyncerConfig ¶
type SetSyncerConfig struct {
// contains filtered or unexported fields
}
func NewSetSyncerConfig ¶
func NewSetSyncerConfig() SetSyncerConfig
func (*SetSyncerConfig) Add ¶
func (f *SetSyncerConfig) Add(filter aggkittypes.SyncerConfig)
func (*SetSyncerConfig) Addresses ¶
func (f *SetSyncerConfig) Addresses(blockRange aggkitcommon.BlockRange) []common.Address
Addresses returns the unique list of contract addresses from all filters within the specified block range TODO: check blockRange
func (*SetSyncerConfig) ContractConfigs ¶
func (f *SetSyncerConfig) ContractConfigs() []ContractConfig
ContractConfigs combines the SyncerConfig into ContractConfig per contract address
func (*SetSyncerConfig) SyncSegments ¶
func (f *SetSyncerConfig) SyncSegments() (*SetSyncSegment, error)
SyncSegments groups the SetSyncerConfig into segments per contract address and blockRange
type Storager ¶
type Storager interface {
dbtypes.KeyValueStorager
// GetSyncedBlockRangePerContract It returns the synced block range stored in DB
GetSyncedBlockRangePerContract(tx dbtypes.Querier) (SetSyncSegment, error)
SaveEthLogsWithHeaders(tx dbtypes.Querier, blockHeaders []*aggkittypes.BlockHeader,
logs []types.Log, isFinal bool) error
GetEthLogs(tx dbtypes.Querier, query LogQuery) ([]types.Log, error)
UpdateSyncedStatus(tx dbtypes.Querier, segments []SyncSegment) error
UpsertSyncerConfigs(tx dbtypes.Querier, configs []ContractConfig) error
GetBlockHeaderByNumber(tx dbtypes.Querier, blockNumber uint64) (*aggkittypes.BlockHeader, bool, error)
NewTx(ctx context.Context) (dbtypes.Txer, error)
}
type SyncSegment ¶
type SyncSegment struct {
ContractAddr common.Address
BlockRange aggkitcommon.BlockRange
TargetToBlock aggkittypes.BlockNumberFinality
}
SyncSegment represents a segment of blocks, it is used for synced segments but also for representing segments to be synced
func NewSyncSegment ¶
func NewSyncSegment(contractAddr common.Address, blockRange aggkitcommon.BlockRange, targetToBlock aggkittypes.BlockNumberFinality, requiredBlockHeader bool) SyncSegment
NewSyncSegment creates a new SyncSegment
func (*SyncSegment) Clone ¶
func (s *SyncSegment) Clone() *SyncSegment
Clone creates a deep copy of the SyncSegment
func (SyncSegment) Equal ¶
func (s SyncSegment) Equal(other SyncSegment) bool
Equal checks if two SyncSegments are equal
func (SyncSegment) NewBlockRange ¶
func (s SyncSegment) NewBlockRange(br aggkitcommon.BlockRange) SyncSegment
NewBlockRange creates a new SyncSegment changing only the BlockRange
func (*SyncSegment) String ¶
func (s *SyncSegment) String() string
String returns a string representation of the SyncSegment
func (*SyncSegment) UpdateToBlock ¶
func (s *SyncSegment) UpdateToBlock(newToBlock uint64)
UpdateToBlock updates the ToBlock of the SyncSegment