store

package
v0.18.14 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BucketHour = "h"
	BucketDay  = "d"
)

Variables

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

Functions

This section is empty.

Types

type AccountsStore

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

AccountsStore handles operations on account

func (AccountsStore) Conn

func (s AccountsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (AccountsStore) Create

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

Create creates a new record. Must pass a pointer.

func (AccountsStore) DeleteByHeight

func (s AccountsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (AccountsStore) FindByName

func (s AccountsStore) FindByName(name string) (*model.Account, error)

FindByName returns an account for a name

func (AccountsStore) Import

func (s AccountsStore) Import(records []model.Account) error

Import imports new records and updates existing ones

func (AccountsStore) Truncate

func (s AccountsStore) Truncate() error

Truncate removes all records from the table

func (AccountsStore) Update

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

Update updates the existing record. Must pass a pointer.

type BlocksStore

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

BlocksStore handles operations on blocks

func (BlocksStore) BlockStats

func (s BlocksStore) BlockStats(bucket string, limit uint) ([]byte, error)

BlockStats returns block stats for a given interval

func (BlocksStore) BlockTimes

func (s BlocksStore) BlockTimes(limit int64) ([]byte, error)

BlockTimes returns recent blocks averages

func (BlocksStore) Conn

func (s BlocksStore) Conn() *sql.DB

Conn returns an underlying database connection

func (BlocksStore) Create

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

Create creates a new record. Must pass a pointer.

func (BlocksStore) CreateIfNotExists

func (s BlocksStore) CreateIfNotExists(block *model.Block) error

CreateIfNotExists creates the block if it does not exist

func (BlocksStore) DeleteByHeight

func (s BlocksStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (BlocksStore) FindBy

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

FindBy returns a block for a matching attribute

func (BlocksStore) FindByHash

func (s BlocksStore) FindByHash(hash string) (*model.Block, error)

FindByHash returns a block with the matching hash

func (BlocksStore) FindByHeight

func (s BlocksStore) FindByHeight(height uint64) (*model.Block, error)

FindByHeight returns a block with the matching height

func (BlocksStore) FindPrevious added in v0.3.0

func (s BlocksStore) FindPrevious(height uint64) (*model.Block, error)

FindPrevious returns a block prior to the given height

func (BlocksStore) Import

func (s BlocksStore) Import(records []model.Block) error

Import creates block records in batch

func (BlocksStore) Last added in v0.3.0

func (s BlocksStore) Last() (*model.Block, error)

Last returns the last indexed block

func (BlocksStore) LastInEpoch added in v0.3.0

func (s BlocksStore) LastInEpoch(epoch string) (*model.Block, error)

LastInEpoch returns the last block in the given epoch

func (BlocksStore) Search

func (s BlocksStore) Search() ([]model.Block, error)

Search returns matching blocks

func (BlocksStore) Truncate

func (s BlocksStore) Truncate() error

Truncate removes all records from the table

func (BlocksStore) Update

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

Update updates the existing record. Must pass a pointer.

type DelegatorEpochsSearch added in v0.7.0

type DelegatorEpochsSearch struct {
	AccountID   string `form:"account_id"`
	ValidatorID string `form:"validator_id"`
	Epoch       string `form:"epoch"`
}

func (*DelegatorEpochsSearch) Validate added in v0.7.0

func (s *DelegatorEpochsSearch) Validate() error

type DelegatorsStore added in v0.5.0

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

DelegatorsStore handles operations on blocks

func (DelegatorsStore) AccountDelegationsSummary added in v0.14.0

func (s DelegatorsStore) AccountDelegationsSummary(account string) (*model.AccountDelegationsSummary, error)

AccountDelegationsSummary returns account delegations summary for the last epoch

func (DelegatorsStore) Conn added in v0.5.0

func (s DelegatorsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (DelegatorsStore) Create added in v0.5.0

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

Create creates a new record. Must pass a pointer.

func (DelegatorsStore) DeleteByHeight added in v0.5.0

func (s DelegatorsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (*DelegatorsStore) FetchRewardsByInterval added in v0.5.0

func (s *DelegatorsStore) FetchRewardsByInterval(account string, validatorId string, from time.Time, to time.Time, timeInterval model.TimeInterval) ([]model.RewardsSummary, error)

FetchRewardsByInterval fetches reward by interval

func (DelegatorsStore) FindDelegatorEpochBy added in v0.5.0

func (s DelegatorsStore) FindDelegatorEpochBy(epoch string, accountId string, validatorId string) (*model.DelegatorEpoch, error)

FindDelegatorEpochBy returns delegator epoch by epoch and account id

func (DelegatorsStore) ImportDelegatorEpochs added in v0.5.0

func (s DelegatorsStore) ImportDelegatorEpochs(records []model.DelegatorEpoch) error

ImportDelegatorEpochs creates new validators in batch

func (DelegatorsStore) SearchDelegatorEpochs added in v0.7.0

func (s DelegatorsStore) SearchDelegatorEpochs(search DelegatorEpochsSearch) ([]model.DelegatorEpoch, error)

SearchDelegatorEpochs performs a delegator epoch search and returns matching records

func (DelegatorsStore) Truncate added in v0.5.0

func (s DelegatorsStore) Truncate() error

Truncate removes all records from the table

func (DelegatorsStore) Update added in v0.5.0

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

Update updates the existing record. Must pass a pointer.

type EpochsStore added in v0.3.0

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

EpochsStore manages epochs records

func (EpochsStore) Conn added in v0.3.0

func (s EpochsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (EpochsStore) Create added in v0.3.0

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

Create creates a new record. Must pass a pointer.

func (EpochsStore) DeleteByHeight added in v0.3.0

func (s EpochsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (EpochsStore) FindByID added in v0.3.0

func (s EpochsStore) FindByID(id string) (*model.Epoch, error)

FindByID returns an epoch for a given ID

func (*EpochsStore) FindUnIndexedDelegatorsEpochs added in v0.9.0

func (s *EpochsStore) FindUnIndexedDelegatorsEpochs() ([]model.Epoch, error)

FindUnIndexedDelegatorsEpochs fetches un indexed delegators' epochs

func (EpochsStore) Import added in v0.3.0

func (s EpochsStore) Import(records []model.Epoch) error

Import created epochs records in batch

func (EpochsStore) Recent added in v0.3.0

func (s EpochsStore) Recent(limit int) ([]model.Epoch, error)

Recent returns a set of recent epochs

func (EpochsStore) Truncate added in v0.3.0

func (s EpochsStore) Truncate() error

Truncate removes all records from the table

func (EpochsStore) Update added in v0.3.0

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

Update updates the existing record. Must pass a pointer.

func (EpochsStore) UpdateCounts added in v0.3.0

func (s EpochsStore) UpdateCounts(ids []string) error

UpdateCounts updates epoch counts for a given set of epoch IDs

type EventsSearch added in v0.3.0

type EventsSearch struct {
	Pagination

	ItemID   string `form:"item_id"`
	ItemType string `form:"item_type"`
	Action   string `form:"action"`
	Height   uint64 `form:"height"`
	Epoch    string `form:"epoch"`
}

type EventsStore added in v0.3.0

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

EventsStore manages events records

func (EventsStore) Conn added in v0.3.0

func (s EventsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (EventsStore) Create added in v0.3.0

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

Create creates a new record. Must pass a pointer.

func (EventsStore) DeleteByHeight added in v0.3.0

func (s EventsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (EventsStore) FindByID added in v0.3.0

func (s EventsStore) FindByID(id int) (*model.Event, error)

FindByID returns an event for a given ID

func (EventsStore) Import added in v0.3.0

func (s EventsStore) Import(records []model.Event) error

func (EventsStore) Search added in v0.3.0

func (s EventsStore) Search(search EventsSearch) (*PaginatedResult, error)

Search performs an event search and returns matching records

func (EventsStore) Truncate added in v0.3.0

func (s EventsStore) Truncate() error

Truncate removes all records from the table

func (EventsStore) Update added in v0.3.0

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

Update updates the existing record. Must pass a pointer.

type HeightRange added in v0.3.0

type HeightRange struct {
	Start uint64
	End   uint64
}

type PaginatedResult added in v0.3.0

type PaginatedResult struct {
	Page    uint        `json:"page"`
	Pages   *uint       `json:"pages,omitempty"`
	Limit   uint        `json:"limit"`
	Count   *uint       `json:"count,omitempty"`
	Records interface{} `json:"records"`
}

type Pagination added in v0.3.0

type Pagination struct {
	Page  uint `form:"page"`
	Limit uint `form:"limit"`
}

func (*Pagination) Validate added in v0.3.0

func (p *Pagination) Validate() error

type StatsStore

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

func (StatsStore) Conn

func (s StatsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (StatsStore) Create

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

Create creates a new record. Must pass a pointer.

func (StatsStore) CreateBlockStats

func (s StatsStore) CreateBlockStats(bucket string, timeRange TimeRange) error

CreateBlockStats populates block stats for given block height range

func (StatsStore) CreateValidatorsStats

func (s StatsStore) CreateValidatorsStats(bucket string, ts time.Time) error

CreateValidatorsStats populates validators stats for a time bucket

func (StatsStore) DeleteByHeight

func (s StatsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (StatsStore) Truncate

func (s StatsStore) Truncate() error

Truncate removes all records from the table

func (StatsStore) Update

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

Update updates the existing record. Must pass a pointer.

type Store

type Store struct {
	Blocks        BlocksStore
	Epochs        EpochsStore
	Accounts      AccountsStore
	Delegators    DelegatorsStore
	Validators    ValidatorsStore
	ValidatorAggs ValidatorAggsStore
	Transactions  TransactionsStore
	Stats         StatsStore
	Events        EventsStore
	// 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) Conn

func (s *Store) Conn() *sql.DB

Conn returns an underlying database connection

func (*Store) ResetAll

func (s *Store) ResetAll() error

ResetAll performs a full database reset without dropping any objects

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 TimeRange added in v0.3.0

type TimeRange struct {
	Start time.Time
	End   time.Time
}

func (TimeRange) FullRange added in v0.3.0

func (t TimeRange) FullRange(bucket string) (time.Time, time.Time, error)

type TransactionsSearch added in v0.3.3

type TransactionsSearch struct {
	Pagination

	BlockHash   string `form:"block_hash"`
	BlockHeight uint64 `form:"block_height"`
	Sender      string `form:"sender"`
	Receiver    string `form:"receiver"`
	Account     string `form:"account"`
	StartDate   string `form:"start_date"`
	EndDate     string `form:"end_date"`
	StartHeight int    `form:"start_height"`
	EndHeight   int    `form:"end_height"`
	// contains filtered or unexported fields
}

func (*TransactionsSearch) Validate added in v0.3.3

func (s *TransactionsSearch) Validate() error

type TransactionsStore added in v0.2.0

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

func (TransactionsStore) Conn added in v0.2.0

func (s TransactionsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (TransactionsStore) Create added in v0.2.0

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

Create creates a new record. Must pass a pointer.

func (TransactionsStore) DeleteByHeight added in v0.2.0

func (s TransactionsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (TransactionsStore) FindByBlock added in v0.2.1

func (s TransactionsStore) FindByBlock(hash string) ([]model.Transaction, error)

FindByBlock returns a collection of transactions for a block hash

func (TransactionsStore) FindByHash added in v0.2.1

func (s TransactionsStore) FindByHash(hash string) (*model.Transaction, error)

FindByHash returns a transaction record by hash

func (TransactionsStore) FindByHeight added in v0.11.0

func (s TransactionsStore) FindByHeight(height uint64) ([]model.Transaction, error)

FindByHeight returns transactions for given height

func (TransactionsStore) FindByHeightRange added in v0.12.1

func (s TransactionsStore) FindByHeightRange(startHeight, endHeight uint64) ([]model.Transaction, error)

FindByHeightRange returns transactions for a given block height range

func (TransactionsStore) FindLowestHeightTransaction added in v0.11.0

func (s TransactionsStore) FindLowestHeightTransaction() (*model.Transaction, error)

FindLowestHeightTransaction returns transaction with the lowest height

func (TransactionsStore) FindTransactionsConfirmActions added in v0.16.1

func (s TransactionsStore) FindTransactionsConfirmActions(start, end uint64) ([]model.Transaction, error)

FindTransactionsConfirmActions returns transactions with confirm actions

func (TransactionsStore) Import added in v0.2.0

func (s TransactionsStore) Import(records []model.Transaction) error

Import imports transactions in bulk

func (TransactionsStore) Recent added in v0.2.1

func (s TransactionsStore) Recent(n int) ([]model.Transaction, error)

Recent returns the most recent N transactions

func (TransactionsStore) Search added in v0.3.3

Search performs a transaction search and returns matching records

func (TransactionsStore) SearchAccount added in v0.18.9

func (s TransactionsStore) SearchAccount(search TransactionsSearch) (*PaginatedResult, error)

Search performs a transaction search and returns matching records

func (TransactionsStore) Truncate added in v0.2.0

func (s TransactionsStore) Truncate() error

Truncate removes all records from the table

func (TransactionsStore) Update added in v0.2.0

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

Update updates the existing record. Must pass a pointer.

func (TransactionsStore) UpdateTransactionMissingFields added in v0.11.0

func (s TransactionsStore) UpdateTransactionMissingFields(trx model.Transaction) error

UpdateTransactionMissingFields updates transactions missing fields

type ValidatorAggsStore

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

func (ValidatorAggsStore) All

All returns all validator records

func (ValidatorAggsStore) Conn

func (s ValidatorAggsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (ValidatorAggsStore) Create

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

Create creates a new record. Must pass a pointer.

func (ValidatorAggsStore) DeleteByHeight

func (s ValidatorAggsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (ValidatorAggsStore) FindBy

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

FindBy returns an validator agg record for a key and value

func (ValidatorAggsStore) FindValidatorEpochs added in v0.1.2

func (s ValidatorAggsStore) FindValidatorEpochs(account string, limit int) ([]model.ValidatorEpoch, error)

FindValidatorEpochs returns the last N validator epochs

func (ValidatorAggsStore) FindValidatorEpochsByEpoch added in v0.9.0

func (s ValidatorAggsStore) FindValidatorEpochsByEpoch(epoch string) ([]model.ValidatorEpoch, error)

FindValidatorEpochsByEpoch returns validator epochs for given epoch

func (ValidatorAggsStore) Import

func (s ValidatorAggsStore) Import(records []model.ValidatorAgg) error

Import create validator aggregates in batch

func (ValidatorAggsStore) ImportValidatorEpochs

func (s ValidatorAggsStore) ImportValidatorEpochs(records []model.ValidatorEpoch) error

ImportValidatorEpochs imports validator epochs records in batch

func (ValidatorAggsStore) PaginateValidatorEpochs added in v0.3.0

func (s ValidatorAggsStore) PaginateValidatorEpochs(account string, pagination Pagination) (*PaginatedResult, error)

PaginateValidatorEpochs returns a paginated search of validator epochs

func (ValidatorAggsStore) Top

Top returns top validators

func (ValidatorAggsStore) Truncate

func (s ValidatorAggsStore) Truncate() error

Truncate removes all records from the table

func (ValidatorAggsStore) Update

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

Update updates the existing record. Must pass a pointer.

type ValidatorsStore

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

ValidatorsStore handles operations on blocks

func (ValidatorsStore) ByHeight

func (s ValidatorsStore) ByHeight(height types.Height) ([]model.Validator, error)

ByHeight returns all transactions for a given height

func (ValidatorsStore) Cleanup

func (s ValidatorsStore) Cleanup(keepHeights uint64) (int64, error)

Cleanup removes old validator records and keeps the N most recent ones

func (ValidatorsStore) Conn

func (s ValidatorsStore) Conn() *sql.DB

Conn returns an underlying database connection

func (ValidatorsStore) Create

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

Create creates a new record. Must pass a pointer.

func (ValidatorsStore) DeleteByHeight

func (s ValidatorsStore) DeleteByHeight(height uint64) error

DeleteByHeight removes all records associated with a height

func (ValidatorsStore) Import

func (s ValidatorsStore) Import(records []model.Validator) error

Import creates new validators in batch

func (ValidatorsStore) Truncate

func (s ValidatorsStore) Truncate() error

Truncate removes all records from the table

func (ValidatorsStore) Update

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

Update updates the existing record. Must pass a pointer.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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