FromProto sets a protobuf Header to the given pointer. It returns an error if the header is invalid.
(ph *tmproto.Header)
| 539 | // FromProto sets a protobuf Header to the given pointer. |
| 540 | // It returns an error if the header is invalid. |
| 541 | func 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 |