snapshot

package
v0.0.0-...-b6c1db7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2020 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRowToSnapshot

func AddRowToSnapshot(snapshot *Snapshot, spr *SnapshotPostgresRow)

func AddSnapshotColumn

func AddSnapshotColumn(db *sql.DB, columnName string)

func CheckIntegrity

func CheckIntegrity(as Snapshot, ss SystemSnapshot) bool

func CreateSnapshotStatusRow

func CreateSnapshotStatusRow(db *sql.DB, blockNumber *big.Int, blockTimestamp string)

func DumpCommissionsSnapshotData

func DumpCommissionsSnapshotData(db *sql.DB, cs CommissionsSnapshot, blockNumber *big.Int) error

func DumpRewardsSnapshotData

func DumpRewardsSnapshotData(db *sql.DB, rs RewardsSnapshot, blockNumber *big.Int) error

func DumpSnapshotData

func DumpSnapshotData(db *sql.DB, snapshot Snapshot, blockNumber *big.Int) error

func DumpSystemSnapshotData

func DumpSystemSnapshotData(db *sql.DB, ss SystemSnapshot, blockNumber *big.Int) error

func DumpVotesSnapshotData

func DumpVotesSnapshotData(db *sql.DB, vs VotesSnapshot, blockNumber *big.Int) error

func FetchSnapshotAddresses

func FetchSnapshotAddresses(db *sql.DB, blockNumber *big.Int) ([]string, error)

func FlushAllSnapshots

func FlushAllSnapshots(db *sql.DB)

func GenerateAndStoreBlockSnapshots

func GenerateAndStoreBlockSnapshots(db *sql.DB, blockNumber *big.Int, rpcClient *rpc.Client)

func GenerateAndStoreGenesisSnapshot

func GenerateAndStoreGenesisSnapshot(db *sql.DB, blockNumber *big.Int, rpcClient *rpc.Client)

func PrettyPrint

func PrettyPrint(v interface{}) (err error)

func SameDateOfTimestamps

func SameDateOfTimestamps(ts1, ts2 string) bool

func SnapshotCommissionsAccountLevel

func SnapshotCommissionsAccountLevel(blockNumber *big.Int, previousSnapshotBlockNumber *big.Int) (AccountCommissions, CommissionsSnapshot)

func SnapshotRewardsAccountLevel

func SnapshotRewardsAccountLevel(blockNumber *big.Int, previousSnapshotBlockNumber *big.Int) (AccountRewards, RewardsSnapshot)

func UTCTime

func UTCTime(timestampHex string) time.Time

Types

type AccountCommissions

type AccountCommissions = map[Address]*big.Int

type AccountRewards

type AccountRewards = map[Address]*big.Int

type AccountSnapshot

type AccountSnapshot map[BlockNumber]*AccountSnapshotRow

AccountSnapshot is helper type for fetching historical snapshot data of an account

func FetchAccountSnapshot

func FetchAccountSnapshot(db *sql.DB, account string) (AccountSnapshot, error)

type AccountSnapshotRow

type AccountSnapshotRow struct {
	//AddColumnWork
	GoldTokenBalance             string
	LockedGoldBalance            string
	NonVotingLockedGoldBalance   string
	PendingWithdrawalGoldBalance string
	CeloUSDValue                 string
	Reward                       string
	Commission                   string
}

AccountSnapshotRow is helper type for fetching historical snapshot data of an account

type AccountVotesDistribution

type AccountVotesDistribution = contract.AccountVotesDistribution

type AccountVotesSnapshot

type AccountVotesSnapshot map[BlockNumber][]*DelegationRow

func FetchAccountVotesSnapshot

func FetchAccountVotesSnapshot(db *sql.DB, account string) (AccountVotesSnapshot, error)

type Address

type Address = string

type BlockNumber

type BlockNumber = string

type CommissionsSnapshot

type CommissionsSnapshot = []*CommissionsSnapshotRow

type CommissionsSnapshotRow

type CommissionsSnapshotRow struct {
	EpochBlockNumber *big.Int
	Validator        string
	ValidatorPayment *big.Int
	Group            string
	GroupPayment     *big.Int
}

type DelegationRow

type DelegationRow struct {
	Group        string
	TotalVotes   string
	ActiveVotes  string
	PendingVotes string
}

type RewardsSnapshot

type RewardsSnapshot = []*RewardsSnapshotRow

type RewardsSnapshotRow

type RewardsSnapshotRow struct {
	EpochBlockNumber   *big.Int
	Address            string
	Group              string
	AddressActiveUnits *big.Int
	GroupActiveUnits   *big.Int
	AddressReward      *big.Int
	GroupReward        *big.Int
}

type Snapshot

type Snapshot map[Address]SnapshotRow

func FetchSnapshotData

func FetchSnapshotData(db *sql.DB, blockNumber *big.Int) (Snapshot, error)

func GenesisSnapshotAccountLevel

func GenesisSnapshotAccountLevel(db *sql.DB, rpcClient *rpc.Client) Snapshot

func SnapshotAccountLevel

func SnapshotAccountLevel(
	db *sql.DB,
	rpcClient *rpc.Client,
	blockNumber *big.Int,
	previousSnapshotBlockNumber *big.Int,
	accountRewards AccountRewards,
	accountCommissions AccountCommissions) Snapshot

type SnapshotDate

type SnapshotDate struct {
	Date        string
	BlockNumber string
}

SnapshotInfo is a tuple representing a snapshot's date and block number

func DatesOfCompletedSnapshots

func DatesOfCompletedSnapshots(db *sql.DB) ([]*SnapshotDate, error)

type SnapshotPostgresRow

type SnapshotPostgresRow struct {
	Address                      string
	GoldTokenBalance             string
	LockedGoldBalance            string
	NonVotingLockedGoldBalance   string
	PendingWithdrawalGoldBalance string
	CeloUSDValue                 string
	Reward                       string
	Commission                   string
}

This type acts as a bridge between Postgres row and Golang SnapshotRow

type SnapshotRow

type SnapshotRow struct {
	GoldTokenBalance             *big.Int
	LockedGoldBalance            *big.Int
	NonVotingLockedGoldBalance   *big.Int
	PendingWithdrawalGoldBalance *big.Int
	CeloUSDValue                 *big.Int
	Reward                       *big.Int
	Commission                   *big.Int
}

func GenerateNewSnapshotRowWithDetails

func GenerateNewSnapshotRowWithDetails(address string, blockNumber *big.Int) SnapshotRow

func NewSnapshotRow

func NewSnapshotRow() SnapshotRow

Use this to set trivial values

type SystemSnapshot

type SystemSnapshot struct {
	GoldTokenSupply            *big.Int
	TotalLockedGoldBalance     *big.Int
	NonVotingLockedGoldBalance *big.Int
	TotalCeloUSDValue          *big.Int
}

func SnapshotSystemLevel

func SnapshotSystemLevel(rpcClient *rpc.Client, blockNumber *big.Int) SystemSnapshot

type SystemSnapshotRow

type SystemSnapshotRow struct {
	BlockNumber                string
	SnapshotDate               string
	GoldTokenSupply            string
	TotalLockedGoldBalance     string
	NonVotingLockedGoldBalance string
	TotalCeloUSDValue          string
}

func FetchAllSystemSnapshots

func FetchAllSystemSnapshots(db *sql.DB) ([]*SystemSnapshotRow, error)

type VotesSnapshot

type VotesSnapshot = map[Address]*AccountVotesDistribution

func VotesSnapshotAccountLevel

func VotesSnapshotAccountLevel(blockNumber *big.Int) VotesSnapshot

Jump to

Keyboard shortcuts

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