deputynode

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: LGPL-3.0 Imports: 16 Imported by: 5

Documentation

Index

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

type DeputySalary struct {
	Address common.Address
	Salary  *big.Int
}

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 Instance

func Instance() *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) Clear

func (d *Manager) Clear()

func (*Manager) GetDeputiesByHeight added in v1.1.1

func (d *Manager) GetDeputiesByHeight(height uint32, total bool) DeputyNodes

GetDeputiesByHeight 通过height获取对应的节点列表

func (*Manager) GetDeputiesCount

func (d *Manager) GetDeputiesCount(height uint32) int

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

func (d *Manager) GetLatestDeputies(height uint32) []string

GetLatestDeputies for api

func (*Manager) GetNodeRankByAddress added in v1.1.1

func (d *Manager) GetNodeRankByAddress(height uint32, addr common.Address) int

func (*Manager) GetNodeRankByNodeID added in v1.1.1

func (d *Manager) GetNodeRankByNodeID(height uint32, nodeID []byte) int

func (*Manager) GetSlot

func (d *Manager) GetSlot(height uint32, firstAddress, nextAddress common.Address) int

获取最新块的出块者序号与本节点序号差

func (*Manager) IsNodeDeputy added in v1.0.2

func (d *Manager) IsNodeDeputy(height uint32, nodeID []byte) bool

IsNodeDeputy

func (*Manager) IsSelfDeputyNode

func (d *Manager) IsSelfDeputyNode(height uint32) bool

IsSelfDeputyNode

func (*Manager) TimeToHandOutRewards

func (d *Manager) TimeToHandOutRewards(height uint32) bool

TimeToHandOutRewards 是否该发出块奖励了

Jump to

Keyboard shortcuts

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