prometheus

package
v0.0.0-...-3a744d8 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2019 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Copyright 2018 The go-hpb Authors This file is part of the go-hpb.

The go-hpb is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The go-hpb is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the go-hpb. If not, see <http://www.gnu.org/licenses/>.

Copyright 2018 The go-hpb Authors This file is part of the go-hpb.

The go-hpb is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

The go-hpb is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with the go-hpb. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindHpbNode

func FindHpbNode(address common.Address, addresses []common.Address) bool

func PreDealNodeInfo

func PreDealNodeInfo(pairs []p2p.HwPair) (error, []p2p.HwPair)

func SetNetNodeType

func SetNetNodeType(snapa *snapshots.HpbNodeSnap) error

设置网络节点类型

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func (*API) Discard

func (api *API) Discard(address common.Address, confRand string)

改变作废的方式

func (*API) GetCandidateNodeSnap

func (api *API) GetCandidateNodeSnap(number *rpc.BlockNumber) (*snapshots.CadNodeSnap, error)

func (*API) GetCandidateNodes

func (api *API) GetCandidateNodes(number *rpc.BlockNumber) (snapshots.CadNodeSnap, error)

获取候选节点信息

func (*API) GetHpbNodeSnap

func (api *API) GetHpbNodeSnap(number *rpc.BlockNumber) (*snapshots.HpbNodeSnap, error)

获取最新的的快照

func (*API) GetHpbNodeSnapAtHash

func (api *API) GetHpbNodeSnapAtHash(hash common.Hash) (*snapshots.HpbNodeSnap, error)

func (*API) GetHpbNodes

func (api *API) GetHpbNodes(number *rpc.BlockNumber) ([]common.Address, error)

func (*API) GetLatestBlockHeader

func (api *API) GetLatestBlockHeader(number *rpc.BlockNumber) (header *types.Header)

跟根据区块号,获取最新的区块头

func (*API) Proposals

func (api *API) Proposals() map[common.Address]bool

func (*API) Propose

func (api *API) Propose(address common.Address, confRand string, auth bool)

type BandWithStatics

type BandWithStatics struct {
	//Addr common.Address
	AverageValue uint64
	Num          uint64
}

type Prometheus

type Prometheus struct {
	// contains filtered or unexported fields
}

Prometheus 的主体结构

func InstancePrometheus

func InstancePrometheus() *Prometheus

InstanceBlockChain returns the singleton of BlockChain.

func New

func New(config *config.PrometheusConfig, db hpbdb.Database) *Prometheus

新创建,在backend中调用

func (*Prometheus) APIs

func (c *Prometheus) APIs(chain consensus.ChainReader) []rpc.API

返回的API

func (*Prometheus) Author

func (c *Prometheus) Author(header *types.Header) (common.Address, error)

从当前的签名中,返回追溯到签名者

func (*Prometheus) Authorize

func (c *Prometheus) Authorize(signer common.Address, signFn SignerFn)

Authorize injects a private key into the consensus engine to mint new blocks with.

func (*Prometheus) CalculateRewards

func (c *Prometheus) CalculateRewards(chain consensus.ChainReader, state *state.StateDB, header *types.Header, uncles []*types.Header) error

计算奖励

func (*Prometheus) Finalize

func (c *Prometheus) Finalize(chain consensus.ChainReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header, receipts []*types.Receipt) (*types.Block, error)

func (*Prometheus) GenBlockWithSig

func (c *Prometheus) GenBlockWithSig(chain consensus.ChainReader, block *types.Block, stop <-chan struct{}) (*types.Block, error)

生成区块

func (*Prometheus) GetAllBalances

func (c *Prometheus) GetAllBalances(addrlist []common.Address, state *state.StateDB) (map[common.Address]big.Int, error)

func (*Prometheus) GetBandwithRes

func (c *Prometheus) GetBandwithRes(addrlist []common.Address, chain consensus.ChainReader, number uint64) (map[common.Address]int, error)

input number, return key is commonAddress, order is value

func (*Prometheus) GetNextRand

func (c *Prometheus) GetNextRand(lastrand []byte, number uint64) ([]byte, error)

func (*Prometheus) GetNodeinfoFromContract

func (c *Prometheus) GetNodeinfoFromContract(chain consensus.ChainReader, header *types.Header, state *state.StateDB) (error, []p2p.HwPair)

func (*Prometheus) GetRankingRes

func (c *Prometheus) GetRankingRes(voteres map[common.Address]big.Int, addrlist []common.Address) (map[common.Address]int, error)

func (*Prometheus) GetSelectPrehp

func (c *Prometheus) GetSelectPrehp(state *state.StateDB, chain consensus.ChainReader, header *types.Header, number uint64, verify bool) ([]*snapshots.CadWinner, []byte, error)

func (*Prometheus) GetSinger

func (c *Prometheus) GetSinger() common.Address

func (*Prometheus) GetVoteRes

func (c *Prometheus) GetVoteRes(chain consensus.ChainReader, header *types.Header, state *state.StateDB) (error, *big.Int, map[common.Address]big.Int)

func (*Prometheus) PrepareBlockHeader

func (c *Prometheus) PrepareBlockHeader(chain consensus.ChainReader, header *types.Header, state *state.StateDB) error

实现引擎的Prepare函数

func (*Prometheus) SetNetTopology

func (c *Prometheus) SetNetTopology(chain consensus.ChainReader, headers []*types.Header)

func (*Prometheus) SetNetTypeByOneHeader

func (c *Prometheus) SetNetTypeByOneHeader(chain consensus.ChainReader, header *types.Header, parents []*types.Header)

func (*Prometheus) VerifyHeader

func (c *Prometheus) VerifyHeader(chain consensus.ChainReader, header *types.Header, seal bool, mode config.SyncMode) error

验证头部,对外调用接口

func (*Prometheus) VerifyHeaders

func (c *Prometheus) VerifyHeaders(chain consensus.ChainReader, headers []*types.Header, seals []bool, mode config.SyncMode) (chan<- struct{}, <-chan error)

批量验证

func (*Prometheus) VerifySeal

func (c *Prometheus) VerifySeal(chain consensus.ChainReader, header *types.Header) error

VerifySeal implements consensus.Engine, checking whether the signature contained in the header satisfies the consensus protocol requirements.

func (*Prometheus) VerifyUncles

func (c *Prometheus) VerifyUncles(chain consensus.ChainReader, block *types.Block) error

VerifyUncles implements consensus.Engine, always returning an error for any uncles as this consensus mechanism doesn't permit uncles.

type SignerFn

type SignerFn func(accounts.Account, []byte) ([]byte, error)

回掉函数

Jump to

Keyboard shortcuts

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