storage

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 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(string, 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 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

type Balances added in v0.2.1

type Balances struct {
	Accounts []Account `json:"accounts"`
}

func (*Balances) AddToBalance added in v0.2.1

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

func (*Balances) FindBalance added in v0.2.1

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

func (*Balances) RegisterBalance added in v0.2.1

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

func (*Balances) RemoveBalance added in v0.2.1

func (a *Balances) RemoveBalance(address string)

func (*Balances) SortByBalanceDescending added in v0.2.1

func (a *Balances) SortByBalanceDescending()

func (*Balances) UpdateBalances added in v0.2.1

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

func (*Balances) UpdateEvents added in v0.2.1

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

type Batch

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

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 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))
	NewBatch() Batch
	GetTotalSupply() *TotalSupply
	GetAccounts() []Account
	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 TotalSupply

type TotalSupply = big.Int

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