deputynode

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: LGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMinerAddressInvalid = errors.New("incorrect field: 'MinerAddress'")
	ErrNodeIDInvalid       = errors.New("incorrect field: 'NodeID'")
	ErrRankInvalid         = errors.New("max deputy node's rank is 65535")
	ErrVotesInvalid        = errors.New("min deputy node's votes are 0")
)
View Source
var (
	ErrNoDeputyInBlock       = errors.New("there is no deputy nodes in snapshot block")
	ErrInvalidDeputyRank     = errors.New("deputy nodes should be sorted by rank and start from 0")
	ErrInvalidDeputyVotes    = errors.New("there is a conflict between deputy node' rank and votes")
	ErrMissingTerm           = errors.New("some term is missing")
	ErrInvalidSnapshotHeight = errors.New("invalid snapshot block height")
	ErrNoTerms               = errors.New("can't access deputy nodes before SaveSnapshot")
	ErrQueryFutureTerm       = errors.New("can't query future term")
)

Functions

func GetSelfNodeID

func GetSelfNodeID() []byte

func GetSelfNodeKey

func GetSelfNodeKey() *ecdsa.PrivateKey

func GetTermIndexByHeight added in v1.2.0

func GetTermIndexByHeight(height uint32) uint32

GetTermIndexByHeight return the index of the term which in charge of consensus the specific block

0 term start at height 0
1 term start at 100W+1K+1
2 term start at 200W+1K+1
...

func IsRewardBlock added in v1.2.0

func IsRewardBlock(height uint32) bool

IsRewardBlock 是否该发出块奖励了

func IsSnapshotBlock added in v1.3.0

func IsSnapshotBlock(height uint32) bool

IsSnapshotBlock

func SetSelfNodeKey

func SetSelfNodeKey(key *ecdsa.PrivateKey)

Types

type DeputyNode

type DeputyNode struct {
	MinerAddress common.Address `json:"minerAddress"   gencodec:"required"` // candidate account address
	NodeID       []byte         `json:"nodeID"         gencodec:"required"`
	Rank         uint32         `json:"rank"           gencodec:"required"` // start from 0
	Votes        *big.Int       `json:"votes"          gencodec:"required"`
}

DeputyNode

func NewDeputyNode added in v1.3.0

func NewDeputyNode(votes *big.Int, rank uint32, minerAddr common.Address, nodeIDStr string) (*DeputyNode, error)

func (*DeputyNode) Check

func (d *DeputyNode) Check() error

func (*DeputyNode) Copy added in v1.2.0

func (d *DeputyNode) Copy() *DeputyNode

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) MerkleRootSha added in v1.2.0

func (nodes DeputyNodes) MerkleRootSha() common.Hash

MerkleRootSha compute the root hash of deputy nodes merkle trie

func (DeputyNodes) String added in v1.1.1

func (nodes DeputyNodes) String() string

type DeputySalary

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

type Manager

type Manager struct {
	DeputyCount int // Max deputy count. Not include candidate nodes
	// contains filtered or unexported fields
}

Manager 代理节点管理器

func NewManager added in v1.2.0

func NewManager(deputyCount int) *Manager

NewManager creates a new Manager. It is used to maintain term record list

func (*Manager) GetDeputiesByHeight added in v1.1.1

func (m *Manager) GetDeputiesByHeight(height uint32) DeputyNodes

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

func (*Manager) GetDeputiesCount

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

GetDeputiesCount 获取共识节点数量

func (*Manager) GetDeputyByAddress

func (m *Manager) GetDeputyByAddress(height uint32, addr common.Address) *DeputyNode

GetDeputyByAddress 获取address对应的节点

func (*Manager) GetDeputyByNodeID

func (m *Manager) GetDeputyByNodeID(height uint32, nodeID []byte) *DeputyNode

GetDeputyByNodeID 根据nodeID获取对应的节点

func (*Manager) GetMyDeputyInfo added in v1.3.0

func (m *Manager) GetMyDeputyInfo(height uint32) *DeputyNode

GetMyDeputyInfo 获取自己在某一届高度的共识节点信息

func (*Manager) GetMyMinerAddress added in v1.3.0

func (m *Manager) GetMyMinerAddress(height uint32) (common.Address, bool)

GetMyMinerAddress 获取自己在某一届高度的矿工账号

func (*Manager) GetTermByHeight added in v1.2.0

func (m *Manager) GetTermByHeight(height uint32) (*TermRecord, error)

GetTermByHeight 通过height获取对应的任期信息

func (*Manager) IsEvilDeputyNode added in v1.3.0

func (m *Manager) IsEvilDeputyNode(minerAddress common.Address, currentHeight uint32) bool

IsEvilDeputyNode currentHeight is current block height

func (*Manager) IsNodeDeputy added in v1.0.2

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

IsNodeDeputy

func (*Manager) IsSelfDeputyNode

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

IsSelfDeputyNode

func (*Manager) PutEvilDeputyNode added in v1.3.0

func (m *Manager) PutEvilDeputyNode(minerAddress common.Address, blockHeight uint32)

SetAbnormalDeputyNode height is block height

func (*Manager) SaveSnapshot added in v1.2.0

func (m *Manager) SaveSnapshot(snapshotHeight uint32, nodes DeputyNodes)

SaveSnapshot add deputy nodes record by snapshot block data

func (*Manager) TwoThirdDeputyCount added in v1.3.0

func (m *Manager) TwoThirdDeputyCount(height uint32) uint32

TwoThirdDeputyCount return the deputy nodes count * 2/3

type TermRecord added in v1.2.0

type TermRecord struct {
	TermIndex uint32      `json:"termIndex"` // start from 0
	Nodes     DeputyNodes `json:"nodes"`     // include deputy nodes and candidate nodes
}

func NewTermRecord added in v1.2.0

func NewTermRecord(snapshotHeight uint32, nodes DeputyNodes) *TermRecord

func (*TermRecord) GetDeputies added in v1.2.0

func (t *TermRecord) GetDeputies(count int) DeputyNodes

GetDeputies return deputy nodes. They are top items in t.Nodes

func (*TermRecord) GetTotalVotes added in v1.2.0

func (t *TermRecord) GetTotalVotes() *big.Int

func (TermRecord) MarshalJSON added in v1.2.0

func (t TermRecord) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*TermRecord) UnmarshalJSON added in v1.2.0

func (t *TermRecord) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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