store

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("record not found")
)

Functions

func NewAccountAggStore

func NewAccountAggStore(db *gorm.DB) *accountAggStore

func NewBalanceEventsStore added in v0.6.0

func NewBalanceEventsStore(db *gorm.DB) *balanceEventsStore

func NewBalanceSummaryStore added in v0.6.0

func NewBalanceSummaryStore(db *gorm.DB) *balanceSummaryStore

func NewBlockSeqStore

func NewBlockSeqStore(db *gorm.DB) *blockSeqStore

func NewBlockSummaryStore added in v0.4.0

func NewBlockSummaryStore(db *gorm.DB) *blockSummaryStore

func NewDatabaseStore added in v0.4.0

func NewDatabaseStore(db *gorm.DB) *databaseStore

func NewDebondingDelegationSeqStore

func NewDebondingDelegationSeqStore(db *gorm.DB) *debondingDelegationSeqStore

func NewDelegationSeqStore

func NewDelegationSeqStore(db *gorm.DB) *delegationSeqStore

func NewReportsStore

func NewReportsStore(db *gorm.DB) *reportsStore

func NewStakingSeqStore

func NewStakingSeqStore(db *gorm.DB) *stakingSeqStore

func NewSyncablesStore

func NewSyncablesStore(db *gorm.DB) *syncablesStore

func NewSystemEventsStore added in v0.5.0

func NewSystemEventsStore(db *gorm.DB) *systemEventsStore

func NewTransactionSeqStore

func NewTransactionSeqStore(db *gorm.DB) *transactionSeqStore

func NewValidatorAggStore

func NewValidatorAggStore(db *gorm.DB) *validatorAggStore

func NewValidatorSeqStore

func NewValidatorSeqStore(db *gorm.DB) *validatorSeqStore

func NewValidatorSummaryStore added in v0.4.0

func NewValidatorSummaryStore(db *gorm.DB) *validatorSummaryStore

Types

type AccountAggStore

type AccountAggStore interface {
	BaseStore

	FindBy(string, interface{}) (*model.AccountAgg, error)
	FindByPublicKey(string) (*model.AccountAgg, error)
}

type ActivityPeriodRow added in v0.4.2

type ActivityPeriodRow struct {
	Period int64
	Min    types.Time
	Max    types.Time
}

type BalanceEventsStore added in v0.6.0

type BalanceEventsStore interface {
	BaseStore

	GetLastEventTime() (types.Time, error)
	CreateOrUpdate(*model.BalanceEvent) error
	DeleteOlderThan(time.Time) (*int64, error)
	Summarize(types.SummaryInterval, []ActivityPeriodRow) ([]model.BalanceSummary, error)
}

type BalanceSummaryStore added in v0.6.0

type BalanceSummaryStore interface {
	BaseStore

	Find(*model.BalanceSummary) (*model.BalanceSummary, error)
	GetSummariesByInterval(interval types.SummaryInterval, address string, start, end *types.Time) ([]model.BalanceSummary, error)
	FindActivityPeriods(types.SummaryInterval, int64) ([]ActivityPeriodRow, error)
}

type BaseStore added in v0.5.0

type BaseStore interface {
	Create(record interface{}) error
	Update(record interface{}) error
	Save(record interface{}) error
}

type BlockSeqStore

type BlockSeqStore interface {
	BaseStore

	FindBy(string, interface{}) (*model.BlockSeq, error)
	FindByHeight(int64) (*model.BlockSeq, error)
	GetAvgRecentTimes(int64) (*GetAvgRecentTimesResult, error)
	FindMostRecent() (*model.BlockSeq, error)
	DeleteOlderThan(time.Time, []ActivityPeriodRow) (*int64, error)
	Summarize(types.SummaryInterval, []ActivityPeriodRow) ([]BlockSeqSummary, error)
}

type BlockSeqSummary added in v0.4.0

type BlockSeqSummary struct {
	TimeBucket   types.Time `json:"time_bucket"`
	Count        int64      `json:"count"`
	BlockTimeAvg float64    `json:"block_time_avg"`
}

type BlockSummaryStore added in v0.4.0

type BlockSummaryStore interface {
	BaseStore

	Find(*model.BlockSummary) (*model.BlockSummary, error)
	FindMostRecentByInterval(types.SummaryInterval) (*model.BlockSummary, error)
	FindActivityPeriods(types.SummaryInterval, int64) ([]ActivityPeriodRow, error)
	FindSummary(types.SummaryInterval, string) ([]model.BlockSummary, error)
	DeleteOlderThan(types.SummaryInterval, time.Time) (*int64, error)
}

type DatabaseStore added in v0.4.0

type DatabaseStore interface {
	GetTotalSize() (*GetTotalSizeResult, error)
}

type DebondingDelegationSeqStore

type DebondingDelegationSeqStore interface {
	BaseStore

	FindByHeight(int64) ([]model.DebondingDelegationSeq, error)
	FindRecentByValidatorUID(string, int64) ([]model.DebondingDelegationSeq, error)
	FindRecentByDelegatorUID(string, int64) ([]model.DebondingDelegationSeq, error)
}

type DelegationSeqStore

type DelegationSeqStore interface {
	BaseStore

	FindByHeight(int64) ([]model.DelegationSeq, error)
	FindLastByValidatorUID(string) ([]model.DelegationSeq, error)
	FindCurrentByDelegatorUID(string) ([]model.DelegationSeq, error)
}

type FindSystemEventByActorQuery added in v0.5.0

type FindSystemEventByActorQuery struct {
	Kind      *model.SystemEventKind
	MinHeight *int64
}

type GetAvgRecentTimesResult

type GetAvgRecentTimesResult struct {
	StartHeight int64   `json:"start_height"`
	EndHeight   int64   `json:"end_height"`
	StartTime   string  `json:"start_time"`
	EndTime     string  `json:"end_time"`
	Count       int64   `json:"count"`
	Diff        float64 `json:"diff"`
	Avg         float64 `json:"avg"`
}

GetAvgRecentTimesResult Contains results for GetAvgRecentTimes query

type GetAvgTimesForIntervalRow

type GetAvgTimesForIntervalRow struct {
	TimeInterval string  `json:"time_interval"`
	Count        int64   `json:"count"`
	Avg          float64 `json:"avg"`
}

GetAvgTimesForIntervalRow Contains row of data for FindSummary query

type GetTotalSizeResult added in v0.4.0

type GetTotalSizeResult struct {
	Size float64 `json:"size"`
}

GetAvgTimesForIntervalRow Contains row of data for FindSummary query

type ReportsStore

type ReportsStore interface {
	BaseStore

	FindNotCompletedByIndexVersion(int64, ...model.ReportKind) (*model.Report, error)
	FindNotCompletedByKind(...model.ReportKind) (*model.Report, error)
	Last() (*model.Report, error)
	DeleteByKinds([]model.ReportKind) error
}

type StakingSeqStore

type StakingSeqStore interface {
	BaseStore

	FindBy(key string, value interface{}) (*model.StakingSeq, error)
	FindByHeight(height int64) (*model.StakingSeq, error)
	Recent() (*model.StakingSeq, error)
}

type Store

type Store struct {
	Database      DatabaseStore
	Syncables     SyncablesStore
	Reports       ReportsStore
	SystemEvents  SystemEventsStore
	BalanceEvents BalanceEventsStore

	BlockSeq               BlockSeqStore
	DebondingDelegationSeq DebondingDelegationSeqStore
	DelegationSeq          DelegationSeqStore
	StakingSeq             StakingSeqStore
	TransactionSeq         TransactionSeqStore
	ValidatorSeq           ValidatorSeqStore

	BlockSummary     BlockSummaryStore
	ValidatorSummary ValidatorSummaryStore
	BalanceSummary   BalanceSummaryStore

	AccountAgg   AccountAggStore
	ValidatorAgg ValidatorAggStore
	// contains filtered or unexported fields
}

Store handles all database operations

func New

func New(connStr string) (*Store, error)

NewIndexerMetric returns a new store from the connection string

func (*Store) Close

func (s *Store) Close() error

Close closes the database connection

func (*Store) SetDebugMode

func (s *Store) SetDebugMode(enabled bool)

SetDebugMode enabled detailed query logging

func (*Store) Test

func (s *Store) Test() error

Test checks the connection status

type SyncablesStore

type SyncablesStore interface {
	BaseStore

	FindByHeight(int64) (*model.Syncable, error)
	FindMostRecent() (*model.Syncable, error)
	FindSmallestIndexVersion() (*int64, error)
	FindFirstByDifferentIndexVersion(int64) (*model.Syncable, error)
	FindMostRecentByDifferentIndexVersion(int64) (*model.Syncable, error)
	GetSyncableForMinTime(time time.Time) (result *model.Syncable, err error)
	CreateOrUpdate(*model.Syncable) error
	ResetProcessedAtForRange(int64, int64) error
}

type SystemEventsStore added in v0.5.0

type SystemEventsStore interface {
	BaseStore

	FindByHeight(int64) ([]model.SystemEvent, error)
	FindByActor(string, FindSystemEventByActorQuery) ([]model.SystemEvent, error)
	FindUnique(int64, string, model.SystemEventKind) (*model.SystemEvent, error)
	CreateOrUpdate(*model.SystemEvent) error
	FindMostRecent() (*model.SystemEvent, error)
	DeleteOlderThan(time.Time) (*int64, error)
}

type TransactionSeqStore

type TransactionSeqStore interface {
	BaseStore

	FindByHeight(h int64) ([]model.TransactionSeq, error)
}

type ValidatorAggStore

type ValidatorAggStore interface {
	BaseStore

	FindBy(string, interface{}) (*model.ValidatorAgg, error)
	FindByAddress(string) (*model.ValidatorAgg, error)
	FindByEntityUID(string) (*model.ValidatorAgg, error)
	GetAllForHeightGreaterThan(int64) ([]model.ValidatorAgg, error)
	CreateOrUpdate(val *model.ValidatorAgg) error
}

type ValidatorSeqStore

type ValidatorSeqStore interface {
	BaseStore

	FindByHeightAndEntityUID(int64, string) (*model.ValidatorSeq, error)
	FindByHeight(int64) ([]model.ValidatorSeq, error)
	FindLastByAddress(string, int64) ([]model.ValidatorSeq, error)
	FindMostRecent() (*model.ValidatorSeq, error)
	DeleteOlderThan(time.Time) (*int64, error)
	Summarize(types.SummaryInterval, []ActivityPeriodRow) ([]ValidatorSeqSummary, error)
}

type ValidatorSeqSummary added in v0.4.0

type ValidatorSeqSummary struct {
	Address                string         `json:"address"`
	TimeBucket             types.Time     `json:"time_bucket"`
	VotingPowerAvg         float64        `json:"voting_power_avg"`
	VotingPowerMax         float64        `json:"voting_power_max"`
	VotingPowerMin         float64        `json:"voting_power_min"`
	TotalSharesAvg         types.Quantity `json:"total_shares_avg"`
	TotalSharesMax         types.Quantity `json:"total_shares_max"`
	TotalSharesMin         types.Quantity `json:"total_shares_min"`
	ActiveEscrowBalanceAvg types.Quantity `json:"active_escrow_balance_avg"`
	ActiveEscrowBalanceMax types.Quantity `json:"active_escrow_balance_max"`
	ActiveEscrowBalanceMin types.Quantity `json:"active_escrow_balance_min"`
	CommissionAvg          types.Quantity `json:"commission_avg"`
	CommissionMax          types.Quantity `json:"commission_max"`
	CommissionMin          types.Quantity `json:"commission_min"`
	ValidatedSum           int64          `json:"validated_sum"`
	NotValidatedSum        int64          `json:"not_validated_sum"`
	ProposedSum            int64          `json:"proposed_sum"`
	UptimeAvg              float64        `json:"uptime_avg"`
}

type ValidatorSummaryRow added in v0.4.0

type ValidatorSummaryRow struct {
	TimeBucket             string         `json:"time_bucket"`
	TimeInterval           string         `json:"time_interval"`
	VotingPowerAvg         float64        `json:"voting_power_avg"`
	VotingPowerMax         float64        `json:"voting_power_max"`
	VotingPowerMin         float64        `json:"voting_power_min"`
	TotalSharesAvg         types.Quantity `json:"total_shares_avg"`
	TotalSharesMax         types.Quantity `json:"total_shares_max"`
	TotalSharesMin         types.Quantity `json:"total_shares_min"`
	ActiveEscrowBalanceAvg types.Quantity `json:"active_escrow_balance_avg"`
	ActiveEscrowBalanceMax types.Quantity `json:"active_escrow_balance_max"`
	ActiveEscrowBalanceMin types.Quantity `json:"active_escrow_balance_min"`
	CommissionAvg          types.Quantity `json:"commission_avg"`
	CommissionMax          types.Quantity `json:"commission_max"`
	CommissionMin          types.Quantity `json:"commission_min"`
	ValidatedSum           int64          `json:"validated_sum"`
	NotValidatedSum        int64          `json:"not_validated_sum"`
	ProposedSum            int64          `json:"proposed_sum"`
	UptimeAvg              float64        `json:"uptime_avg"`
}

type ValidatorSummaryStore added in v0.4.0

type ValidatorSummaryStore interface {
	BaseStore

	Find(*model.ValidatorSummary) (*model.ValidatorSummary, error)
	FindActivityPeriods(types.SummaryInterval, int64) ([]ActivityPeriodRow, error)
	FindAllByTimePeriod(start, end *types.Time, addresses ...string) ([]model.ValidatorSummary, error)
	FindSummary(types.SummaryInterval, string) ([]ValidatorSummaryRow, error)
	FindSummaryByAddress(string, types.SummaryInterval, string) ([]model.ValidatorSummary, error)
	FindMostRecent() (*model.ValidatorSummary, error)
	FindMostRecentByInterval(types.SummaryInterval) (*model.ValidatorSummary, error)
	DeleteOlderThan(types.SummaryInterval, time.Time) (*int64, error)
}

Jump to

Keyboard shortcuts

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