common

package
v0.0.0-...-77cda71 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DposContractAddress = "0x00000000000000000000000000000000000000fe"

Variables

This section is empty.

Functions

func DecodeTransaction

func DecodeTransaction(tx models.Transaction) (functionSig string, params any, err error)

func FormatFloat

func FormatFloat(f float64) string

func GetFunctionName

func GetFunctionName(temp interface{}) string

func GetYieldIntervalEnd

func GetYieldIntervalEnd(pbft_count uint64, block_num *uint64, interval uint64) uint64

func MakeThreadPool

func MakeThreadPool() pool.Pool

isn't creating threads, but limiting goroutines count. Mostly used for RPC and db related tasks

func Max

func Max[T Number](a, b T) T

func Min

func Min[T Number](a, b T) T

func ParseBool

func ParseBool(s string) (v bool)

func ParseFloat

func ParseFloat(s string) (v float64)

func ParseInt

func ParseInt(s string) (v int64)

func ParseStringToBigInt

func ParseStringToBigInt(v string) *big.Int

func ParseToString

func ParseToString(item any) (result any, err error)

func ParseUInt

func ParseUInt(s string) (v uint64)

func ProcessTransaction

func ProcessTransaction(trx *models.Transaction) (err error)

Types

type AspenHfConfig

type AspenHfConfig struct {
	BlockNumPartOne  uint64   `json:"block_num_part_one"`
	BlockNumPartTwo  uint64   `json:"block_num_part_two"`
	MaxSupply        *big.Int `json:"max_supply"`
	GeneratedRewards *big.Int `json:"generated_rewards"`
}

func (*AspenHfConfig) UnmarshalJSON

func (hf *AspenHfConfig) UnmarshalJSON(data []byte) error

type CallData

type CallData struct {
	Name   string `json:"name"`
	Params any    `json:"params"`
}

type ChainConfig

type ChainConfig struct {
	CommitteeSize               *big.Int
	BlocksPerYear               *big.Int
	YieldPercentage             *big.Int
	DagProposersReward          *big.Int
	MaxBlockAuthorReward        *big.Int
	EligibilityBalanceThreshold *big.Int
	Hardforks                   HardforksConfig
}

func DefaultChainConfig

func DefaultChainConfig() *ChainConfig

type Config

type Config struct {
	Chain                         *ChainConfig
	TotalYieldSavingInterval      uint64
	ValidatorsYieldSavingInterval uint64
	SyncQueueLimit                uint64
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) IsEligible

func (c *Config) IsEligible(stake *big.Int) bool

type HardforksConfig

type HardforksConfig struct {
	RewardsDistributionFrequency map[uint64]uint32 `json:"rewards_distribution_frequency"`
	MagnoliaHf                   MagnoliaHfConfig  `json:"magnolia_hf"`
	AspenHf                      AspenHfConfig     `json:"aspen_hf"`
}

func (*HardforksConfig) GetDistributionFrequency

func (c *HardforksConfig) GetDistributionFrequency(period uint64) uint32

func (*HardforksConfig) IsAspenHfOne

func (c *HardforksConfig) IsAspenHfOne(blockNum uint64) bool

func (*HardforksConfig) IsAspenHfTwo

func (c *HardforksConfig) IsAspenHfTwo(blockNum uint64) bool

type MagnoliaHfConfig

type MagnoliaHfConfig struct {
	BlockNum uint64 `json:"block_num"`
}

func (*MagnoliaHfConfig) UnmarshalJSON

func (hf *MagnoliaHfConfig) UnmarshalJSON(data []byte) error

type Number

type Number interface {
	constraints.Integer | constraints.Float
}

type Task

type Task[P any] struct {
	// contains filtered or unexported fields
}

func MakeTask

func MakeTask[P any](f func(P) error, params P, err *error) *Task[P]

func (*Task[P]) Run

func (t *Task[P]) Run()

type TaskWithResult

type TaskWithResult[P, R any] struct {
	// contains filtered or unexported fields
}

func MakeTaskWithResult

func MakeTaskWithResult[P, R any](f func(P) (R, error), params P, result *R, err *error) *TaskWithResult[P, R]

func (*TaskWithResult[P, R]) Run

func (t *TaskWithResult[P, R]) Run()

type TaskWithoutParams

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

func MakeTaskWithoutParams

func MakeTaskWithoutParams(f func() error, err *error) *TaskWithoutParams

func (*TaskWithoutParams) Run

func (t *TaskWithoutParams) Run()

Jump to

Keyboard shortcuts

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