MCPcopy Create free account
hub / github.com/DeAI-Artist/Linkis / HeaderFromProto

Function HeaderFromProto

types/block.go:541–570  ·  view source on GitHub ↗

FromProto sets a protobuf Header to the given pointer. It returns an error if the header is invalid.

(ph *tmproto.Header)

Source from the content-addressed store, hash-verified

539// FromProto sets a protobuf Header to the given pointer.
540// It returns an error if the header is invalid.
541func HeaderFromProto(ph *tmproto.Header) (Header, error) {
542 if ph == nil {
543 return Header{}, errors.New("nil Header")
544 }
545
546 h := new(Header)
547
548 bi, err := BlockIDFromProto(&ph.LastBlockId)
549 if err != nil {
550 return Header{}, err
551 }
552
553 h.Version = ph.Version
554 h.ChainID = ph.ChainID
555 h.Height = ph.Height
556 h.Time = ph.Time
557 h.Height = ph.Height
558 h.LastBlockID = *bi
559 h.ValidatorsHash = ph.ValidatorsHash
560 h.NextValidatorsHash = ph.NextValidatorsHash
561 h.ConsensusHash = ph.ConsensusHash
562 h.AppHash = ph.AppHash
563 h.DataHash = ph.DataHash
564 h.EvidenceHash = ph.EvidenceHash
565 h.LastResultsHash = ph.LastResultsHash
566 h.LastCommitHash = ph.LastCommitHash
567 h.ProposerAddress = ph.ProposerAddress
568
569 return *h, h.ValidateBasic()
570}
571
572//-------------------------------------
573

Callers 4

BlockMetaFromProtoFunction · 0.85
SignedHeaderFromProtoFunction · 0.85
TestHeaderProtoFunction · 0.85
BlockFromProtoFunction · 0.85

Calls 2

BlockIDFromProtoFunction · 0.85
ValidateBasicMethod · 0.65

Tested by 1

TestHeaderProtoFunction · 0.68