model

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: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeStaking = "staking"

	ActionValidatorAdded   = "joined_active_set"
	ActionValidatorRemoved = "left_active_set"
	ActionValidatorKicked  = "kicked"
	ActionBalanceChanged   = "balance_changed"

	ItemTypeValidator = "validator"
)

Variables

View Source
var (
	TimeIntervalTypes = map[string]TimeInterval{
		"daily":   TimeIntervalDaily,
		"monthly": TimeIntervalMonthly,
		"yearly":  TimeIntervalYearly,
	}
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID             int64        `json:"-"`
	Name           string       `json:"name"`
	StartHeight    types.Height `json:"start_height"`
	StartTime      time.Time    `json:"start_time"`
	LastHeight     types.Height `json:"last_height"`
	LastTime       time.Time    `json:"last_time"`
	Balance        types.Amount `json:"balance"`
	StakingBalance types.Amount `json:"staking_balance"`
	CreatedAt      time.Time    `json:"-"`
	UpdatedAt      time.Time    `json:"-"`
}

func (Account) Validate

func (acc Account) Validate() error

Validate returns an error if account is invalid

type AccountDelegationsSummary added in v0.14.0

type AccountDelegationsSummary struct {
	StakingBalance    types.Amount `gorm:"column:staking_balance"`
	StakingPoolsCount int          `gorm:"column:staking_pools_count"`
}

type Block

type Block struct {
	ID                types.Height `json:"id"`
	Time              time.Time    `json:"time"`
	Producer          string       `json:"producer"`
	Hash              string       `json:"hash"`
	Epoch             string       `json:"epoch"`
	GasPrice          types.Amount `json:"gas_price"`
	GasLimit          uint         `json:"gas_allowed"`
	GasUsed           uint         `json:"gas_used"`
	TotalSupply       types.Amount `json:"total_supply"`
	ChunksCount       int          `json:"chunks_count"`
	TransactionsCount int          `json:"transactions_count"`
	ApprovalsCount    int          `json:"approvals_count"`
	CreatedAt         time.Time    `json:"created_at"`
}

func (Block) Validate

func (b Block) Validate() error

Validate returns an error if block data is invalid

type Delegation added in v0.3.0

type Delegation struct {
	ID              int          `json:"-"`
	Account         string       `json:"account"`
	UnstakedBalance types.Amount `json:"unstaked_balance"`
	StakedBalance   types.Amount `json:"staked_balance"`
	CanWithdraw     bool         `json:"can_withdraw"`
}

func (Delegation) TableName added in v0.3.0

func (Delegation) TableName() string

func (Delegation) Validate added in v0.3.0

func (d Delegation) Validate() error

type DelegatorEpoch added in v0.5.0

type DelegatorEpoch struct {
	ID                  int64        `json:"-"`
	AccountID           string       `json:"account_id"`
	ValidatorID         string       `json:"validator_id"`
	Epoch               string       `json:"epoch"`
	DistributedAtEpoch  string       `json:"distributed_at_epoch"`
	DistributedAtHeight types.Height `json:"distributed_at_height"`
	DistributedAtTime   time.Time    `json:"distributed_at_time"`
	StakedBalance       types.Amount `json:"staked_balance"`
	UnstakedBalance     types.Amount `json:"unstaked_balance"`
	Reward              types.Amount `json:"reward"`
}

func (DelegatorEpoch) TableName added in v0.5.0

func (DelegatorEpoch) TableName() string

type Epoch added in v0.3.0

type Epoch struct {
	ID                string    `json:"id"`
	StartHeight       uint64    `json:"start_height"`
	StartTime         time.Time `json:"start_time"`
	EndHeight         uint64    `json:"end_height"`
	EndTime           time.Time `json:"end_time"`
	BlocksCount       uint      `json:"blocks_count"`
	ValidatorsCount   uint      `json:"validators_count"`
	AverageEfficiency float64   `json:"average_efficiency"`
}

func (Epoch) TableName added in v0.3.0

func (Epoch) TableName() string

func (Epoch) Validate added in v0.3.0

func (e Epoch) Validate() error

type Event added in v0.3.0

type Event struct {
	ID          int       `json:"id"`
	Scope       string    `json:"scope"`
	Action      string    `json:"action"`
	BlockHeight uint64    `json:"block_height"`
	BlockTime   time.Time `json:"block_time"`
	Epoch       string    `json:"epoch"`
	ItemID      string    `json:"item_id"`
	ItemType    string    `json:"item_type"`
	Metadata    types.Map `json:"metadata"`
	CreatedAt   time.Time `json:"created_at"`
}

func (Event) TableName added in v0.3.0

func (Event) TableName() string

func (Event) Validate added in v0.3.0

func (e Event) Validate() error

type Model

type Model struct {
	ID        int64     `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type RewardsSummary added in v0.5.0

type RewardsSummary struct {
	Interval  string       `json:"interval"`
	Validator string       `json:"validator"`
	Amount    types.Amount `json:"amount"`
}

type TimeInterval added in v0.5.0

type TimeInterval uint
const (
	TimeIntervalDaily TimeInterval = iota
	TimeIntervalMonthly
	TimeIntervalYearly
)

func GetTypeForTimeInterval added in v0.5.0

func GetTypeForTimeInterval(s string) (TimeInterval, bool)

func (TimeInterval) String added in v0.5.0

func (k TimeInterval) String() string

type Transaction

type Transaction struct {
	Model

	Time         time.Time       `json:"time"`
	Height       types.Height    `json:"height"`
	Hash         string          `json:"hash"`
	BlockHash    string          `json:"block_hash"`
	Sender       string          `json:"sender"`
	Receiver     string          `json:"receiver"`
	GasBurnt     string          `json:"gas_burnt"`
	Fee          string          `json:"fee"`
	PublicKey    string          `json:"public_key"`
	Signature    string          `json:"signature"`
	Actions      json.RawMessage `json:"actions"`
	ActionsCount int             `json:"actions_count"`
	Outcome      json.RawMessage `json:"outcome"`
	Receipt      json.RawMessage `json:"receipt"`
	Success      bool            `json:"success"`
}

func (Transaction) IsReceiverPool added in v0.16.1

func (t Transaction) IsReceiverPool() bool

IsReceiverPool checks if receiver is a pool name

func (Transaction) Validate

func (t Transaction) Validate() error

Validate returns an error if transaction is invalid

type TransactionAction added in v0.2.0

type TransactionAction struct {
	Type string      `json:"type"`
	Data interface{} `json:"data"`
}

type TransactionsByDelegator added in v0.16.1

type TransactionsByDelegator struct {
	Validator string
	Amount    big.Int
	Type      string
}

TransactionsByDelegator this is supposed to be used for reward calculation

type Validator

type Validator struct {
	ID             int64        `json:"-"`
	Height         types.Height `json:"height"`
	Time           time.Time    `json:"time"`
	AccountID      string       `json:"account_id"`
	Epoch          string       `json:"epoch"`
	ExpectedBlocks int          `json:"expected_blocks"`
	ProducedBlocks int          `json:"produced_blocks"`
	Slashed        bool         `json:"slashed"`
	Stake          types.Amount `json:"stake"`
	Efficiency     float64      `json:"efficiency"`
	RewardFee      *int         `json:"reward_fee"`
	CreatedAt      time.Time    `json:"-"`
	UpdatedAt      time.Time    `json:"-"`
}

func (Validator) TableName

func (Validator) TableName() string

func (Validator) Validate

func (v Validator) Validate() error

type ValidatorAgg

type ValidatorAgg struct {
	ID             int64        `json:"-"`
	AccountID      string       `json:"account_id"`
	StartHeight    types.Height `json:"start_height"`
	StartTime      time.Time    `json:"start_time"`
	LastHeight     types.Height `json:"last_height"`
	LastTime       time.Time    `json:"last_time"`
	ExpectedBlocks int          `json:"expected_blocks"`
	ProducedBlocks int          `json:"produced_blocks"`
	Active         bool         `json:"active"`
	Slashed        bool         `json:"slashed"`
	Stake          types.Amount `json:"stake"`
	Efficiency     float64      `json:"efficiency"`
	RewardFee      *int         `json:"reward_fee"`
	CreatedAt      time.Time    `json:"-"`
	UpdatedAt      time.Time    `json:"-"`
}

ValidatorAgg represents validator data at latest height

func (ValidatorAgg) TableName

func (ValidatorAgg) TableName() string

type ValidatorEpoch

type ValidatorEpoch struct {
	ID             int64        `json:"-"`
	AccountID      string       `json:"-"`
	Epoch          string       `json:"epoch"`
	LastHeight     types.Height `json:"last_height"`
	LastTime       time.Time    `json:"last_time"`
	ExpectedBlocks int          `json:"expected_blocks"`
	ProducedBlocks int          `json:"produced_blocks"`
	Efficiency     float64      `json:"efficiency"`
	StakingBalance types.Amount `json:"staking_balance"`
	RewardFee      *int         `json:"reward_fee"`
}

func (ValidatorEpoch) TableName added in v0.1.2

func (ValidatorEpoch) TableName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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