posapi

package
v2.1.5-beta-1+incompat... Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: GPL-3.0 Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIs

func APIs(chain PosChainReader, backend ethapi.Backend) []rpc.API

Types

type Activity

type Activity struct {
	EpLeader    []common.Address `json:"epLeader"`
	EpActivity  []int            `json:"epActivity"`
	RpLeader    []common.Address `json:"rpLeader"`
	RpActivity  []int            `json:"rpActivity"`
	SltLeader   []common.Address `json:"sltLeader"`
	SlBlocks    []int            `json:"slBlocks"`
	SlActivity  float64          `json:"slActivity"`
	SlCtrlCount int              `json:"slCtrlCount"`
}

type ApiClientProbability

type ApiClientProbability struct {
	Addr        common.Address
	Probability *math.HexOrDecimal256
}

type ApiStakerInfo

type ApiStakerInfo struct {
	Addr             common.Address
	Infors           []ApiClientProbability
	FeeRate          uint64
	TotalProbability *math.HexOrDecimal256
}

type ClientInfo

type ClientInfo struct {
	Address     common.Address        `json:"address"`
	Amount      *math.HexOrDecimal256 `json:"amount"`
	StakeAmount *math.HexOrDecimal256 `json:"votingPower"`
	QuitEpoch   uint64                `json:"quitEpoch"`
}

type DelegatorInfo

type DelegatorInfo struct {
	Address   common.Address        `json:"address"`
	Incentive *math.HexOrDecimal256 `json:"incentive"`
	Type      string                `json:"type"`
}

type EpRnpActivity

type EpRnpActivity struct {
	EpLeader   []common.Address `json:"epLeader"`
	EpActivity []int            `json:"epActivity"`
	RpLeader   []common.Address `json:"rpLeader"`
	RpActivity []int            `json:"rpActivity"`
}

type LeaderJson

type LeaderJson struct {
	Type      uint8          `json:"type"`
	SecAddr   common.Address `json:"secAddr"`
	PubSec256 string         `json:"pubSec256"`
	PubBn256  string         `json:"pubBn256"`
}

func ToLeaderJson

func ToLeaderJson(leader []vm.Leader) []LeaderJson

type PartnerInfo

type PartnerInfo struct {
	Address      common.Address        `json:"address"`
	Amount       *math.HexOrDecimal256 `json:"amount"`
	StakeAmount  *math.HexOrDecimal256 `json:"votingPower"`
	Renewal      bool                  `json:"renewal"`
	LockEpochs   uint64                `json:"lockEpochs"`
	StakingEpoch uint64                `json:"stakingEpoch"`
}

type PosApi

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

func (PosApi) CalProbability

func (a PosApi) CalProbability(amountCoin uint64, lockTime uint64) (string, error)

CalProbability use to calc the probability of a staker with amount by stake wan coins. The probability is different in different time, so you should input each epoch ID you want to calc Such as CalProbability(390, 10000, 60, 360) means begin from epoch 360 lock 60 epochs stake 10000 to calc 390's probability.

func (PosApi) GetActivity

func (a PosApi) GetActivity(epochID uint64) (*Activity, error)

GetActivity get epoch leader, random proposer, slot leader 's addresses and activity

func (PosApi) GetBootNodePK

func (a PosApi) GetBootNodePK() string

func (PosApi) GetChainQuality

func (a PosApi) GetChainQuality(epochid uint64, slotid uint64) (uint64, error)

func (PosApi) GetEpRnpActivity

func (a PosApi) GetEpRnpActivity(epochID uint64) (*EpRnpActivity, error)

GetEpRnpActivity get epoch leader, random leader proposer activity

func (PosApi) GetEpochBlkCnt

func (a PosApi) GetEpochBlkCnt(epochId uint64) (uint64, error)

func (PosApi) GetEpochGasPool

func (a PosApi) GetEpochGasPool(epochID uint64) (string, error)

func (PosApi) GetEpochID

func (a PosApi) GetEpochID() uint64

func (PosApi) GetEpochIDByTime

func (a PosApi) GetEpochIDByTime(timeUnix uint64) uint64

GetEpochIDByTime can get Epoch ID by input time second Unix.

func (PosApi) GetEpochIdByBlockNumber

func (a PosApi) GetEpochIdByBlockNumber(blockNumber uint64) uint64

func (PosApi) GetEpochIncentive

func (a PosApi) GetEpochIncentive(epochID uint64) (string, error)

func (PosApi) GetEpochIncentiveBlockNumber

func (a PosApi) GetEpochIncentiveBlockNumber(epochID uint64) (uint64, error)

func (PosApi) GetEpochIncentivePayDetail

func (a PosApi) GetEpochIncentivePayDetail(epochID uint64) ([]ValidatorInfo, error)

func (PosApi) GetEpochLeadersAddrByEpochID

func (a PosApi) GetEpochLeadersAddrByEpochID(epochID uint64) ([]common.Address, error)

func (PosApi) GetEpochLeadersByEpochID

func (a PosApi) GetEpochLeadersByEpochID(epochID uint64) (map[string]string, error)

func (PosApi) GetEpochRemain

func (a PosApi) GetEpochRemain(epochID uint64) (string, error)

func (PosApi) GetEpochStakeOut

func (a PosApi) GetEpochStakeOut(epochID uint64) ([]RefundInfo, error)

func (PosApi) GetEpochStakerInfo

func (a PosApi) GetEpochStakerInfo(epochID uint64, addr common.Address) (ApiStakerInfo, error)

func (PosApi) GetEpochStakerInfoAll

func (a PosApi) GetEpochStakerInfoAll(epochID uint64) ([]ApiStakerInfo, error)

func (PosApi) GetIncentivePool

func (a PosApi) GetIncentivePool(epochID uint64) ([]string, error)

func (PosApi) GetIncentiveRunTimes

func (a PosApi) GetIncentiveRunTimes() (string, error)

func (PosApi) GetLeaderGroupByEpochID

func (a PosApi) GetLeaderGroupByEpochID(epochID uint64) ([]LeaderJson, error)

func (PosApi) GetLocalPK

func (a PosApi) GetLocalPK() (string, error)

func (PosApi) GetMaxStableBlkNumber

func (a PosApi) GetMaxStableBlkNumber() uint64

func (PosApi) GetPosInfo

func (a PosApi) GetPosInfo() (info PosInfoJson)

func (PosApi) GetRBAddress

func (a PosApi) GetRBAddress(epochID uint64) []common.Address

func (PosApi) GetRandom

func (a PosApi) GetRandom(epochId uint64, blockNr int64) (*big.Int, error)

func (PosApi) GetRandomProposersAddrByEpochID

func (a PosApi) GetRandomProposersAddrByEpochID(epochID uint64) ([]common.Address, error)

func (PosApi) GetRandomProposersByEpochID

func (a PosApi) GetRandomProposersByEpochID(epochID uint64) (map[string]string, error)

func (PosApi) GetRbSignatureCount

func (a PosApi) GetRbSignatureCount(epochId uint64, blockNr int64) (int, error)

func (PosApi) GetRbStage

func (a PosApi) GetRbStage(slotId uint64) uint64

func (PosApi) GetReorgState

func (a PosApi) GetReorgState(epochid uint64) ([]uint64, error)

func (PosApi) GetSlStage

func (a PosApi) GetSlStage(slotId uint64) uint64

func (PosApi) GetSlotActivity

func (a PosApi) GetSlotActivity(epochID uint64) (*SlotActivity, error)

GetSlotActivity get slot activity of epoch

func (PosApi) GetSlotCount

func (a PosApi) GetSlotCount() int

func (PosApi) GetSlotCreateStatusByEpochID

func (a PosApi) GetSlotCreateStatusByEpochID(epochID uint64) bool

func (PosApi) GetSlotID

func (a PosApi) GetSlotID() uint64

func (PosApi) GetSlotIDByTime

func (a PosApi) GetSlotIDByTime(timeUnix uint64) uint64

GetSlotIDByTime can get Slot ID by input time second Unix.

func (PosApi) GetSlotLeaderByEpochIDAndSlotID

func (a PosApi) GetSlotLeaderByEpochIDAndSlotID(epochID uint64, slotID uint64) string

func (PosApi) GetSlotScCallTimesByEpochID

func (a PosApi) GetSlotScCallTimesByEpochID(epochID uint64) uint64

func (PosApi) GetSlotTime

func (a PosApi) GetSlotTime() int

func (PosApi) GetSmaByEpochID

func (a PosApi) GetSmaByEpochID(epochID uint64) (map[string]string, error)

func (PosApi) GetStakerInfo

func (a PosApi) GetStakerInfo(targetBlkNum uint64) ([]*StakerJson, error)

this is the static snap of stekers by the block Number.

func (PosApi) GetTimeByEpochID

func (a PosApi) GetTimeByEpochID(epochID uint64) uint64

GetTimeByEpochID can get time second Unix by epoch ID.

func (PosApi) GetTotalIncentive

func (a PosApi) GetTotalIncentive() (string, error)

func (PosApi) GetTotalRemain

func (a PosApi) GetTotalRemain() (string, error)

func (PosApi) GetTps

func (a PosApi) GetTps(fromNumber uint64, toNumber uint64) (string, error)

GetTps used to get tps value

func (PosApi) GetValidRBCnt

func (a PosApi) GetValidRBCnt(epochId uint64) ([]uint64, error)

func (PosApi) GetValidSMACnt

func (a PosApi) GetValidSMACnt(epochId uint64) ([]uint64, error)

func (PosApi) GetValidatorActivity

func (a PosApi) GetValidatorActivity(epochID uint64) (*ValidatorActivity, error)

GetValidatorActivity get epoch leader, random proposer addresses and activity

func (PosApi) GetWhiteListConfig

func (a PosApi) GetWhiteListConfig() ([]vm.UpgradeWhiteEpochLeaderParam, error)

func (PosApi) GetWhiteListbyEpochID

func (a PosApi) GetWhiteListbyEpochID(epochID uint64) ([]string, error)

func (PosApi) Version

func (a PosApi) Version() string

type PosChainReader

type PosChainReader interface {
	// Config retrieves the blockchain's chain configuration.
	Config() *params.ChainConfig

	// CurrentHeader retrieves the current header from the local chain.
	CurrentHeader() *types.Header

	// GetHeader retrieves a block header from the database by hash and number.
	GetHeader(hash common.Hash, number uint64) *types.Header

	// GetHeaderByNumber retrieves a block header from the database by number.
	GetHeaderByNumber(number uint64) *types.Header

	// GetHeaderByHash retrieves a block header from the database by its hash.
	GetHeaderByHash(hash common.Hash) *types.Header

	// GetBlock retrieves a block from the database by hash and number.
	GetBlock(hash common.Hash, number uint64) *types.Block

	//get chain quality,return quality * 1000
	ChainQuality(epochid uint64, slotid uint64) (uint64, error)
}

type PosInfoJson

type PosInfoJson struct {
	FirstEpochId     uint64 `json:"firstEpochId"`
	FirstBlockNumber uint64 `json:"firstBlockNumber"`
}

type RefundInfo

type RefundInfo struct {
	Addr   common.Address        `json:"address"`
	Amount *math.HexOrDecimal256 `json:"amount"`
}

type SlotActivity

type SlotActivity struct {
	SltLeader   []common.Address `json:"sltLeader"`
	SlBlocks    []int            `json:"slBlocks"`
	SlActivity  float64          `json:"slActivity"`
	SlCtrlCount int              `json:"slCtrlCount"`
}

type StakerJson

type StakerJson struct {
	Address   common.Address `json:"address"`
	PubSec256 string         `json:"pubSec256"` //stakeholder’s wan public key
	PubBn256  string         `json:"pubBn256"`  //stakeholder’s bn256 public key

	Amount         *math.HexOrDecimal256 `json:"amount"`
	StakeAmount    *math.HexOrDecimal256 `json:"votingPower"`
	LockEpochs     uint64                `json:"lockEpochs"`     //lock time which is input by user. 0 means unexpired.
	NextLockEpochs uint64                `json:"nextLockEpochs"` //lock time which is input by user. 0 means unexpired.
	From           common.Address        `json:"from"`

	StakingEpoch uint64 `json:"stakingEpoch"` //the user’s staking time
	FeeRate      uint64 `json:"feeRate"`
	//NextFeeRate  uint64
	Clients  []ClientInfo  `json:"clients"`
	Partners []PartnerInfo `json:"partners"`

	MaxFeeRate          uint64 `json:"maxFeeRate"`
	FeeRateChangedEpoch uint64 `json:"feeRateChangedEpoch"`
}

func ToStakerJson

func ToStakerJson(staker *vm.StakerInfo) *StakerJson

type ValidatorActivity

type ValidatorActivity struct {
	EpLeader   []common.Address `json:"epLeader"`
	EpActivity []int            `json:"epActivity"`
	RpLeader   []common.Address `json:"rpLeader"`
	RpActivity []int            `json:"rpActivity"`
}

type ValidatorInfo

type ValidatorInfo struct {
	Address       common.Address        `json:"address"`
	WalletAddress common.Address        `json:"stakeInFromAddr"`
	Incentive     *math.HexOrDecimal256 `json:"incentive"`
	Type          string                `json:"type"`
	Delegators    []DelegatorInfo       `json:"delegators"`
}

Jump to

Keyboard shortcuts

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