storage

package
v1.0.0-beta Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_MAX_ROWS_PER_INSERT = 100000
View Source
var DEFAULT_REDIS_POOL_SIZE = 20
View Source
var ZERO_BYTES_10 = strings.Repeat("\x00", 10)
View Source
var ZERO_BYTES_66 = strings.Repeat("\x00", 66)

Functions

func IsInRange

func IsInRange(num *big.Int, rangeStart *big.Int, rangeEnd *big.Int) bool

func NewConnector

func NewConnector[T any](cfg *config.StorageConnectionConfig) (T, error)

Types

type BalancesQueryFilter

type BalancesQueryFilter struct {
	ChainId      *big.Int
	TokenType    string
	TokenAddress string
	Owner        string
	ZeroBalance  bool
	SortBy       string
	SortOrder    string
	Page         int
	Limit        int
	Offset       int
}

type BigInt

type BigInt struct {
	big.Int
}

func (BigInt) MarshalJSON

func (b BigInt) MarshalJSON() ([]byte, error)

type ClickHouseConnector

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

func NewClickHouseConnector

func NewClickHouseConnector(cfg *config.ClickhouseConfig) (*ClickHouseConnector, error)

func (*ClickHouseConnector) DeleteBlockData

func (c *ClickHouseConnector) DeleteBlockData(chainId *big.Int, blockNumbers []*big.Int) error

func (*ClickHouseConnector) DeleteBlockFailures

func (c *ClickHouseConnector) DeleteBlockFailures(failures []common.BlockFailure) error

func (*ClickHouseConnector) DeleteStagingData

func (c *ClickHouseConnector) DeleteStagingData(data *[]common.BlockData) error

func (*ClickHouseConnector) GetAggregations

func (c *ClickHouseConnector) GetAggregations(table string, qf QueryFilter) (QueryResult[interface{}], error)

func (*ClickHouseConnector) GetBlockFailures

func (c *ClickHouseConnector) GetBlockFailures(qf QueryFilter) ([]common.BlockFailure, error)

func (*ClickHouseConnector) GetBlockHeadersDescending

func (c *ClickHouseConnector) GetBlockHeadersDescending(chainId *big.Int, from *big.Int, to *big.Int) (blockHeaders []common.BlockHeader, err error)

func (*ClickHouseConnector) GetBlocks

func (c *ClickHouseConnector) GetBlocks(qf QueryFilter, fields ...string) (QueryResult[common.Block], error)

func (*ClickHouseConnector) GetLastReorgCheckedBlockNumber

func (c *ClickHouseConnector) GetLastReorgCheckedBlockNumber(chainId *big.Int) (*big.Int, error)

func (*ClickHouseConnector) GetLastStagedBlockNumber

func (c *ClickHouseConnector) GetLastStagedBlockNumber(chainId *big.Int, rangeStart *big.Int, rangeEnd *big.Int) (maxBlockNumber *big.Int, err error)

func (*ClickHouseConnector) GetLogs

func (c *ClickHouseConnector) GetLogs(qf QueryFilter, fields ...string) (QueryResult[common.Log], error)

func (*ClickHouseConnector) GetMaxBlockNumber

func (c *ClickHouseConnector) GetMaxBlockNumber(chainId *big.Int) (maxBlockNumber *big.Int, err error)

func (*ClickHouseConnector) GetStagingData

func (c *ClickHouseConnector) GetStagingData(qf QueryFilter) (*[]common.BlockData, error)

func (*ClickHouseConnector) GetTokenBalances

func (*ClickHouseConnector) GetTraces

func (c *ClickHouseConnector) GetTraces(qf QueryFilter, fields ...string) (QueryResult[common.Trace], error)

func (*ClickHouseConnector) GetTransactions

func (c *ClickHouseConnector) GetTransactions(qf QueryFilter, fields ...string) (QueryResult[common.Transaction], error)

func (*ClickHouseConnector) InsertBlockData

func (c *ClickHouseConnector) InsertBlockData(data *[]common.BlockData) error

TODO make this atomic

func (*ClickHouseConnector) InsertStagingData

func (c *ClickHouseConnector) InsertStagingData(data []common.BlockData) error

func (*ClickHouseConnector) SetLastReorgCheckedBlockNumber

func (c *ClickHouseConnector) SetLastReorgCheckedBlockNumber(chainId *big.Int, blockNumber *big.Int) error

func (*ClickHouseConnector) StoreBlockFailures

func (c *ClickHouseConnector) StoreBlockFailures(failures []common.BlockFailure) error

type IMainStorage

type IMainStorage interface {
	InsertBlockData(data *[]common.BlockData) error

	GetBlocks(qf QueryFilter, fields ...string) (blocks QueryResult[common.Block], err error)
	GetTransactions(qf QueryFilter, fields ...string) (transactions QueryResult[common.Transaction], err error)
	GetLogs(qf QueryFilter, fields ...string) (logs QueryResult[common.Log], err error)
	GetTraces(qf QueryFilter, fields ...string) (traces QueryResult[common.Trace], err error)
	GetAggregations(table string, qf QueryFilter) (QueryResult[interface{}], error)
	GetMaxBlockNumber(chainId *big.Int) (maxBlockNumber *big.Int, err error)
	/**
	 * Get block headers ordered from latest to oldest.
	 */
	GetBlockHeadersDescending(chainId *big.Int, from *big.Int, to *big.Int) (blockHeaders []common.BlockHeader, err error)
	DeleteBlockData(chainId *big.Int, blockNumbers []*big.Int) error

	GetTokenBalances(qf BalancesQueryFilter) (QueryResult[common.TokenBalance], error)
}

type IOrchestratorStorage

type IOrchestratorStorage interface {
	GetBlockFailures(qf QueryFilter) ([]common.BlockFailure, error)
	StoreBlockFailures(failures []common.BlockFailure) error
	DeleteBlockFailures(failures []common.BlockFailure) error
	GetLastReorgCheckedBlockNumber(chainId *big.Int) (*big.Int, error)
	SetLastReorgCheckedBlockNumber(chainId *big.Int, blockNumber *big.Int) error
}

type IStagingStorage

type IStagingStorage interface {
	InsertStagingData(data []common.BlockData) error
	GetStagingData(qf QueryFilter) (data *[]common.BlockData, err error)
	DeleteStagingData(data *[]common.BlockData) error
	GetLastStagedBlockNumber(chainId *big.Int, rangeStart *big.Int, rangeEnd *big.Int) (maxBlockNumber *big.Int, err error)
}

type IStorage

type IStorage struct {
	OrchestratorStorage IOrchestratorStorage
	MainStorage         IMainStorage
	StagingStorage      IStagingStorage
}

func NewStorageConnector

func NewStorageConnector(cfg *config.StorageConfig) (IStorage, error)

type InsertOptions

type InsertOptions struct {
	AsDeleted bool
}

type MemoryConnector

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

func NewMemoryConnector

func NewMemoryConnector(cfg *config.MemoryConfig) (*MemoryConnector, error)

func (*MemoryConnector) DeleteBlockData

func (m *MemoryConnector) DeleteBlockData(chainId *big.Int, blockNumbers []*big.Int) error

func (*MemoryConnector) DeleteBlockFailures

func (m *MemoryConnector) DeleteBlockFailures(failures []common.BlockFailure) error

func (*MemoryConnector) DeleteStagingData

func (m *MemoryConnector) DeleteStagingData(data *[]common.BlockData) error

func (*MemoryConnector) GetBlockFailures

func (m *MemoryConnector) GetBlockFailures(qf QueryFilter) ([]common.BlockFailure, error)

func (*MemoryConnector) GetBlockHeadersDescending

func (m *MemoryConnector) GetBlockHeadersDescending(chainId *big.Int, from *big.Int, to *big.Int) ([]common.BlockHeader, error)

func (*MemoryConnector) GetBlocks

func (m *MemoryConnector) GetBlocks(qf QueryFilter, fields ...string) (QueryResult[common.Block], error)

func (*MemoryConnector) GetLastReorgCheckedBlockNumber

func (m *MemoryConnector) GetLastReorgCheckedBlockNumber(chainId *big.Int) (*big.Int, error)

func (*MemoryConnector) GetLastStagedBlockNumber

func (m *MemoryConnector) GetLastStagedBlockNumber(chainId *big.Int, rangeStart *big.Int, rangeEnd *big.Int) (*big.Int, error)

func (*MemoryConnector) GetLogs

func (m *MemoryConnector) GetLogs(qf QueryFilter, fields ...string) (QueryResult[common.Log], error)

func (*MemoryConnector) GetMaxBlockNumber

func (m *MemoryConnector) GetMaxBlockNumber(chainId *big.Int) (*big.Int, error)

func (*MemoryConnector) GetStagingData

func (m *MemoryConnector) GetStagingData(qf QueryFilter) (*[]common.BlockData, error)

func (*MemoryConnector) GetTraces

func (m *MemoryConnector) GetTraces(qf QueryFilter, fields ...string) (QueryResult[common.Trace], error)

func (*MemoryConnector) GetTransactions

func (m *MemoryConnector) GetTransactions(qf QueryFilter, fields ...string) (QueryResult[common.Transaction], error)

func (*MemoryConnector) InsertBlockData

func (m *MemoryConnector) InsertBlockData(data *[]common.BlockData) error

func (*MemoryConnector) InsertStagingData

func (m *MemoryConnector) InsertStagingData(data []common.BlockData) error

func (*MemoryConnector) SetLastReorgCheckedBlockNumber

func (m *MemoryConnector) SetLastReorgCheckedBlockNumber(chainId *big.Int, blockNumber *big.Int) error

func (*MemoryConnector) StoreBlockFailures

func (m *MemoryConnector) StoreBlockFailures(failures []common.BlockFailure) error

type QueryFilter

type QueryFilter struct {
	ChainId             *big.Int
	BlockNumbers        []*big.Int
	FilterParams        map[string]string
	GroupBy             []string
	SortBy              string
	SortOrder           string
	Page                int
	Limit               int
	Offset              int
	Aggregates          []string // e.g., ["COUNT(*) AS count", "SUM(amount) AS total_amount"]
	FromAddress         string
	ContractAddress     string
	Signature           string
	ForceConsistentData bool
}

type QueryResult

type QueryResult[T any] struct {
	// TODO: findout how to only allow Log/transaction arrays or split the result
	Data       []T                      `json:"data"`
	Aggregates []map[string]interface{} `json:"aggregates"`
}

type RedisConnector

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

func NewRedisConnector

func NewRedisConnector(cfg *config.RedisConfig) (*RedisConnector, error)

func (*RedisConnector) DeleteBlockFailures

func (r *RedisConnector) DeleteBlockFailures(failures []common.BlockFailure) error

func (*RedisConnector) GetBlockFailures

func (r *RedisConnector) GetBlockFailures(qf QueryFilter) ([]common.BlockFailure, error)

func (*RedisConnector) GetLastReorgCheckedBlockNumber

func (r *RedisConnector) GetLastReorgCheckedBlockNumber(chainId *big.Int) (*big.Int, error)

func (*RedisConnector) SetLastReorgCheckedBlockNumber

func (r *RedisConnector) SetLastReorgCheckedBlockNumber(chainId *big.Int, blockNumber *big.Int) error

func (*RedisConnector) StoreBlockFailures

func (r *RedisConnector) StoreBlockFailures(failures []common.BlockFailure) error

Jump to

Keyboard shortcuts

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