storage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemoryStore

type MemoryStore struct {
	// contains filtered or unexported fields
}

MemoryStore is a simple in-memory implementation (Note: data lost on restart, for testing/temp tasks only)

func NewMemoryStore

func NewMemoryStore(prefix string) *MemoryStore

NewMemoryStore initializes a new in-memory storage.

func (*MemoryStore) Close

func (m *MemoryStore) Close() error

Close implements the Persistence interface.

func (*MemoryStore) LoadCursor

func (m *MemoryStore) LoadCursor(key string) (uint64, error)

LoadCursor retrieves the last scanned block height from memory.

func (*MemoryStore) SaveCursor

func (m *MemoryStore) SaveCursor(key string, height uint64) error

SaveCursor updates the last scanned block height in memory.

type Persistence

type Persistence interface {
	// LoadCursor reads the last scanned block height
	// key: task identifier (e.g., "erc20-scanner-v1")
	LoadCursor(key string) (uint64, error)

	// SaveCursor saves the current block height
	SaveCursor(key string, height uint64) error

	// Close releases resources
	Close() error
}

Persistence defines the interface for saving scanner progress

type PostgresStore

type PostgresStore struct {
	// contains filtered or unexported fields
}

PostgresStore implements the Persistence interface

func NewPostgresStore

func NewPostgresStore(connStr string, tablePrefix string) (*PostgresStore, error)

NewPostgresStore initializes PostgreSQL storage. connStr: Connection string tablePrefix: Table prefix (defaults to "scanner_") -> Resulting table is prefix + "checkpoints"

func (*PostgresStore) Close

func (p *PostgresStore) Close() error

Close closes the database connection

func (*PostgresStore) LoadCursor

func (p *PostgresStore) LoadCursor(key string) (uint64, error)

LoadCursor retrieves the last scanned block height for a given task key

func (*PostgresStore) SaveCursor

func (p *PostgresStore) SaveCursor(key string, height uint64) error

SaveCursor updates or inserts the last scanned block height for a given task key

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore implements the Persistence interface using Redis as a backend.

func NewRedisStore

func NewRedisStore(addr, password string, db int, prefix string) (*RedisStore, error)

NewRedisStore initializes Redis storage addr: e.g., "localhost:6379" prefix: Key prefix (e.g., "evm_scanner:"). Final Key is prefix + task_key

func (*RedisStore) Close

func (r *RedisStore) Close() error

Close closes the Redis client connection

func (*RedisStore) LoadCursor

func (r *RedisStore) LoadCursor(key string) (uint64, error)

LoadCursor retrieves the last scanned block height from Redis

func (*RedisStore) SaveCursor

func (r *RedisStore) SaveCursor(key string, height uint64) error

SaveCursor updates the last scanned block height in Redis

Jump to

Keyboard shortcuts

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