Documentation
¶
Index ¶
- Variables
- func GetDeputyTermIndexByHeight(height uint32) uint32
- func GetLastSnapshotHeight(height uint32) uint32
- func GetSelfNodeID() []byte
- func GetSelfNodeKey() *ecdsa.PrivateKey
- func GetSignerTermIndexByHeight(height uint32) uint32
- func IsRewardBlock(height uint32) bool
- func IsSnapshotBlock(height uint32) bool
- func SetSelfNodeKey(key *ecdsa.PrivateKey)
- type BlockLoader
- type DeputySalary
- type Manager
- func (m *Manager) GetDeputiesByHeight(height uint32, onlyBlockSigner bool) types.DeputyNodes
- func (m *Manager) GetDeputiesCount(height uint32) int
- func (m *Manager) GetDeputyByAddress(height uint32, addr common.Address) *types.DeputyNode
- func (m *Manager) GetDeputyByDistance(targetHeight uint32, parentBlockMiner common.Address, distance uint32) (*types.DeputyNode, error)
- func (m *Manager) GetDeputyByNodeID(height uint32, nodeID []byte) *types.DeputyNode
- func (m *Manager) GetMinerDistance(targetHeight uint32, parentBlockMiner, targetMiner common.Address) (uint32, error)
- func (m *Manager) GetMyDeputyInfo(height uint32) *types.DeputyNode
- func (m *Manager) GetMyMinerAddress(height uint32) (common.Address, bool)
- func (m *Manager) GetTermByHeight(height uint32, onlyBlockSigner bool) (*TermRecord, error)
- func (m *Manager) IsEvilDeputyNode(minerAddress common.Address, currentHeight uint32) bool
- func (m *Manager) IsNodeDeputy(height uint32, nodeID []byte) bool
- func (m *Manager) IsSelfDeputyNode(height uint32) bool
- func (m *Manager) PutEvilDeputyNode(minerAddress common.Address, blockHeight uint32)
- func (m *Manager) SaveSnapshot(snapshotHeight uint32, nodes types.DeputyNodes)
- func (m *Manager) TwoThirdDeputyCount(height uint32) uint32
- type TermRecord
Constants ¶
This section is empty.
Variables ¶
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
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
GetLastSnapshotHeight
func GetSelfNodeID ¶
func GetSelfNodeID() []byte
func GetSelfNodeKey ¶
func GetSelfNodeKey() *ecdsa.PrivateKey
func GetSignerTermIndexByHeight ¶ added in v1.4.0
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
IsRewardBlock 是否该发出块奖励了. 1001001,2001001,3001001,4001001。。。
func SetSelfNodeKey ¶
func SetSelfNodeKey(key *ecdsa.PrivateKey)
Types ¶
type BlockLoader ¶ added in v1.4.0
type DeputySalary ¶
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 ¶
GetDeputiesCount 获取共识节点数量
func (*Manager) GetDeputyByAddress ¶
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
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
IsEvilDeputyNode test if a deputy node is in blacklist
func (*Manager) IsNodeDeputy ¶ added in v1.0.2
IsNodeDeputy
func (*Manager) IsSelfDeputyNode ¶
IsSelfDeputyNode
func (*Manager) PutEvilDeputyNode ¶ added in v1.3.0
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
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.