prometheus

package
v0.0.0-...-6ec8c49 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: GPL-3.0 Imports: 30 Imported by: 3

Documentation

Overview

Copyright 2018 The go-hpb Authors Modified based on go-ethereum, which Copyright (C) 2014 The go-ethereum Authors.

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 Modified based on go-ethereum, which Copyright (C) 2014 The go-ethereum Authors.

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) GetAllHpbNodes

func (api *API) GetAllHpbNodes(blocknum *rpc.BlockNumber) ([]common.Address, error)

func (*API) GetAllVoters

func (api *API) GetAllVoters(boeaddr common.Address, blocknum *rpc.BlockNumber) (*VoterInfo, error)

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) GetElectedMiner

func (api *API) GetElectedMiner(number *rpc.BlockNumber) (common.Address, 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 {
	AverageValue uint64
	Num          uint64
}

type Prometheus

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

func InstancePrometheus

func InstancePrometheus() *Prometheus

InstanceBlockChain returns the singleton of BlockChain.

func New

func (*Prometheus) APIs

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

API for the terminal

func (*Prometheus) Author

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

retrieve the signer from the signature

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)

generate blocks by giving the signature

func (*Prometheus) GetAllBalances

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

func (*Prometheus) GetAllBalancesByCoin

func (c *Prometheus) GetAllBalancesByCoin(addrlist []common.Address, coinlist []common.Address, state *state.StateDB) (map[common.Address]big.Int, error)
  • GetAllBalancesByCoin *
  • In: addrlist hpnode addresses from contract coinlist hpHolderCoin addresses from contract,Correspond addrlist by index state a pointer to stateDB
  • Out: mapBalance hpnode address->hpHolderCoin address's balance *
  • This function will get the balance of the coinaddress corresponding to the hpnode address.
  • To separate Coinbase account and holdercoin address

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) GetBlockNumberFromBlockSetContract

func (c *Prometheus) GetBlockNumberFromBlockSetContract(chain consensus.ChainReader, header *types.Header, state *state.StateDB, key string) (error, uint64)

* GetBlockNumberFromBlockSetContract * * This function will get a block number from contract with given key.

func (*Prometheus) GetCoinAddressFromElectionContract

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

* GetCoinAddressFromElectionContract * * This function will get all coinbase addresses and holdercoin addresses. * coinbase address and holdercoin address correspond by index

func (*Prometheus) GetCoinAddressFromNewContract

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

* GetCoinAddressFromNewContract * * This function will get all coinbase addresses and holdercoin addresses. * coinbase address and holdercoin address correspond by index

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) GetNodeinfoFromElectContract

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

* GetNodeinfoFromElectContract * * This function will get all boenodes by contract.

func (*Prometheus) GetNodeinfoFromNewContract

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

* GetNodeinfoFromNewContract * * This function will get all boenodes by contract.

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) GetVoteResFromElectionContract

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

* GetVoteResFromElectionContract * * This function will get voteresult by contract.

func (*Prometheus) GetVoteResFromNewContract

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

* GetVoteResFromNewContract * * This function will get voteresult by contract.

func (*Prometheus) PrepareBlockHeader

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

Prepare function for Block

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

Verify one header

func (*Prometheus) VerifyHeaders

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

Verify the headers

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)

type VoterInfo

type VoterInfo struct {
	Voters []common.Address `json:"voters"       gencodec:"required"`
	Nums   []uint64         `json:"nums"       gencodec:"required"`
}

Jump to

Keyboard shortcuts

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