MCPcopy Create free account
hub / github.com/CPChain/chain / GetBlockGenerationInfo

Method GetBlockGenerationInfo

internal/cpcapi/api.go:549–574  ·  view source on GitHub ↗

GetBlockGenerationInfo returns current committee and it's Info

()

Source from the content-addressed store, hash-verified

547
548// GetBlockGenerationInfo returns current committee and it's Info
549func (s *PublicBlockChainAPI) GetBlockGenerationInfo() cpclient.BlockGenerationInfo {
550
551 t := s.b.CurrentTerm()
552 pi := s.b.CurrentProposerIndex()
553 v := s.b.CurrentView()
554 b := s.b.CurrentBlock()
555 cm := len(s.b.CommitteMember())
556 proposers, err := s.b.Proposers(rpc.BlockNumber(b.Number().Uint64()))
557 if err != nil {
558 log.Fatal("get proposer error")
559 }
560
561 header, err := s.b.HeaderByNumber(context.Background(), rpc.LatestBlockNumber)
562 blockGenerationInfo := cpclient.BlockGenerationInfo{
563 ProposerIndex: pi,
564 Term: t,
565 View: v,
566 Proposer: header.Coinbase,
567 BlockNumber: header.Number.Uint64(),
568 TermLen: cm,
569 Proposers: proposers,
570 }
571
572 return blockGenerationInfo
573
574}
575
576func (s *PublicBlockChainAPI) GetBlockReward(blockNr rpc.BlockNumber) uint64 {
577 return s.b.BlockReward(blockNr).Uint64()

Callers

nothing calls this directly

Calls 11

BlockNumberMethod · 0.80
Uint64Method · 0.80
CurrentTermMethod · 0.65
CurrentProposerIndexMethod · 0.65
CurrentViewMethod · 0.65
CurrentBlockMethod · 0.65
CommitteMemberMethod · 0.65
ProposersMethod · 0.65
FatalMethod · 0.65
HeaderByNumberMethod · 0.65
NumberMethod · 0.45

Tested by

no test coverage detected