database

package
v0.0.0-...-b9e5fcc Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Builder

func Builder(ctx *db.Context) (db.Database, error)

Builder allows to create a new Db instance implementing the db.Builder type

Types

type Db

type Db struct {
	*postgresql.Database
	Sqlx *sqlx.DB
}

Db represents a PostgreSQL database with expanded features. so that it can properly store custom BigDipper-related data.

func Cast

func Cast(db db.Database) *Db

Cast allows to cast the given db to a Db instance

func (*Db) DeleteCompletedRedelegations

func (db *Db) DeleteCompletedRedelegations(timestamp time.Time) error

DeleteCompletedRedelegations deletes all the redelegations that have completed before the given timestamp

func (*Db) DeleteCompletedUnbondingDelegations

func (db *Db) DeleteCompletedUnbondingDelegations(timestamp time.Time) error

DeleteCompletedUnbondingDelegations deletes all the unbonding delegations that have completed before the given timestamp

func (*Db) DeleteDelegatorDelegations

func (db *Db) DeleteDelegatorDelegations(delegator string) error

DeleteDelegatorDelegations removes all the delegations associated with the given delegator

func (*Db) DeleteDelegatorRewardsAmount

func (db *Db) DeleteDelegatorRewardsAmount(delegatorAddr string, height int64) error

DeleteDelegatorRewardsAmount deletes the rewards for the given delegator-validator tuple at the given height

func (*Db) DeleteDelegatorsToRefresh

func (db *Db) DeleteDelegatorsToRefresh(height int64) ([]string, error)

DeleteDelegatorsToRefresh removes and returns the list of delegators whose balance should be updated at the given height

func (*Db) DeleteRedelegation

func (db *Db) DeleteRedelegation(redelegation types.Redelegation) error

DeleteRedelegation removes the given redelegation from the database

func (*Db) DeleteUnbondingDelegation

func (db *Db) DeleteUnbondingDelegation(delegation types.UnbondingDelegation) error

DeleteUnbondingDelegation removes the given unbonding delegation from the database

func (*Db) DeleteValidatorDelegations

func (db *Db) DeleteValidatorDelegations(valOperAddr string) error

DeleteValidatorDelegations removes all the delegations associated with the given validator consensus address

func (*Db) GetAccountBalance

func (db *Db) GetAccountBalance(address string) ([]sdk.Coin, error)

GetAccountBalance returns the balance of the user having the given address

func (*Db) GetAccounts

func (db *Db) GetAccounts() ([]string, error)

GetAccounts returns all the accounts that are currently stored inside the database.

func (*Db) GetBlockHeightTimeDayAgo

func (db *Db) GetBlockHeightTimeDayAgo(now time.Time) (dbtypes.BlockRow, error)

GetBlockHeightTimeDayAgo return block height and time that a block proposals about a day (24hour) ago from input date

func (*Db) GetBlockHeightTimeHourAgo

func (db *Db) GetBlockHeightTimeHourAgo(now time.Time) (dbtypes.BlockRow, error)

GetBlockHeightTimeHourAgo return block height and time that a block proposals about a hour ago from input date

func (*Db) GetBlockHeightTimeMinuteAgo

func (db *Db) GetBlockHeightTimeMinuteAgo(now time.Time) (dbtypes.BlockRow, error)

GetBlockHeightTimeMinuteAgo return block height and time that a block proposals about a minute ago from input date

func (*Db) GetDelegators

func (db *Db) GetDelegators() ([]string, error)

GetDelegators returns the current delegators set

func (*Db) GetGenesis

func (db *Db) GetGenesis() (*types.Genesis, error)

GetGenesis returns the genesis information stored inside the database

func (*Db) GetGovParams

func (db *Db) GetGovParams() (*types.GovParams, error)

GetGovParams returns the most recent governance parameters

func (*Db) GetLastBlock

func (db *Db) GetLastBlock() (*dbtypes.BlockRow, error)

GetLastBlock returns the last block stored inside the database based on the heights

func (*Db) GetLastBlockHeight

func (db *Db) GetLastBlockHeight() (int64, error)

GetLastBlockHeight returns the last block height stored inside the database

func (*Db) GetOpenProposalsIds

func (db *Db) GetOpenProposalsIds() ([]uint64, error)

GetOpenProposalsIds returns all the ids of the proposals that are currently in deposit or voting period

func (*Db) GetProposal

func (db *Db) GetProposal(id uint64) (*types.Proposal, error)

GetProposal returns the proposal with the given id, or nil if not found

func (*Db) GetStakingParams

func (db *Db) GetStakingParams() (*types.StakingParams, error)

GetStakingParams returns the types.StakingParams instance containing the current params

func (*Db) GetTokenUnits

func (db *Db) GetTokenUnits() ([]types.TokenUnit, error)

GetTokenUnits returns the slice of all the names of the different tokens units

func (*Db) GetUserDelegationsAmount

func (db *Db) GetUserDelegationsAmount(address string) (sdk.Coins, error)

GetUserDelegationsAmount returns the amount of the delegations currently stored for the user having the given address

func (*Db) GetUserDelegatorRewardsAmount

func (db *Db) GetUserDelegatorRewardsAmount(address string) (sdk.DecCoins, error)

GetUserDelegatorRewardsAmount returns the amount of rewards that the given user has currently associated

func (*Db) GetUserRedelegationsAmount

func (db *Db) GetUserRedelegationsAmount(address string) (sdk.Coins, error)

GetUserRedelegationsAmount returns the amount of the redelegations currently stored for the user having the given address

func (*Db) GetUserUnBondingDelegationsAmount

func (db *Db) GetUserUnBondingDelegationsAmount(address string) (sdk.Coins, error)

GetUserUnBondingDelegationsAmount returns the amount of the redelegations currently stored for the user having the given address

func (*Db) GetUserValidatorCommissionAmount

func (db *Db) GetUserValidatorCommissionAmount(address string) (sdk.DecCoins, error)

GetUserValidatorCommissionAmount returns the current amount of the validator commission that is associated with the user having the given address

func (*Db) GetValidator

func (db *Db) GetValidator(valAddress string) (types.Validator, error)

GetValidator returns the validator having the given address. If no validator for such address can be found, an error is returned instead.

func (*Db) GetValidatorBySelfDelegateAddress

func (db *Db) GetValidatorBySelfDelegateAddress(address string) (types.Validator, error)

GetValidatorBySelfDelegateAddress returns the validator having the given address as the self_delegate_address, or an error if such validator cannot be found.

func (*Db) GetValidatorConsensusAddress

func (db *Db) GetValidatorConsensusAddress(address string) (sdk.ConsAddress, error)

GetValidatorConsensusAddress returns the consensus address of the validator having the given operator address

func (*Db) GetValidatorOperatorAddress

func (db *Db) GetValidatorOperatorAddress(consAddr string) (sdk.ValAddress, error)

GetValidatorOperatorAddress returns the operator address of the validator having the given consensus address

func (*Db) GetValidators

func (db *Db) GetValidators() ([]types.Validator, error)

GetValidators returns all the validators that are currently stored inside the database.

func (*Db) HasDelegatorRewards

func (db *Db) HasDelegatorRewards() (bool, error)

HasDelegatorRewards checks if the database contains any delegation reward

func (*Db) HasValidatorCommission

func (db *Db) HasValidatorCommission() (bool, error)

HasValidatorCommission checks if the database contains any validators commission

func (*Db) InsertEnableModules

func (db *Db) InsertEnableModules(modules []string) error

InsertEnableModules allows to save enabled module into the database

func (*Db) Prune

func (db *Db) Prune(height int64) error

Prune implements db.PruningDb

func (*Db) SaveAccountBalanceHistory

func (db *Db) SaveAccountBalanceHistory(entry types.AccountBalanceHistory) error

SaveAccountBalanceHistory saves the given entry inside the account_balance_history table

func (*Db) SaveAccountBalances

func (db *Db) SaveAccountBalances(balances []types.AccountBalance) error

SaveAccountBalances allows to store the given balances inside the database

func (*Db) SaveAccounts

func (db *Db) SaveAccounts(accounts []types.Account) error

SaveAccounts saves the given accounts inside the database

func (*Db) SaveAverageBlockTimeGenesis

func (db *Db) SaveAverageBlockTimeGenesis(averageTime float64, height int64) error

SaveAverageBlockTimeGenesis save the average block time in average_block_time_from_genesis table

func (*Db) SaveAverageBlockTimePerDay

func (db *Db) SaveAverageBlockTimePerDay(averageTime float64, height int64) error

SaveAverageBlockTimePerDay save the average block time in average_block_time_per_day table

func (*Db) SaveAverageBlockTimePerHour

func (db *Db) SaveAverageBlockTimePerHour(averageTime float64, height int64) error

SaveAverageBlockTimePerHour save the average block time in average_block_time_per_hour table

func (*Db) SaveAverageBlockTimePerMin

func (db *Db) SaveAverageBlockTimePerMin(averageTime float64, height int64) error

SaveAverageBlockTimePerMin save the average block time in average_block_time_per_minute table

func (*Db) SaveCommunityPool

func (db *Db) SaveCommunityPool(coin sdk.DecCoins, height int64) error

SaveCommunityPool allows to save for the given height the given total amount of coins

func (*Db) SaveDelegations

func (db *Db) SaveDelegations(delegations []types.Delegation) error

SaveDelegations stores inside the database the given delegations data. It assumes that the validators addresses are already present inside the proper database table. TIP: To store the validators data call SaveValidatorsData.

func (*Db) SaveDelegatorsRewardsAmounts

func (db *Db) SaveDelegatorsRewardsAmounts(amounts []types.DelegatorRewardAmount) error

SaveDelegatorsRewardsAmounts allows to store the given delegator reward amounts as the most updated ones

func (*Db) SaveDelegatorsToRefresh

func (db *Db) SaveDelegatorsToRefresh(height int64, delegators []string) error

SaveDelegatorsToRefresh stores the given delegators as accounts to be refreshed on the block at height + 1

func (*Db) SaveDeposits

func (db *Db) SaveDeposits(deposits []types.Deposit) error

SaveDeposits allows to save multiple deposits

func (*Db) SaveDistributionParams

func (db *Db) SaveDistributionParams(params *types.DistributionParams) error

SaveDistributionParams allows to store the given distribution parameters inside the database

func (*Db) SaveDoubleSignEvidence

func (db *Db) SaveDoubleSignEvidence(evidence types.DoubleSignEvidence) error

SaveDoubleSignEvidence saves the given double sign evidence inside the proper tables

func (*Db) SaveGenesis

func (db *Db) SaveGenesis(genesis *types.Genesis) error

SaveGenesis save the given genesis data

func (*Db) SaveGovParams

func (db *Db) SaveGovParams(params *types.GovParams) error

SaveGovParams saves the given x/gov parameters inside the database

func (*Db) SaveInflation

func (db *Db) SaveInflation(inflation sdk.Dec, height int64) error

SaveInflation allows to store the inflation for the given block height as well as timestamp

func (*Db) SaveMintParams

func (db *Db) SaveMintParams(params *types.MintParams) error

SaveMintParams allows to store the given params inside the database

func (*Db) SaveProposalStakingPoolSnapshot

func (db *Db) SaveProposalStakingPoolSnapshot(snapshot types.ProposalStakingPoolSnapshot) error

SaveProposalStakingPoolSnapshot allows to save the given snapshot of the staking pool

func (*Db) SaveProposalValidatorsStatusesSnapshots

func (db *Db) SaveProposalValidatorsStatusesSnapshots(snapshots []types.ProposalValidatorStatusSnapshot) error

SaveProposalValidatorsStatusesSnapshots allows to save the given validator statuses snapshots

func (*Db) SaveProposals

func (db *Db) SaveProposals(proposals []types.Proposal) error

SaveProposals allows to save for the given height the given total amount of coins

func (*Db) SaveRedelegations

func (db *Db) SaveRedelegations(redelegations []types.Redelegation) error

SaveRedelegations saves the given redelegations inside the database. It assumes that all the validators as well as all the delegators addresses are already present inside the proper tables of the database. To store the validators data call SaveValidatorData(s). To store the account data call SaveAccount.

func (*Db) SaveSlashingParams

func (db *Db) SaveSlashingParams(params *types.SlashingParams) error

SaveSlashingParams saves the slashing params for the given height

func (*Db) SaveStakingParams

func (db *Db) SaveStakingParams(params types.StakingParams) error

SaveStakingParams allows to store the given params into the database

func (*Db) SaveStakingPool

func (db *Db) SaveStakingPool(pool *types.Pool) error

SaveStakingPool allows to save for the given height the given stakingtypes pool

func (*Db) SaveSupply

func (db *Db) SaveSupply(coins sdk.Coins, height int64) error

SaveSupply allows to save for the given height the given total amount of coins

func (*Db) SaveTallyResults

func (db *Db) SaveTallyResults(tallys []types.TallyResult) error

SaveTallyResults allows to save for the given height the given total amount of coins

func (*Db) SaveToken

func (db *Db) SaveToken(token types.Token) error

SaveToken allows to save the given token details

func (*Db) SaveTokenPricesHistory

func (db *Db) SaveTokenPricesHistory(prices []types.TokenPrice) error

SaveTokenPricesHistory stores the given prices as historic ones

func (*Db) SaveTokensPrices

func (db *Db) SaveTokensPrices(prices []types.TokenPrice) error

SaveTokensPrices allows to save the given prices as the most updated ones

func (*Db) SaveUnbondingDelegations

func (db *Db) SaveUnbondingDelegations(delegations []types.UnbondingDelegation) error

SaveUnbondingDelegations saves the given unbonding delegations into the database. It assumes that all the validators as well as all the delegators addresses are already present inside the proper tables of the database. To store the validators data call SaveValidatorData(s). To store the account data call SaveAccount.

func (*Db) SaveValidatorCommission

func (db *Db) SaveValidatorCommission(data types.ValidatorCommission) error

SaveValidatorCommission saves a single validator commission. It assumes that the delegator address is already present inside the proper database table. TIP: To store the validator data call SaveValidatorData.

func (*Db) SaveValidatorCommissionAmount

func (db *Db) SaveValidatorCommissionAmount(amount types.ValidatorCommissionAmount) error

SaveValidatorCommissionAmount allows to store the given validator commission amount as the most updated one

func (*Db) SaveValidatorData

func (db *Db) SaveValidatorData(validator types.Validator) error

SaveValidatorData saves properly the information about the given validator.

func (*Db) SaveValidatorDescription

func (db *Db) SaveValidatorDescription(description types.ValidatorDescription) error

SaveValidatorDescription save a single validator description. It assumes that the delegator address is already present inside the proper database table. TIP: To store the validator data call SaveValidatorData.

func (*Db) SaveValidatorsData

func (db *Db) SaveValidatorsData(validators []types.Validator) error

SaveValidatorsData allows the bulk saving of a list of validators.

func (*Db) SaveValidatorsSigningInfos

func (db *Db) SaveValidatorsSigningInfos(infos []types.ValidatorSigningInfo) error

SaveValidatorsSigningInfos saves the given infos inside the database

func (*Db) SaveValidatorsStatuses

func (db *Db) SaveValidatorsStatuses(statuses []types.ValidatorStatus) error

SaveValidatorsStatuses save validator jail and status in the given height and timestamp

func (*Db) SaveValidatorsVotingPowers

func (db *Db) SaveValidatorsVotingPowers(entries []types.ValidatorVotingPower) error

SaveValidatorsVotingPowers saves the given validator voting powers. It assumes that the delegator address is already present inside the proper database table. TIP: To store the validator data call SaveValidatorData.

func (*Db) SaveVestingAccounts

func (db *Db) SaveVestingAccounts(vestingAccounts []exported.VestingAccount) error

SaveVestingAccounts saves the given vesting accounts inside the database

func (*Db) SaveVote

func (db *Db) SaveVote(vote types.Vote) error

SaveVote allows to save for the given height and the message vote

func (*Db) UpdateProposal

func (db *Db) UpdateProposal(update types.ProposalUpdate) error

UpdateProposal updates a proposal stored inside the database

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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