redt

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayPeersInfo

func DisplayPeersInfo(url string)

func SignersFromBlock

func SignersFromBlock(header *ethertypes.Header) (author common.Address, signers []common.Address, err error)

SignersFromBlock returns the author of the block (proposer) and the list of signers

Types

type NodeInfo

type NodeInfo struct {
	Operator string `json:"operator"`
	Enode    string `json:"enode"`
	Address  common.Address
}

type RedTNode

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

func NewRedTNode

func NewRedTNode(url string) (*RedTNode, error)

NewRedTNode creates a connection to a blockchain node in the RedT network url can be an HTTP or WebSocket schema

func (*RedTNode) AllValidators

func (rt *RedTNode) AllValidators() map[common.Address]*NodeInfo

func (*RedTNode) BlockByHash added in v0.4.2

func (rt *RedTNode) BlockByHash(blockhash common.Hash) (*ethertypes.Block, error)

BlockByHash returns the given full block.

func (*RedTNode) Close

func (rt *RedTNode) Close()

func (*RedTNode) CurrentBlockNumber

func (rt *RedTNode) CurrentBlockNumber() (int64, error)

CurrentBlockNumber asks the blockchain node for the number of the latest current block

func (*RedTNode) DisplayMyInfo

func (rt *RedTNode) DisplayMyInfo()

func (*RedTNode) DisplayPeersInfo

func (rt *RedTNode) DisplayPeersInfo()

func (*RedTNode) EthClient

func (rt *RedTNode) EthClient() *ethclient.Client

func (*RedTNode) HeaderByNumber

func (rt *RedTNode) HeaderByNumber(number int64) (*ethertypes.Header, error)

HeaderByNumber retrieves a header from the internal cache of from the blockchain node if cache miss

func (*RedTNode) NodeInfo

func (rt *RedTNode) NodeInfo() (*p2p.NodeInfo, error)

func (*RedTNode) Peers

func (rt *RedTNode) Peers() ([]*p2p.PeerInfo, error)

func (*RedTNode) RpcClient

func (rt *RedTNode) RpcClient() *rpc.Client

func (*RedTNode) ValidatorInfo

func (rt *RedTNode) ValidatorInfo(validator common.Address) *NodeInfo

func (*RedTNode) Validators

func (rt *RedTNode) Validators() []common.Address

type SignersTable

type SignersTable struct {
	NextProposer    bool
	CurrentProposer bool
	AsProposer      int
	CurrentSigner   bool
	AsSigner        int
	Name            string
	Address         common.Address
}

type StatisticsRedT

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

func NewStatistics

func NewStatistics(allValidators map[common.Address]*NodeInfo, valSet []common.Address) *StatisticsRedT

NewStatistics creates and initializes a statistics object that will accumulate counters.

func (*StatisticsRedT) StatisticsForFullBlock added in v0.4.2

func (st *StatisticsRedT) StatisticsForFullBlock(fullBlock *ethertypes.Block) *StatisticsSummary

StatisticsForFullBlock returns a map with statistical data prepared for HTML templates

func (*StatisticsRedT) StatisticsForHeader

func (st *StatisticsRedT) StatisticsForHeader(header *ethertypes.Header, latestTimestamp uint64) (map[string]any, uint64)

StatisticsForHeader returns a map with statistical data prepared for HTML templates

func (*StatisticsRedT) StatisticsForHeaderNew

func (st *StatisticsRedT) StatisticsForHeaderNew(header *ethertypes.Header) *StatisticsSummary

StatisticsForHeader returns a map with statistical data prepared for HTML templates

func (*StatisticsRedT) UpdateStatisticsForBlock

func (st *StatisticsRedT) UpdateStatisticsForBlock(header *ethertypes.Header) (author common.Address, signers []common.Address, err error)

UpdateStatisticsForBlock uses the info of the block to update the statistics. It receives a Header (not a full Block) and returns the address of the author and an array with the signers of the block

func (*StatisticsRedT) UpdateStatisticsForFullBlock added in v0.4.2

func (st *StatisticsRedT) UpdateStatisticsForFullBlock(fullblock *ethertypes.Block) (author common.Address, signers []common.Address, err error)

UpdateStatisticsForFullBlock uses the info of the block to update the statistics. It receives a full Block and returns the address of the author and an array with the signers of the block

func (*StatisticsRedT) ValidatorInfo

func (st *StatisticsRedT) ValidatorInfo(validator common.Address) *NodeInfo

ValidatorInfo returns the validator info object associated to the specified address.

func (*StatisticsRedT) ValidatorSet

func (st *StatisticsRedT) ValidatorSet() []common.Address

ValidatorSet returns the current set of validator addresses. It does not make a request to the blockchain node but instead uses the set calculated when the statistics object was created.

type StatisticsSummary

type StatisticsSummary struct {
	BlockNumber      int64
	Elapsed          uint64
	Timestamp        time.Time
	ProposerName     string
	ProposerCount    int
	ProposerAddress  common.Address
	NextProposerName string
	GasLimit         uint64
	GasUsed          uint64
	GasLimitH        string
	GasUsedH         string
	BlockNumTxs      int
	AllNumTxs        int
	Signers          []SignersTable
}

Jump to

Keyboard shortcuts

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