snapshots

package
v0.0.0-...-5e88e9b Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenRand

func GenRand(input []byte) (error, []byte)

Types

type CadNodeSnap

type CadNodeSnap struct {
	Number       uint64                     `json:"number"`       // 生成快照的时间点
	Hash         common.Hash                `json:"hash"`         // 生成快照的Block hash
	CanAddresses []common.Address           `json:"cadaddresses"` // 当前的授权用户
	VotePercents map[common.Address]float64 `json:"VotePercents"` //候选节点获得的投票的百分比
}

定义结构体

func CalcuCadNodeSnap

func CalcuCadNodeSnap(db hpbdb.Database, number uint64, hash common.Hash, headers []*types.Header, chain consensus.ChainReader) (*CadNodeSnap, error)

Get snap in community by elections,

func LoadCadNodeSnap

func LoadCadNodeSnap(db hpbdb.Database, hash common.Hash) (*CadNodeSnap, error)

加载快照,直接去数据库中读取

func NewCadNodeSnap

func NewCadNodeSnap(number uint64, hash common.Hash, addresses []common.Address) *CadNodeSnap

创建对象

func NewCadNodeSnapvote

func NewCadNodeSnapvote(number uint64, hash common.Hash, addresses []common.Address, VotePercents map[common.Address]float64) *CadNodeSnap

创建对象

func (*CadNodeSnap) StoreCadNodeSnap

func (c *CadNodeSnap) StoreCadNodeSnap(db hpbdb.Database, hash common.Hash) error

store inserts the snapshot into the database.

type CadWinner

type CadWinner struct {
	NetworkId string         `json:"networkid"` // 获胜者的网络ID
	Address   common.Address `json:"address"`   // 获胜者的地址
	VoteIndex uint64         `json:"voteIndex"` // 获胜者的指标总和
}

定义结构体

type HpbNodeSnap

type HpbNodeSnap struct {

	//Number  uint64                      `json:"number"`  // 生成快照的时间点
	CheckPointNum  uint64                      `json:"checkPointNum"`  // 最近的检查点
	CheckPointHash common.Hash                 `json:"checkPointHash"` // 生成快照的Block hash
	Signers        map[common.Address]struct{} `json:"signers"`        // 当前的授权用户
	Recents        map[uint64]common.Address   `json:"recents"`        // 最近签名者 spam
	Tally          map[common.Address]Tally    `json:"tally"`          // 目前的计票情况
	// contains filtered or unexported fields
}

func CalculateHpbSnap

func CalculateHpbSnap(index uint64, signatures *lru.ARCCache, config *config.PrometheusConfig, number uint64, latestCheckPointNum uint64, latestCheckPointHash common.Hash, chain consensus.ChainReader) (*HpbNodeSnap, error)

func LoadHistorysnap

func LoadHistorysnap(config *config.PrometheusConfig, sigcache *lru.ARCCache, db hpbdb.Database, hash common.Hash) (*HpbNodeSnap, error)

加载快照,直接去数据库中读取

func NewHistorysnap

func NewHistorysnap(config *config.PrometheusConfig, sigcache *lru.ARCCache, number uint64, checkPointNum uint64, checkPointHash common.Hash, signersHash []common.Address) *HpbNodeSnap

为创世块使用

func (*HpbNodeSnap) CalculateCurrentMinerorigin

func (s *HpbNodeSnap) CalculateCurrentMinerorigin(number uint64, signer common.Address) bool

func (*HpbNodeSnap) GetHardwareRandom

func (s *HpbNodeSnap) GetHardwareRandom(number uint64) string

判断当前的次序

func (*HpbNodeSnap) GetHpbNodes

func (s *HpbNodeSnap) GetHpbNodes() []common.Address

已经授权的signers, 无需进行排序

func (*HpbNodeSnap) GetOffset

func (s *HpbNodeSnap) GetOffset(number uint64, signer common.Address) uint64

判断当前的次序

func (*HpbNodeSnap) GetOffsethw

func (s *HpbNodeSnap) GetOffsethw(number uint64, signer common.Address, headers []*types.Header) (uint64, uint64, map[common.Address]uint64)

func (*HpbNodeSnap) Store

func (s *HpbNodeSnap) Store(hash common.Hash, db hpbdb.Database) error

store inserts the snapshot into the database.

func (*HpbNodeSnap) ValidVote

func (s *HpbNodeSnap) ValidVote(address common.Address) bool

判断投票的有效性

type Tally

type Tally struct {
	CandAddress common.Address `json:"candAddress"` // 通过投票的个数
	VoteNumbers *big.Int       `json:"voteNumbers"` // 通过投票的个数
	VoteIndexs  *big.Int       `json:"voteIndexs"`  // 通过投票的个数
	VotePercent *big.Int       `json:"votePercent"` // 通过投票的个数
}

Jump to

Keyboard shortcuts

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