storage

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIntToKey added in v0.2.1

func FormatIntToKey(i uint64) string

func GetHoldersPage added in v0.2.1

func GetHoldersPage(s Storage, from, count uint64) (ret []models.Account, pagination *models.PaginatedResponse)

func GetObjectsPage

func GetObjectsPage[T Paginated](s Storage, address string, from, count uint64) (ret []T, pagination *models.PaginatedResponse)

func GetTotal

func GetTotal[T Paginated](s Storage, address string) (r uint64)

func GetTypeName

func GetTypeName[T any]() string

func GetUIntKey added in v0.2.1

func GetUIntKey(key uint64) string

func ProcessIntervalData added in v0.3.0

func ProcessIntervalData[T Yields](s Storage, start uint64, fn func([]byte, T) (stop bool))

Types

type Account added in v0.2.1

type Account struct {
	Address string   `json:"address"`
	Balance *big.Int `json:"balance"`
}

func (*Account) ToModel added in v0.2.3

func (a *Account) ToModel() models.Account

type Accounts added in v1.5.4

type Accounts []Account

func (*Accounts) AddToBalance added in v1.5.4

func (a *Accounts) AddToBalance(address string, value *big.Int)

func (*Accounts) FindBalance added in v1.5.4

func (a *Accounts) FindBalance(address string) *Account

func (*Accounts) RegisterBalance added in v1.5.4

func (a *Accounts) RegisterBalance(address string) *Account

func (*Accounts) RemoveBalance added in v1.5.4

func (a *Accounts) RemoveBalance(address string)

func (*Accounts) SortByBalanceDescending added in v1.5.4

func (a *Accounts) SortByBalanceDescending()

func (*Accounts) UpdateBalances added in v1.5.4

func (a *Accounts) UpdateBalances(from, to, value_str string)

func (*Accounts) UpdateEvents added in v1.5.4

func (a *Accounts) UpdateEvents(logs []models.EventLog) error

type AddressStats

type AddressStats struct {
	models.StatsResponse
	Address string `json:"address"`
	// contains filtered or unexported fields
}

AddressStats defines the model for an address aggregate.

func MakeEmptyAddressStats

func MakeEmptyAddressStats(addr string) *AddressStats

func (*AddressStats) AddDag

func (a *AddressStats) AddDag(timestamp models.Timestamp) uint64

func (*AddressStats) AddPbft

func (a *AddressStats) AddPbft(timestamp models.Timestamp) uint64

func (*AddressStats) AddTransaction

func (a *AddressStats) AddTransaction(timestamp models.Timestamp) uint64

func (*AddressStats) IsEqual added in v0.2.1

func (a *AddressStats) IsEqual(b *AddressStats) bool

func (*AddressStats) RegisterValidatorBlock added in v0.3.6

func (a *AddressStats) RegisterValidatorBlock(blockHeight uint64)

type AddressStatsMap added in v1.5.2

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

func MakeAddressStatsMap added in v1.5.2

func MakeAddressStatsMap() *AddressStatsMap

func (*AddressStatsMap) AddToBatch added in v1.5.2

func (a *AddressStatsMap) AddToBatch(b Batch)

func (*AddressStatsMap) GetAddress added in v1.5.2

func (a *AddressStatsMap) GetAddress(s Storage, addr string) *AddressStats

type Batch

type Batch interface {
	CommitBatch()
	SetTotalSupply(s *TotalSupply)
	SetFinalizationData(f *FinalizationData)
	SetGenesisHash(h GenesisHash)
	UpdateWeekStats(w WeekStats)
	SaveAccounts(a Accounts)
	AddToBatchFullKey(o interface{}, key []byte) error
	AddToBatch(o interface{}, key1 string, key2 uint64)
	AddToBatchSingleKey(o interface{}, key string)
	Remove(key []byte)
}

type FinalizationData

type FinalizationData struct {
	DagCount  uint64 `json:"dag_blocks_executed"`
	TrxCount  uint64 `json:"transactions_executed"`
	PbftCount uint64 `json:"pbft_period"`
}

func (*FinalizationData) Check

func (local *FinalizationData) Check(remote FinalizationData)

type GenesisHash

type GenesisHash string

type MultipliedYield added in v0.2.1

type MultipliedYield struct {
	Yield *big.Int `json:"yield"`
}

type Paginated

type Paginated interface {
	models.Transaction | models.Dag | models.Pbft
}

type RewardsStats added in v1.8.1

type RewardsStats struct {
	TotalRewardsStats
	ValidatorsStats []ValidatorStatsWithAddress
}

map can't be serialized to rlp, so we need to use slice of structs

type Storage

type Storage interface {
	Clean() error
	Close() error
	ForEach(o interface{}, key_prefix string, start *uint64, fn func(key, res []byte) (stop bool))
	ForEachBackwards(o interface{}, key_prefix string, start *uint64, fn func(key, res []byte) (stop bool))
	ForEachFromKey(prefix, start_key []byte, fn func(key, res []byte) (stop bool))
	ForEachFromKeyBackwards(prefix, start_key []byte, fn func(key, res []byte) (stop bool))
	NewBatch() Batch
	GetTotalSupply() *TotalSupply
	GetAccounts() Accounts
	GetWeekStats(year, week int32) WeekStats
	GetFinalizationData() *FinalizationData
	GetAddressStats(addr string) *AddressStats
	GenesisHashExist() bool
	GetGenesisHash() GenesisHash
	GetTransactionByHash(hash string) models.Transaction
	GetInternalTransactions(hash string) models.InternalTransactionsResponse
	GetTransactionLogs(hash string) models.TransactionLogsResponse
	GetValidatorYield(validator string, block uint64) (res Yield)
	GetTotalYield(block uint64) (res Yield)
}

type TotalRewardsStats added in v1.8.1

type TotalRewardsStats struct {
	BlockAuthor      string
	TotalVotesWeight uint64
	MaxVotesWeight   uint64
	TotalDagCount    uint64
}

type TotalSupply

type TotalSupply = big.Int

type ValidatorStats added in v1.8.1

type ValidatorStats struct {
	// count of rewardable(with 1 or more unique transactions) DAG blocks produced by this validator
	DagBlocksCount uint64
	// Validator cert voted block weight
	VoteWeight uint64
	// Validator fee reward amount
	FeeReward *big.Int
}

type ValidatorStatsWithAddress added in v1.8.1

type ValidatorStatsWithAddress struct {
	ValidatorStats
	Address string
}

type ValidatorYield added in v0.2.1

type ValidatorYield struct {
	Validator string   `json:"validator"`
	Yield     *big.Int `json:"yield"`
}

type ValidatorsYield added in v0.2.1

type ValidatorsYield struct {
	Yields []ValidatorYield `json:"yields"`
}

type WeekStats

type WeekStats struct {
	Validators []models.Validator
	Total      uint32
	Key        []byte `rlp:"-"`
}

func MakeEmptyWeekStats

func MakeEmptyWeekStats() *WeekStats

func (*WeekStats) AddPbftBlock

func (w *WeekStats) AddPbftBlock(block *models.Pbft)

func (*WeekStats) GetPaginated

func (w *WeekStats) GetPaginated(from, count uint64) ([]models.Validator, *models.PaginatedResponse)

func (*WeekStats) Sort

func (w *WeekStats) Sort()

type Yield added in v0.2.1

type Yield struct {
	Yield string `json:"yield"`
}

type Yields added in v0.2.1

type Yields interface {
	ValidatorsYield | MultipliedYield
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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