Documentation
¶
Index ¶
- Constants
- func GetSelfNodeID() []byte
- func GetSelfNodeKey() *ecdsa.PrivateKey
- func SetSelfNodeKey(key *ecdsa.PrivateKey)
- type CandidateNode
- type DeputyNode
- type DeputyNodes
- type DeputyNodesRecord
- type DeputySalary
- type Manager
- func (d *Manager) Add(height uint32, nodes DeputyNodes)
- func (d *Manager) Clear()
- func (d *Manager) GetDeputiesByHeight(height uint32, total bool) DeputyNodes
- func (d *Manager) GetDeputiesCount(height uint32) int
- func (d *Manager) GetDeputyByAddress(height uint32, addr common.Address) *DeputyNode
- func (d *Manager) GetDeputyByNodeID(height uint32, nodeID []byte) *DeputyNode
- func (d *Manager) GetLatestDeputies(height uint32) []string
- func (d *Manager) GetNodeRankByAddress(height uint32, addr common.Address) int
- func (d *Manager) GetNodeRankByNodeID(height uint32, nodeID []byte) int
- func (d *Manager) GetSlot(height uint32, firstAddress, nextAddress common.Address) int
- func (d *Manager) IsNodeDeputy(height uint32, nodeID []byte) bool
- func (d *Manager) IsSelfDeputyNode(height uint32) bool
- func (d *Manager) TimeToHandOutRewards(height uint32) bool
Constants ¶
View Source
const (
TotalCount = 5
)
Variables ¶
This section is empty.
Functions ¶
func GetSelfNodeID ¶
func GetSelfNodeID() []byte
func GetSelfNodeKey ¶
func GetSelfNodeKey() *ecdsa.PrivateKey
func SetSelfNodeKey ¶
func SetSelfNodeKey(key *ecdsa.PrivateKey)
Types ¶
type CandidateNode ¶ added in v1.1.0
type CandidateNode struct { IsCandidate bool `json:"isCandidate" gencodec:"required"` MinerAddress common.Address `json:"minerAddress" gencodec:"required"` // 候选节点挖矿收益地址 NodeID []byte `json:"nodeID" gencodec:"required"` Host string `json:"host" gencodec:"required"` // ip或者域名 Port uint32 `json:"port" gencodec:"required"` // 端口 }
CandidateNode
func (CandidateNode) MarshalJSON ¶ added in v1.1.0
func (c CandidateNode) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*CandidateNode) UnmarshalJSON ¶ added in v1.1.0
func (c *CandidateNode) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type DeputyNode ¶
type DeputyNode struct { MinerAddress common.Address `json:"minerAddress" gencodec:"required"` NodeID []byte `json:"nodeID" gencodec:"required"` IP net.IP `json:"ip" gencodec:"required"` // ip Port uint32 `json:"port" gencodec:"required"` // 端口 Rank uint32 `json:"rank" gencodec:"required"` // 排名 从0开始 Votes *big.Int `json:"votes" gencodec:"required"` // 得票数 }
DeputyNode
func (*DeputyNode) Check ¶
func (d *DeputyNode) Check() error
func (*DeputyNode) Hash ¶
func (d *DeputyNode) Hash() (h common.Hash)
func (DeputyNode) MarshalJSON ¶
func (d DeputyNode) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON.
func (*DeputyNode) UnmarshalJSON ¶
func (d *DeputyNode) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type DeputyNodes ¶
type DeputyNodes []*DeputyNode
func (DeputyNodes) String ¶ added in v1.1.1
func (nodes DeputyNodes) String() string
type DeputyNodesRecord ¶
type DeputyNodesRecord struct {
// contains filtered or unexported fields
}
type DeputySalary ¶
func CalcSalary ¶
func CalcSalary(height uint32, termRewards *big.Int) []*DeputySalary
CalcSalary 计算收益
type Manager ¶
type Manager struct { DeputyNodesList []*DeputyNodesRecord // key:节点列表生效开始高度 value:节点列表 // contains filtered or unexported fields }
Manager 代理节点管理器
func (*Manager) Add ¶
func (d *Manager) Add(height uint32, nodes DeputyNodes)
Add 投票结束 统计结果通过add函数缓存起来 height: next term start height. if snapshot:1000, period:100, result: 1101 2101 3101...
func (*Manager) GetDeputiesByHeight ¶ added in v1.1.1
func (d *Manager) GetDeputiesByHeight(height uint32, total bool) DeputyNodes
GetDeputiesByHeight 通过height获取对应的节点列表
func (*Manager) GetDeputiesCount ¶
getDeputyNodeCount 获取共识节点数量
func (*Manager) GetDeputyByAddress ¶
func (d *Manager) GetDeputyByAddress(height uint32, addr common.Address) *DeputyNode
getNodeByAddress 获取address对应的节点
func (*Manager) GetDeputyByNodeID ¶
func (d *Manager) GetDeputyByNodeID(height uint32, nodeID []byte) *DeputyNode
getNodeByNodeID 根据nodeid获取对应的节点
func (*Manager) GetLatestDeputies ¶ added in v1.0.1
GetLatestDeputies for api
func (*Manager) GetNodeRankByAddress ¶ added in v1.1.1
func (*Manager) GetNodeRankByNodeID ¶ added in v1.1.1
func (*Manager) IsNodeDeputy ¶ added in v1.0.2
IsNodeDeputy
func (*Manager) IsSelfDeputyNode ¶
IsSelfDeputyNode
func (*Manager) TimeToHandOutRewards ¶
TimeToHandOutRewards 是否该发出块奖励了
Click to show internal directories.
Click to hide internal directories.