Documentation ¶
Index ¶
- func GetReorgError(err error) error
- func GetReorgErrorBlockNumber(err error) uint64
- func IsReorgError(err error) bool
- func LogComparedBytes(name1 string, name2 string, data1 []byte, data2 []byte, numBytesBefore int, ...) string
- func RpcBatchToStateBatch(rpcBatch *types.Batch) *state.Batch
- type Cache
- func (c *Cache[K, T]) Clear()
- func (c *Cache[K, T]) Delete(key K)
- func (c *Cache[K, T]) DeleteOutdated()
- func (c *Cache[K, T]) Get(key K) (T, bool)
- func (c *Cache[K, T]) GetOrDefault(key K, defaultValue T) T
- func (c *Cache[K, T]) Keys() []K
- func (c *Cache[K, T]) Len() int
- func (c *Cache[K, T]) RenewEntry(key K, validTime time.Time)
- func (c *Cache[K, T]) Set(key K, value T)
- func (c *Cache[K, T]) Values() []T
- type CriticalErrorHalt
- type DefaultTimeProvider
- type MockTimerProvider
- type ReorgError
- type TimeProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetReorgError ¶ added in v0.6.6
GetReorgError returns the error that caused the reorg
func GetReorgErrorBlockNumber ¶ added in v0.6.6
GetReorgErrorBlockNumber returns the block number that caused the reorg
func IsReorgError ¶ added in v0.6.6
IsReorgError checks if an error is a ReorgError
Types ¶
type Cache ¶
type Cache[K comparable, T any] struct { // contains filtered or unexported fields }
Cache is a generic cache implementation with TOL (time of live) for each item
func NewCache ¶
func NewCache[K comparable, T any](timerProvider TimeProvider, timeOfLiveItems time.Duration) *Cache[K, T]
NewCache creates a new cache
func (*Cache[K, T]) Delete ¶
func (c *Cache[K, T]) Delete(key K)
Delete deletes the key from the cache
func (*Cache[K, T]) DeleteOutdated ¶
func (c *Cache[K, T]) DeleteOutdated()
DeleteOutdated deletes the outdated items from the cache
func (*Cache[K, T]) Get ¶
Get returns the value of the key and true if the key exists and is not outdated
func (*Cache[K, T]) GetOrDefault ¶
func (c *Cache[K, T]) GetOrDefault(key K, defaultValue T) T
GetOrDefault returns the value of the key and defaultValue if the key does not exist or is outdated
func (*Cache[K, T]) RenewEntry ¶
RenewEntry renews the entry of the key
type CriticalErrorHalt ¶
type CriticalErrorHalt struct { EventLog syncinterfaces.EventLogInterface SleepTime time.Duration }
CriticalErrorHalt is a Synchronizer halter, implements syncinterfaces.Halter basically it logs an error and keep in a infinite loop to halt the synchronizer
func NewCriticalErrorHalt ¶
func NewCriticalErrorHalt(eventLog syncinterfaces.EventLogInterface, sleepTime time.Duration) *CriticalErrorHalt
NewCriticalErrorHalt creates a new HaltSynchronizer
func (*CriticalErrorHalt) CriticalError ¶
func (g *CriticalErrorHalt) CriticalError(ctx context.Context, err error)
CriticalError halts the Synchronizer and write a eventLog on Database
type DefaultTimeProvider ¶
type DefaultTimeProvider struct{}
DefaultTimeProvider is the default implementation of TimeProvider
func (DefaultTimeProvider) Now ¶
func (d DefaultTimeProvider) Now() time.Time
Now returns current time
type MockTimerProvider ¶
type MockTimerProvider struct {
// contains filtered or unexported fields
}
MockTimerProvider is a mock implementation of the TimerProvider interface that return the internal variable
func (*MockTimerProvider) Now ¶
func (m *MockTimerProvider) Now() time.Time
Now in the implementation of TimeProvider.Now()
type ReorgError ¶ added in v0.6.6
type ReorgError struct { // BlockNumber is the block number that caused the reorg BlockNumber uint64 Err error }
ReorgError is an error that is raised when a reorg is detected
func NewReorgError ¶ added in v0.6.6
func NewReorgError(blockNumber uint64, err error) *ReorgError
NewReorgError creates a new ReorgError
func (*ReorgError) Error ¶ added in v0.6.6
func (e *ReorgError) Error() string
type TimeProvider ¶
TimeProvider is a interface for classes that needs time and we want to be able to unittest it