model

package
v0.19.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	TimeIntervalDaily TimeInterval = iota
	TimeIntervalMonthly
	TimeIntervalYearly

	RewardOwnerTypeValidator RewardOwnerType = "validator"
	RewardOwnerTypeDelegator RewardOwnerType = "delegator"
)
View Source
const (
	// Transaction types
	TxTypePayment             = "payment"
	TxTypeDelegation          = "delegation"
	TxTypeCoinbase            = "coinbase"
	TxTypeCoinbaseFeeTransfer = "fee_transfer_via_coinbase"
	TxTypeFeeTransfer         = "fee_transfer"
	TxTypeSnarkFee            = "snark_fee"

	// Transaction statuses
	TxStatusApplied = "applied"
	TxStatusFailed  = "failed"
)

Variables

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

	RewardOwnerTypes = map[string]RewardOwnerType{
		"validator": RewardOwnerTypeValidator,
		"delegator": RewardOwnerTypeDelegator,
	}
)

Functions

This section is empty.

Types

type Account

type Account struct {
	ID             string       `json:"-"`
	PublicKey      string       `json:"public_key"`
	Delegate       *string      `json:"delegate"`
	Balance        types.Amount `json:"balance"`
	BalanceUnknown types.Amount `json:"balance_unknown"`
	Stake          types.Amount `json:"stake"`
	Nonce          uint64       `json:"nonce"`
	StartHeight    uint64       `json:"start_height"`
	StartTime      time.Time    `json:"start_time"`
	LastHeight     uint64       `json:"last_height"`
	LastTime       time.Time    `json:"last_time"`
	CreatedAt      time.Time    `json:"-"`
	UpdatedAt      time.Time    `json:"-"`
}

Account contains the account details

func (Account) String

func (acc Account) String() string

String returns account text representation

func (Account) Validate

func (acc Account) Validate() error

Validate validates the record

type Block

type Block struct {
	ID                int            `json:"-"`
	Height            uint64         `json:"height"`
	Hash              string         `json:"hash"`
	ParentHash        string         `json:"parent_hash"`
	Time              time.Time      `json:"time"`
	Canonical         bool           `json:"canonical"`
	LedgerHash        string         `json:"ledger_hash"`
	SnarkedLedgerHash string         `json:"snarked_ledger_hash"`
	Creator           string         `json:"creator"`
	Coinbase          types.Amount   `json:"coinbase"`
	TotalCurrency     types.Amount   `json:"total_currency"`
	Epoch             int            `json:"epoch"`
	Slot              int            `json:"slot"`
	TransactionsCount int            `json:"transactions_count"`
	TransactionsFees  types.Amount   `json:"transactions_fees"`
	SnarkersCount     int            `json:"snarkers_count"`
	SnarkerAccounts   pq.StringArray `json:"snarker_accounts"`
	SnarkJobsCount    int            `json:"snark_jobs_count"`
	SnarkJobsFees     types.Amount   `json:"snark_jobs_fees"`
	RewardCalculated  bool           `json:"reward_calculated"`
	Supercharged      bool           `json:"supercharged"`
}

Block model contains block data

func (Block) EligibleForRewardCalculation added in v0.17.0

func (b Block) EligibleForRewardCalculation() bool

func (Block) TableName

func (Block) TableName() string

TableName returns the model table name

func (Block) Validate

func (b Block) Validate() error

Validate returns an error if block data is invalid

type BlockAvgStat

type BlockAvgStat 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"`
}

BlockAvgStat contains block averagess

type BlockIntervalStat

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

BlockIntervalStat contains block count stats for a given time interval

type BlockReward added in v0.11.0

type BlockReward struct {
	ID           string       `json:"-"`
	OwnerAccount string       `json:"owner_account"`
	Delegate     *string      `json:"delegate"`
	Epoch        int          `json:"epoch"`
	TimeBucket   time.Time    `json:"time_bucket"`
	Reward       types.Amount `json:"reward"`
	OwnerType    string       `json:"owner_type"`
}

BlockReward contains the reward details earned at a specific height

func (BlockReward) String added in v0.11.0

func (br BlockReward) String() string

String returns account text representation

type Delegation

type Delegation struct {
	PublicKey string       `json:"public_key"`
	Delegate  string       `json:"delegate"`
	Balance   types.Amount `json:"balance"`
	Weight    types.Float  `json:"-"`
}

type Ledger

type Ledger struct {
	ID                int          `json:"-"`
	Time              time.Time    `json:"time"`
	Epoch             int          `json:"epoch"`
	EntriesCount      int          `json:"entries_count"`
	StakedAmount      types.Amount `json:"staked_amount"`
	DelegationsCount  int          `json:"delegations_count"`
	DelegationsAmount types.Amount `json:"delegations_amount"`
}

func (Ledger) TableName

func (Ledger) TableName() string

type LedgerEntry

type LedgerEntry struct {
	ID                          int          `json:"-"`
	LedgerID                    int          `json:"-"`
	PublicKey                   string       `json:"public_key"`
	Delegate                    string       `json:"delegate"`
	Delegation                  bool         `json:"delegation"`
	Balance                     types.Amount `json:"balance"`
	TimingInitialMinimumBalance types.Amount `json:"timing_initial_minimum_balance"`
	TimingCliffTime             *int         `json:"timing_cliff_time"`
	TimingCliffAmount           types.Amount `json:"timing_cliff_amount"`
	TimingVestingPeriod         *int         `json:"timing_vesting_period"`
	TimingVestingIncrement      types.Amount `json:"timing_vesting_increment"`
}

func (LedgerEntry) IsUntimed added in v0.11.0

func (l LedgerEntry) IsUntimed() bool

func (LedgerEntry) TableName

func (LedgerEntry) TableName() string

type RewardOwnerType added in v0.11.0

type RewardOwnerType string

func GetTypeForRewardOwnerType added in v0.11.0

func GetTypeForRewardOwnerType(s string) (RewardOwnerType, bool)

type RewardsSummary added in v0.11.0

type RewardsSummary struct {
	Interval string       `json:"interval"`
	Epoch    string       `json:"epoch,omitempty"`
	Delegate string       `json:"delegate,omitempty"`
	Amount   types.Amount `json:"amount"`
}

type SnarkJob

type SnarkJob struct {
	ID         int          `json:"-"`
	Height     uint64       `json:"height"`
	BlockHash  string       `json:"block_hash"`
	Time       time.Time    `json:"time"`
	Prover     string       `json:"prover"`
	Fee        types.Amount `json:"fee"`
	WorksCount int          `json:"works_count"`
	CreatedAt  time.Time    `json:"-"`
}

SnarkJob contains a completed SNARK job details

func (SnarkJob) TableName

func (SnarkJob) TableName() string

TableName returns the Job table name

func (SnarkJob) Validate

func (j SnarkJob) Validate() error

Validate returns an error if job is invalid

type Snarker

type Snarker struct {
	ID          int       `json:"-"`
	Account     string    `json:"public_key"`
	Fee         uint64    `json:"fee"`
	JobsCount   int       `json:"jobs_count"`
	WorksCount  int       `json:"works_count"`
	StartHeight uint64    `json:"start_height"`
	StartTime   time.Time `json:"start_time"`
	LastHeight  uint64    `json:"last_height"`
	LastTime    time.Time `json:"last_time"`
	CreatedAt   time.Time `json:"-"`
	UpdatedAt   time.Time `json:"-"`
}

func (Snarker) Validate

func (s Snarker) Validate() error

type SnarkerJobFee added in v0.18.0

type SnarkerJobFee struct {
	Fee        types.Amount `json:"fee"`
	JobsCount  int          `json:"jobs_count"`
	WorksCount int          `json:"works_count"`
}

type SnarkerJobsStat added in v0.18.0

type SnarkerJobsStat struct {
	Time          time.Time    `json:"time"`
	FeeMin        types.Amount `json:"fee_min"`
	FeeMax        types.Amount `json:"fee_max"`
	FeeAvg        types.Amount `json:"fee_avg"`
	JobsCount     int          `json:"jobs_count"`
	SnarkersCount int          `json:"snarkers_count"`
	WorksCount    int          `json:"works_count"`
}

type SnarkerStat added in v0.18.0

type SnarkerStat struct {
	InclusionRatio float32      `json:"inclusion_ratio"`
	JobsPercent    float32      `json:"jobs_percent"`
	FeesAmount     types.Amount `json:"fees_amount"`
}

type SnarkerTimeStat added in v0.18.0

type SnarkerTimeStat struct {
	Time                 time.Time    `json:"time"`
	FeeMin               types.Amount `json:"fee_min"`
	FeeMax               types.Amount `json:"fee_max"`
	FeeAvg               types.Amount `json:"fee_avg"`
	JobsCount            int          `json:"jobs_count"`
	WorksCount           int          `json:"works_count"`
	BlocksCount          int          `json:"blocks_count"`
	CanonicalBlocksCount int          `json:"canonical_blocks_count"`
	InclusionRatio       float32      `json:"inclusion_ratio"`
	FeesAmount           types.Amount `json:"fees_amount"`
}

type TimeInterval added in v0.11.0

type TimeInterval uint

func GetTypeForTimeInterval added in v0.11.0

func GetTypeForTimeInterval(s string) (TimeInterval, bool)

func (TimeInterval) String added in v0.11.0

func (k TimeInterval) String() string

type Transaction

type Transaction struct {
	ID                      int          `json:"id"`
	Hash                    string       `json:"hash"`
	Type                    string       `json:"type"`
	BlockHash               string       `json:"block_hash"`
	BlockHeight             uint64       `json:"block_height"`
	Time                    time.Time    `json:"time"`
	Sender                  *string      `json:"sender"`
	Receiver                string       `json:"receiver"`
	Amount                  types.Amount `json:"amount"`
	Fee                     types.Amount `json:"fee"`
	Nonce                   *int         `json:"nonce"`
	Memo                    *string      `json:"memo"`
	Status                  string       `json:"status"`
	Canonical               bool         `json:"canonical"`
	FailureReason           *string      `json:"failure_reason"`
	SequenceNumber          *int         `json:"sequence_number"`
	SecondarySequenceNumber *int         `json:"secondary_sequence_number"`
	CreatedAt               time.Time    `json:"-"`
	UpdatedAt               time.Time    `json:"-"`
}

Transaction contains the blockchain transaction details

func (Transaction) TableName

func (Transaction) TableName() string

TableName returns the model table name

func (Transaction) Validate

func (t Transaction) Validate() error

Validate returns an error if transaction is invalid

type Validator

type Validator struct {
	ID             int          `json:"-"`
	IdentityName   *string      `json:"identity_name"`
	PublicKey      string       `json:"public_key"`
	BlocksCreated  int          `json:"blocks_created"`
	BlocksProposed int          `json:"blocks_proposed"`
	Stake          types.Amount `json:"stake"`
	Fee            types.Float  `json:"fee" gorm:"-"`
	Delegations    int          `json:"delegations"`
	StartHeight    uint64       `json:"start_height"`
	StartTime      time.Time    `json:"start_time"`
	LastHeight     uint64       `json:"last_height"`
	LastTime       time.Time    `json:"last_time"`
	CreatedAt      time.Time    `json:"-"`
	UpdatedAt      time.Time    `json:"-"`
}

Validator stores the block producer information

func (Validator) Validate

func (v Validator) Validate() error

Validate returns an error if validator is invalid

type ValidatorEpoch added in v0.11.0

type ValidatorEpoch struct {
	ID             int         `json:"-"`
	AccountAddress string      `json:"account_address"`
	Epoch          int         `json:"epoch"`
	ValidatorFee   types.Float `json:"validator_fee"`
}

func (ValidatorEpoch) TableName added in v0.11.0

func (ValidatorEpoch) TableName() string

TableName returns the model table name

type ValidatorStat

type ValidatorStat struct {
	Time                string `json:"time"`
	Bucket              string `json:"bucket"`
	BlocksProducedCount int    `json:"blocks_produced_count"`
	DelegationsCount    int    `json:"delegations_count"`
	DelegationsAmount   string `json:"delegations_amount"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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