store

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type AccountAggStore

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

AccountAggStore handles operations on accounts

func NewAccountAggStore

func NewAccountAggStore(db *gorm.DB) *AccountAggStore

func (AccountAggStore) All

func (s AccountAggStore) All() ([]model.AccountAgg, error)

All returns all accounts

func (AccountAggStore) Create

func (s AccountAggStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (AccountAggStore) CreateOrUpdate

func (s AccountAggStore) CreateOrUpdate(acc *model.AccountAgg) error

CreateOrUpdate creates a new account or updates an existing one

func (AccountAggStore) DeleteByHeight

func (s AccountAggStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (AccountAggStore) FindBy

func (s AccountAggStore) FindBy(key string, value interface{}) (*model.AccountAgg, error)

FindBy returns an account for a matching attribute

func (AccountAggStore) FindByID

func (s AccountAggStore) FindByID(id int64) (*model.AccountAgg, error)

FindByID returns an account for the ID

func (AccountAggStore) FindByPublicKey

func (s AccountAggStore) FindByPublicKey(key string) (*model.AccountAgg, error)

FindByPublicKey returns an account for the public key

func (AccountAggStore) Save

func (s AccountAggStore) Save(record interface{}) error

Save saves record to database

func (AccountAggStore) Truncate

func (s AccountAggStore) Truncate() error

Truncate removes all records from the table

func (AccountAggStore) Update

func (s AccountAggStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type AvgForTimeIntervalRow

type AvgForTimeIntervalRow struct {
	TimeInterval string  `json:"time_interval"`
	Avg          float64 `json:"avg"`
}

AvgForTimeIntervalRow result of time interval query

type AvgQuantityForTimeIntervalRow

type AvgQuantityForTimeIntervalRow struct {
	TimeInterval string         `json:"time_interval"`
	Avg          types.Quantity `json:"avg"`
}

AvgQuantityForTimeIntervalRow result of time interval query with quantity

type BlockSeqStore

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

BlockSeqStore handles operations on blocks

func NewBlockSeqStore

func NewBlockSeqStore(db *gorm.DB) *BlockSeqStore

func (BlockSeqStore) Create

func (s BlockSeqStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (BlockSeqStore) CreateIfNotExists

func (s BlockSeqStore) CreateIfNotExists(block *model.BlockSeq) error

CreateIfNotExists creates the block if it does not exist

func (BlockSeqStore) DeleteByHeight

func (s BlockSeqStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (BlockSeqStore) FindBy

func (s BlockSeqStore) FindBy(key string, value interface{}) (*model.BlockSeq, error)

FindBy returns a block for a matching attribute

func (BlockSeqStore) FindByHeight

func (s BlockSeqStore) FindByHeight(height int64) (*model.BlockSeq, error)

FindByHeight returns a block with the matching height

func (BlockSeqStore) FindByID

func (s BlockSeqStore) FindByID(id int64) (*model.BlockSeq, error)

FindByID returns a block with matching ID

func (*BlockSeqStore) GetAvgRecentTimes

func (s *BlockSeqStore) GetAvgRecentTimes(limit int64) GetAvgRecentTimesResult

GetAvgRecentTimes Gets average block times for recent blocks by limit

func (*BlockSeqStore) GetAvgTimesForInterval

func (s *BlockSeqStore) GetAvgTimesForInterval(interval string, period string) ([]GetAvgTimesForIntervalRow, error)

GetAvgTimesForInterval Gets average block times for interval

func (BlockSeqStore) Save

func (s BlockSeqStore) Save(record interface{}) error

Save saves record to database

func (BlockSeqStore) Truncate

func (s BlockSeqStore) Truncate() error

Truncate removes all records from the table

func (BlockSeqStore) Update

func (s BlockSeqStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type DebondingDelegationSeqStore

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

DebondingDelegationSeqStore handles operations on debondingDelegations

func NewDebondingDelegationSeqStore

func NewDebondingDelegationSeqStore(db *gorm.DB) *DebondingDelegationSeqStore

func (DebondingDelegationSeqStore) Create

func (s DebondingDelegationSeqStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (DebondingDelegationSeqStore) CreateIfNotExists

func (s DebondingDelegationSeqStore) CreateIfNotExists(debondingDelegation *model.DebondingDelegationSeq) error

CreateIfNotExists creates the debondingDelegation if it does not exist

func (DebondingDelegationSeqStore) DeleteByHeight

func (s DebondingDelegationSeqStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (DebondingDelegationSeqStore) FindByHeight

FindByHeight finds debonding delegations by height

func (*DebondingDelegationSeqStore) FindRecentByDelegatorUID

func (s *DebondingDelegationSeqStore) FindRecentByDelegatorUID(key string, limit int64) ([]model.DebondingDelegationSeq, error)

FindRecentByDelegatorUID gets recent debonding delegations for delegator

func (*DebondingDelegationSeqStore) FindRecentByValidatorUID

func (s *DebondingDelegationSeqStore) FindRecentByValidatorUID(key string, limit int64) ([]model.DebondingDelegationSeq, error)

FindRecentByValidatorUID gets recent debonding delegations for validator

func (DebondingDelegationSeqStore) Save

func (s DebondingDelegationSeqStore) Save(record interface{}) error

Save saves record to database

func (DebondingDelegationSeqStore) Truncate

func (s DebondingDelegationSeqStore) Truncate() error

Truncate removes all records from the table

func (DebondingDelegationSeqStore) Update

func (s DebondingDelegationSeqStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type DelegationSeqStore

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

DelegationSeqStore handles operations on delegations

func NewDelegationSeqStore

func NewDelegationSeqStore(db *gorm.DB) *DelegationSeqStore

func (DelegationSeqStore) Create

func (s DelegationSeqStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (DelegationSeqStore) CreateIfNotExists

func (s DelegationSeqStore) CreateIfNotExists(delegation *model.DelegationSeq) error

CreateIfNotExists creates the delegation if it does not exist

func (DelegationSeqStore) DeleteByHeight

func (s DelegationSeqStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (DelegationSeqStore) FindByHeight

func (s DelegationSeqStore) FindByHeight(h int64) ([]model.DelegationSeq, error)

FindByHeight finds delegation by height

func (*DelegationSeqStore) FindCurrentByDelegatorUID

func (s *DelegationSeqStore) FindCurrentByDelegatorUID(key string) ([]model.DelegationSeq, error)

GetCurrentByDelegatorUID gets current delegations for delegator

func (*DelegationSeqStore) FindLastByValidatorUID

func (s *DelegationSeqStore) FindLastByValidatorUID(key string) ([]model.DelegationSeq, error)

GetLastByValidatorUID finds last delegations for validator

func (DelegationSeqStore) Save

func (s DelegationSeqStore) Save(record interface{}) error

Save saves record to database

func (DelegationSeqStore) Truncate

func (s DelegationSeqStore) Truncate() error

Truncate removes all records from the table

func (DelegationSeqStore) Update

func (s DelegationSeqStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

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 GetAvgTimesForInterval query

type ReportsStore

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

ReportsStore handles operations on reports

func NewReportsStore

func NewReportsStore(db *gorm.DB) *ReportsStore

func (ReportsStore) Create

func (s ReportsStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (ReportsStore) DeleteByHeight

func (s ReportsStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (ReportsStore) Last

func (s ReportsStore) Last() (*model.Report, error)

Last returns the last report

func (ReportsStore) Save

func (s ReportsStore) Save(record interface{}) error

Save saves record to database

func (ReportsStore) Truncate

func (s ReportsStore) Truncate() error

Truncate removes all records from the table

func (ReportsStore) Update

func (s ReportsStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type StakingSeqStore

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

StakingSeqStore handles operations on staking

func NewStakingSeqStore

func NewStakingSeqStore(db *gorm.DB) *StakingSeqStore

func (StakingSeqStore) Create

func (s StakingSeqStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (StakingSeqStore) CreateIfNotExists

func (s StakingSeqStore) CreateIfNotExists(staking *model.StakingSeq) error

CreateIfNotExists creates the staking if it does not exist

func (StakingSeqStore) DeleteByHeight

func (s StakingSeqStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (StakingSeqStore) FindBy

func (s StakingSeqStore) FindBy(key string, value interface{}) (*model.StakingSeq, error)

FindBy returns a staking for a matching attribute

func (StakingSeqStore) FindByHeight

func (s StakingSeqStore) FindByHeight(height int64) (*model.StakingSeq, error)

FindByHeight returns a staking with the matching height

func (StakingSeqStore) FindByID

func (s StakingSeqStore) FindByID(id int64) (*model.StakingSeq, error)

FindByID returns a staking with matching ID

func (StakingSeqStore) Recent

func (s StakingSeqStore) Recent() (*model.StakingSeq, error)

Recent returns the most recent staking

func (StakingSeqStore) Save

func (s StakingSeqStore) Save(record interface{}) error

Save saves record to database

func (StakingSeqStore) Truncate

func (s StakingSeqStore) Truncate() error

Truncate removes all records from the table

func (StakingSeqStore) Update

func (s StakingSeqStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type Store

type Store struct {
	Syncables *SyncablesStore
	Reports   *ReportsStore

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

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

Store handles all database operations

func New

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

New 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 struct {
	// contains filtered or unexported fields
}

SyncablesStore handles operations on syncables

func NewSyncablesStore

func NewSyncablesStore(db *gorm.DB) *SyncablesStore

func (SyncablesStore) Create

func (s SyncablesStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (SyncablesStore) CreateOrUpdate

func (s SyncablesStore) CreateOrUpdate(val *model.Syncable) error

CreateOrUpdate creates a new syncable or updates an existing one

func (SyncablesStore) DeleteByHeight

func (s SyncablesStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (SyncablesStore) FindByHeight

func (s SyncablesStore) FindByHeight(height int64) (syncable *model.Syncable, err error)

Exists returns true if a syncable exists at give height

func (SyncablesStore) FindMostRecent

func (s SyncablesStore) FindMostRecent() (*model.Syncable, error)

FindMostRecent returns the most recent processed syncable for type

func (SyncablesStore) Save

func (s SyncablesStore) Save(record interface{}) error

Save saves record to database

func (SyncablesStore) Truncate

func (s SyncablesStore) Truncate() error

Truncate removes all records from the table

func (SyncablesStore) Update

func (s SyncablesStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type TransactionSeqStore

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

TransactionSeqStore handles operations on transactions

func NewTransactionSeqStore

func NewTransactionSeqStore(db *gorm.DB) *TransactionSeqStore

func (TransactionSeqStore) Create

func (s TransactionSeqStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (TransactionSeqStore) CreateIfNotExists

func (s TransactionSeqStore) CreateIfNotExists(transaction *model.TransactionSeq) error

CreateIfNotExists creates the transaction if it does not exist

func (TransactionSeqStore) DeleteByHeight

func (s TransactionSeqStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (TransactionSeqStore) FindByHeight

func (s TransactionSeqStore) FindByHeight(h int64) ([]model.TransactionSeq, error)

func (TransactionSeqStore) Save

func (s TransactionSeqStore) Save(record interface{}) error

Save saves record to database

func (TransactionSeqStore) Truncate

func (s TransactionSeqStore) Truncate() error

Truncate removes all records from the table

func (TransactionSeqStore) Update

func (s TransactionSeqStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type ValidatorAggStore

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

ValidatorAggStore handles operations on validators

func NewValidatorAggStore

func NewValidatorAggStore(db *gorm.DB) *ValidatorAggStore

func (ValidatorAggStore) All

All returns all validators

func (ValidatorAggStore) Create

func (s ValidatorAggStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (ValidatorAggStore) CreateOrUpdate

func (s ValidatorAggStore) CreateOrUpdate(val *model.ValidatorAgg) error

CreateOrUpdate creates a new validator or updates an existing one

func (ValidatorAggStore) DeleteByHeight

func (s ValidatorAggStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (ValidatorAggStore) FindBy

func (s ValidatorAggStore) FindBy(key string, value interface{}) (*model.ValidatorAgg, error)

FindBy returns an validator for a matching attribute

func (*ValidatorAggStore) FindByEntityUID

func (s *ValidatorAggStore) FindByEntityUID(key string) (*model.ValidatorAgg, error)

FindByEntityUID return validator by entity UID

func (ValidatorAggStore) FindByID

func (s ValidatorAggStore) FindByID(id int64) (*model.ValidatorAgg, error)

FindByID returns an validator for the ID

func (*ValidatorAggStore) GetAllForHeightGreaterThan

func (s *ValidatorAggStore) GetAllForHeightGreaterThan(height int64) ([]model.ValidatorAgg, error)

GetAllForHeightGreaterThan returns validators who have been validating since given height

func (ValidatorAggStore) Save

func (s ValidatorAggStore) Save(record interface{}) error

Save saves record to database

func (ValidatorAggStore) Truncate

func (s ValidatorAggStore) Truncate() error

Truncate removes all records from the table

func (ValidatorAggStore) Update

func (s ValidatorAggStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

type ValidatorSeqStore

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

ValidatorSeqStore handles operations on validators

func NewValidatorSeqStore

func NewValidatorSeqStore(db *gorm.DB) *ValidatorSeqStore

func (ValidatorSeqStore) Create

func (s ValidatorSeqStore) Create(record interface{}) error

Create creates a new record. Must pass a pointer.

func (ValidatorSeqStore) CreateIfNotExists

func (s ValidatorSeqStore) CreateIfNotExists(validator *model.ValidatorSeq) error

CreateIfNotExists creates the validator if it does not exist

func (ValidatorSeqStore) DeleteByHeight

func (s ValidatorSeqStore) DeleteByHeight(height int64) error

DeleteByHeight removes all records associated with a height

func (ValidatorSeqStore) FindByHeight

func (s ValidatorSeqStore) FindByHeight(h int64) ([]model.ValidatorSeq, error)

FindByHeight finds validator by height

func (*ValidatorSeqStore) GetTotalMissedByEntityUID

func (s *ValidatorSeqStore) GetTotalMissedByEntityUID(key string) (*int64, error)

GetTotalMissedByEntityUID gets total missed blocks for validator

func (*ValidatorSeqStore) GetTotalProposedByEntityUID

func (s *ValidatorSeqStore) GetTotalProposedByEntityUID(key string) (*int64, error)

GetTotalProposedByEntityUID gets total proposed blocks for validator

func (*ValidatorSeqStore) GetTotalSharesForInterval

func (s *ValidatorSeqStore) GetTotalSharesForInterval(interval string, period string) ([]AvgQuantityForTimeIntervalRow, error)

GetTotalSharesForInterval gets total shares of all validators for interval

func (*ValidatorSeqStore) GetTotalValidatedByEntityUID

func (s *ValidatorSeqStore) GetTotalValidatedByEntityUID(key string) (*int64, error)

GetTotalValidatedByEntityUID gets total validated blocks for validator

func (*ValidatorSeqStore) GetTotalVotingPowerForInterval

func (s *ValidatorSeqStore) GetTotalVotingPowerForInterval(interval string, period string) ([]AvgForTimeIntervalRow, error)

GetTotalVotingPowerForInterval gets total voting power of all validators for interval

func (*ValidatorSeqStore) GetValidatorSharesForInterval

func (s *ValidatorSeqStore) GetValidatorSharesForInterval(key string, interval string, period string) ([]AvgQuantityForTimeIntervalRow, error)

GetValidatorSharesForInterval gets shares for validator for interval

func (*ValidatorSeqStore) GetValidatorUptimeForInterval

func (s *ValidatorSeqStore) GetValidatorUptimeForInterval(key string, interval string, period string) ([]AvgForTimeIntervalRow, error)

GetValidatorUptimeForInterval gets uptime for validator for interval

func (*ValidatorSeqStore) GetValidatorVotingPowerForInterval

func (s *ValidatorSeqStore) GetValidatorVotingPowerForInterval(key string, interval string, period string) ([]AvgForTimeIntervalRow, error)

GetValidatorVotingPowerForInterval gets voting powers for validator for interval

func (ValidatorSeqStore) Save

func (s ValidatorSeqStore) Save(record interface{}) error

Save saves record to database

func (ValidatorSeqStore) Truncate

func (s ValidatorSeqStore) Truncate() error

Truncate removes all records from the table

func (ValidatorSeqStore) Update

func (s ValidatorSeqStore) Update(record interface{}) error

Update updates the existing record. Must pass a pointer.

Jump to

Keyboard shortcuts

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