persistence

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicMetrics

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

func NewBasicMetrics

func NewBasicMetrics(namespace, driverName string, enabled bool) *BasicMetrics

func (*BasicMetrics) ObserveOperation

func (m *BasicMetrics) ObserveOperation(operation Operation)

func (*BasicMetrics) ObserveOperationError

func (m *BasicMetrics) ObserveOperationError(operation Operation)

type BeaconState

type BeaconState struct {
	gorm.Model
	ID   string `gorm:"primaryKey"`
	Node string `gorm:"index"`
	// We have to use int64 here as SQLite doesn't support uint64. This sucks
	// but slot 9223372036854775808 is probably around the heat death
	// of the universe so we should be OK.
	Slot                 int64 `gorm:"index:idx_slot,where:deleted_at IS NULL"`
	Epoch                int64
	StateRoot            string
	FetchedAt            time.Time `gorm:"index"`
	BeaconImplementation string
	NodeVersion          string `gorm:"not null;default:''"`
	Location             string `gorm:"not null;default:''"`
	Network              string `gorm:"not null;default:''"`
}

type BeaconStateFilter

type BeaconStateFilter struct {
	ID                   *string
	Node                 *string
	Before               *time.Time
	After                *time.Time
	Slot                 *uint64
	Epoch                *uint64
	StateRoot            *string
	NodeVersion          *string
	Location             *string
	Network              *string
	BeaconImplementation *string
}

func (*BeaconStateFilter) AddAfter

func (f *BeaconStateFilter) AddAfter(after time.Time)

func (*BeaconStateFilter) AddBeaconImplementation

func (f *BeaconStateFilter) AddBeaconImplementation(BeaconImplementation string)

func (*BeaconStateFilter) AddBefore

func (f *BeaconStateFilter) AddBefore(before time.Time)

func (*BeaconStateFilter) AddEpoch

func (f *BeaconStateFilter) AddEpoch(epoch uint64)

func (*BeaconStateFilter) AddID

func (f *BeaconStateFilter) AddID(id string)

func (*BeaconStateFilter) AddLocation

func (f *BeaconStateFilter) AddLocation(location string)

func (*BeaconStateFilter) AddNetwork

func (f *BeaconStateFilter) AddNetwork(network string)

func (*BeaconStateFilter) AddNode

func (f *BeaconStateFilter) AddNode(node string)

func (*BeaconStateFilter) AddNodeVersion

func (f *BeaconStateFilter) AddNodeVersion(nodeVersion string)

func (*BeaconStateFilter) AddSlot

func (f *BeaconStateFilter) AddSlot(slot uint64)

func (*BeaconStateFilter) AddStateRoot

func (f *BeaconStateFilter) AddStateRoot(stateRoot string)

func (*BeaconStateFilter) ApplyToQuery

func (f *BeaconStateFilter) ApplyToQuery(query *gorm.DB) (*gorm.DB, error)

func (*BeaconStateFilter) Validate

func (f *BeaconStateFilter) Validate() error

type Config

type Config struct {
	DSN        string `yaml:"dsn"`
	DriverName string `yaml:"driver_name"`
}

func (*Config) Validate

func (c *Config) Validate() error

type DistinctBeaconStateValueResults

type DistinctBeaconStateValueResults struct {
	Node                 []string
	Slot                 []uint64
	Epoch                []uint64
	StateRoot            []string
	NodeVersion          []string
	Location             []string
	Network              []string
	BeaconImplementation []string
}

type DistinctExecutionBadBlockValueResults

type DistinctExecutionBadBlockValueResults struct {
	Node                    []string
	BlockHash               []string
	BlockNumber             []int64
	Location                []string
	Network                 []string
	ExecutionImplementation []string
	NodeVersion             []string
	BlockExtraData          []string
}

type DistinctExecutionBlockTraceValueResults

type DistinctExecutionBlockTraceValueResults struct {
	Node                    []string
	BlockHash               []string
	BlockNumber             []int64
	Location                []string
	Network                 []string
	ExecutionImplementation []string
	NodeVersion             []string
}

type ExecutionBadBlock

type ExecutionBadBlock struct {
	gorm.Model
	ID                      string    `gorm:"primaryKey"`
	Node                    string    `gorm:"index"`
	FetchedAt               time.Time `gorm:"index"`
	ExecutionImplementation string
	NodeVersion             string `gorm:"not null;default:''"`
	Location                string `gorm:"not null;default:''"`
	Network                 string `gorm:"not null;default:''"`
	BlockHash               string `gorm:"not null;default:''"`
	BlockNumber             sql.NullInt64
	BlockExtraData          sql.NullString
}

type ExecutionBadBlockFilter

type ExecutionBadBlockFilter struct {
	ID                      *string
	Node                    *string
	Before                  *time.Time
	After                   *time.Time
	NodeVersion             *string
	Location                *string
	Network                 *string
	ExecutionImplementation *string
	BlockHash               *string
	BlockNumber             *int64
	BlockExtraData          *string
}

func (*ExecutionBadBlockFilter) AddAfter

func (f *ExecutionBadBlockFilter) AddAfter(after time.Time)

func (*ExecutionBadBlockFilter) AddBefore

func (f *ExecutionBadBlockFilter) AddBefore(before time.Time)

func (*ExecutionBadBlockFilter) AddBlockExtraData

func (f *ExecutionBadBlockFilter) AddBlockExtraData(data string)

func (*ExecutionBadBlockFilter) AddBlockHash

func (f *ExecutionBadBlockFilter) AddBlockHash(hash string)

func (*ExecutionBadBlockFilter) AddBlockNumber

func (f *ExecutionBadBlockFilter) AddBlockNumber(number int64)

func (*ExecutionBadBlockFilter) AddExecutionImplementation

func (f *ExecutionBadBlockFilter) AddExecutionImplementation(impl string)

func (*ExecutionBadBlockFilter) AddID

func (f *ExecutionBadBlockFilter) AddID(id string)

func (*ExecutionBadBlockFilter) AddLocation

func (f *ExecutionBadBlockFilter) AddLocation(location string)

func (*ExecutionBadBlockFilter) AddNetwork

func (f *ExecutionBadBlockFilter) AddNetwork(network string)

func (*ExecutionBadBlockFilter) AddNode

func (f *ExecutionBadBlockFilter) AddNode(node string)

func (*ExecutionBadBlockFilter) AddNodeVersion

func (f *ExecutionBadBlockFilter) AddNodeVersion(nodeVersion string)

func (*ExecutionBadBlockFilter) ApplyToQuery

func (f *ExecutionBadBlockFilter) ApplyToQuery(query *gorm.DB) (*gorm.DB, error)

func (*ExecutionBadBlockFilter) Validate

func (f *ExecutionBadBlockFilter) Validate() error

type ExecutionBlockTrace

type ExecutionBlockTrace struct {
	gorm.Model
	ID                      string    `gorm:"primaryKey"`
	Node                    string    `gorm:"index"`
	FetchedAt               time.Time `gorm:"index"`
	ExecutionImplementation string
	NodeVersion             string `gorm:"not null;default:''"`
	Location                string `gorm:"not null;default:''"`
	Network                 string `gorm:"not null;default:''"`
	BlockHash               string `gorm:"not null;default:''"`
	BlockNumber             int64
}

type ExecutionBlockTraceFilter

type ExecutionBlockTraceFilter struct {
	ID                      *string
	Node                    *string
	Before                  *time.Time
	After                   *time.Time
	NodeVersion             *string
	Location                *string
	Network                 *string
	ExecutionImplementation *string
	BlockHash               *string
	BlockNumber             *int64
}

func (*ExecutionBlockTraceFilter) AddAfter

func (f *ExecutionBlockTraceFilter) AddAfter(after time.Time)

func (*ExecutionBlockTraceFilter) AddBefore

func (f *ExecutionBlockTraceFilter) AddBefore(before time.Time)

func (*ExecutionBlockTraceFilter) AddBlockHash

func (f *ExecutionBlockTraceFilter) AddBlockHash(hash string)

func (*ExecutionBlockTraceFilter) AddBlockNumber

func (f *ExecutionBlockTraceFilter) AddBlockNumber(number int64)

func (*ExecutionBlockTraceFilter) AddExecutionImplementation

func (f *ExecutionBlockTraceFilter) AddExecutionImplementation(impl string)

func (*ExecutionBlockTraceFilter) AddID

func (f *ExecutionBlockTraceFilter) AddID(id string)

func (*ExecutionBlockTraceFilter) AddLocation

func (f *ExecutionBlockTraceFilter) AddLocation(location string)

func (*ExecutionBlockTraceFilter) AddNetwork

func (f *ExecutionBlockTraceFilter) AddNetwork(network string)

func (*ExecutionBlockTraceFilter) AddNode

func (f *ExecutionBlockTraceFilter) AddNode(node string)

func (*ExecutionBlockTraceFilter) AddNodeVersion

func (f *ExecutionBlockTraceFilter) AddNodeVersion(nodeVersion string)

func (*ExecutionBlockTraceFilter) ApplyToQuery

func (f *ExecutionBlockTraceFilter) ApplyToQuery(query *gorm.DB) (*gorm.DB, error)

func (*ExecutionBlockTraceFilter) Validate

func (f *ExecutionBlockTraceFilter) Validate() error

type Indexer

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

func NewIndexer

func NewIndexer(namespace string, log logrus.FieldLogger, config Config) (*Indexer, error)

func (*Indexer) CountBeaconState

func (i *Indexer) CountBeaconState(ctx context.Context, filter *BeaconStateFilter) (int64, error)

func (*Indexer) CountExecutionBadBlock

func (i *Indexer) CountExecutionBadBlock(ctx context.Context, filter *ExecutionBadBlockFilter) (int64, error)

func (*Indexer) CountExecutionBlockTrace

func (i *Indexer) CountExecutionBlockTrace(ctx context.Context, filter *ExecutionBlockTraceFilter) (int64, error)

func (*Indexer) DeleteBeaconState

func (i *Indexer) DeleteBeaconState(ctx context.Context, id string) error

func (*Indexer) DeleteExecutionBadBlock

func (i *Indexer) DeleteExecutionBadBlock(ctx context.Context, id string) error

func (*Indexer) DeleteExecutionBlockTrace

func (i *Indexer) DeleteExecutionBlockTrace(ctx context.Context, id string) error

func (*Indexer) DistinctBeaconStateValues

func (i *Indexer) DistinctBeaconStateValues(ctx context.Context, fields []string) (*DistinctBeaconStateValueResults, error)

func (*Indexer) DistinctExecutionBadBlockValues

func (i *Indexer) DistinctExecutionBadBlockValues(ctx context.Context, fields []string) (*DistinctExecutionBadBlockValueResults, error)

func (*Indexer) DistinctExecutionBlockTraceValues

func (i *Indexer) DistinctExecutionBlockTraceValues(ctx context.Context, fields []string) (*DistinctExecutionBlockTraceValueResults, error)

func (*Indexer) InsertBeaconState

func (i *Indexer) InsertBeaconState(ctx context.Context, state *BeaconState) error

func (*Indexer) InsertExecutionBadBlock

func (i *Indexer) InsertExecutionBadBlock(ctx context.Context, trace *ExecutionBadBlock) error

func (*Indexer) InsertExecutionBlockTrace

func (i *Indexer) InsertExecutionBlockTrace(ctx context.Context, trace *ExecutionBlockTrace) error

func (*Indexer) ListBeaconState

func (i *Indexer) ListBeaconState(ctx context.Context, filter *BeaconStateFilter, page *PaginationCursor) ([]*BeaconState, error)

func (*Indexer) ListExecutionBadBlock

func (i *Indexer) ListExecutionBadBlock(ctx context.Context, filter *ExecutionBadBlockFilter, page *PaginationCursor) ([]*ExecutionBadBlock, error)

func (*Indexer) ListExecutionBlockTrace

func (i *Indexer) ListExecutionBlockTrace(ctx context.Context, filter *ExecutionBlockTraceFilter, page *PaginationCursor) ([]*ExecutionBlockTrace, error)

func (*Indexer) RemoveBeaconState

func (i *Indexer) RemoveBeaconState(ctx context.Context, id string) error

func (*Indexer) Start

func (i *Indexer) Start(ctx context.Context) error

func (*Indexer) Stop

func (i *Indexer) Stop(ctx context.Context) error

func (*Indexer) UpdateBeaconState

func (i *Indexer) UpdateBeaconState(ctx context.Context, state *BeaconState) error

type Operation

type Operation string
const (
	OperationInsertBeaconState Operation = "insert_beacon_state_metadata"
	OperationDeleteBeaconState Operation = "delete_beacon_state_metadata"
	OperationCountBeaconState  Operation = "count_beacon_state_metadata"
	OperationListBeaconState   Operation = "list_beacon_state_metadata"
	OperationUpdateBeaconState Operation = "update_beacon_state_metadata"

	OperationDistinctValues Operation = "distinct_values"

	OperationInsertExecutionBlockTrace Operation = "insert_execution_block_trace"
	OperationDeleteExecutionBlockTrace Operation = "delete_execution_block_trace"
	OperationCountExecutionBlockTrace  Operation = "count_execution_block_trace"
	OperationListExecutionBlockTrace   Operation = "list_execution_block_trace"
	OperationUpdateExecutionBlockTrace Operation = "update_execution_block_trace"

	OperationInsertExecutionBadBlock Operation = "insert_execution_bad_block"
	OperationDeleteExecutionBadBlock Operation = "delete_execution_bad_block"
	OperationCountExecutionBadBlock  Operation = "count_execution_bad_block"
	OperationListExecutionBadBlock   Operation = "list_execution_bad_block"
	OperationUpdateExecutionBadBlock Operation = "update_execution_bad_block"
)

type PaginationCursor

type PaginationCursor struct {
	// The cursor to start from.
	Offset int `json:"offset"`
	// The number of items to return.
	Limit int `json:"limit"`
	// OrderBy is the column to order by.
	OrderBy string `json:"order_by"`
}

func (*PaginationCursor) ApplyOffsetLimit

func (p *PaginationCursor) ApplyOffsetLimit(query *gorm.DB) *gorm.DB

func (*PaginationCursor) ApplyOrderBy

func (p *PaginationCursor) ApplyOrderBy(query *gorm.DB) *gorm.DB

func (*PaginationCursor) Validate

func (p *PaginationCursor) Validate() error

Jump to

Keyboard shortcuts

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