deputynode

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: LGPL-3.0 Imports: 14 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

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")
	ErrNoStableTerm          = errors.New("term is not stable")
	ErrMineGenesis           = errors.New("can not mine genesis block")
	ErrNotDeputy             = errors.New("the miner address is not a deputy")
	ErrInvalidDistance       = errors.New("deputy distance should be greater than 0")
)

Functions

func GetDeputyTermIndexByHeight added in v1.4.0

func GetDeputyTermIndexByHeight(height uint32) uint32

GetDeputyTermIndexByHeight return the index of the term which contains the same deputies with

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

func GetLastSnapshotHeight added in v1.4.0

func GetLastSnapshotHeight(height uint32) uint32

GetLastSnapshotHeight

func GetSelfNodeID

func GetSelfNodeID() []byte

func GetSelfNodeKey

func GetSelfNodeKey() *ecdsa.PrivateKey

func GetSignerTermIndexByHeight added in v1.4.0

func GetSignerTermIndexByHeight(height uint32) uint32

GetSignerTermIndexByHeight return the index of the term which in charge of sign 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 是否该发出块奖励了. 1001001,2001001,3001001,4001001。。。

func IsSnapshotBlock added in v1.3.0

func IsSnapshotBlock(height uint32) bool

IsSnapshotBlock

func SetSelfNodeKey

func SetSelfNodeKey(key *ecdsa.PrivateKey)

Types

type BlockLoader added in v1.4.0

type BlockLoader interface {
	GetBlockByHeight(height uint32) (*types.Block, error)
}

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, blockLoader BlockLoader) *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, onlyBlockSigner bool) types.DeputyNodes

GetDeputiesByHeight 通过height获取对应的节点列表。若onlyBlockSigner为true则获取当前可签名的节点的任期信息,false则获取当前已当选的节点的任期信息

func (*Manager) GetDeputiesCount

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

GetDeputiesCount 获取共识节点数量

func (*Manager) GetDeputyByAddress

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

GetDeputyByAddress 获取address对应的节点

func (*Manager) GetDeputyByDistance added in v1.4.0

func (m *Manager) GetDeputyByDistance(targetHeight uint32, parentBlockMiner common.Address, distance uint32) (*types.DeputyNode, error)

GetDeputyByDistance find a deputy from parent block miner by miner index distance. The distance should always greater than 0

func (*Manager) GetDeputyByNodeID

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

GetDeputyByNodeID 根据nodeID获取对应的节点

func (*Manager) GetMinerDistance added in v1.2.0

func (m *Manager) GetMinerDistance(targetHeight uint32, parentBlockMiner, targetMiner common.Address) (uint32, error)

GetMinerDistance get miner index distance. It is always greater than 0 and not greater than deputy count

func (*Manager) GetMyDeputyInfo added in v1.3.0

func (m *Manager) GetMyDeputyInfo(height uint32) *types.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, onlyBlockSigner bool) (*TermRecord, error)

GetTermByHeight 通过height获取对应的任期信息。若onlyBlockSigner为true则获取当前可签名的节点的任期信息,false则获取当前已当选的节点的任期信息

func (*Manager) IsEvilDeputyNode added in v1.3.0

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

IsEvilDeputyNode test if a deputy node is in blacklist

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)

PutEvilDeputyNode put a deputy node into blacklist for a while

func (*Manager) SaveSnapshot added in v1.2.0

func (m *Manager) SaveSnapshot(snapshotHeight uint32, nodes types.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     types.DeputyNodes `json:"nodes"`     // include deputy nodes and candidate nodes
}

func NewTermRecord added in v1.2.0

func NewTermRecord(snapshotHeight uint32, nodes types.DeputyNodes) *TermRecord

func (*TermRecord) GetDeputies added in v1.2.0

func (t *TermRecord) GetDeputies(count int) types.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