FromProto sets a protobuf BlockID to the given pointer. It returns an error if the block id is invalid.
(bID *tmproto.BlockID)
| 1233 | // FromProto sets a protobuf BlockID to the given pointer. |
| 1234 | // It returns an error if the block id is invalid. |
| 1235 | func BlockIDFromProto(bID *tmproto.BlockID) (*BlockID, error) { |
| 1236 | if bID == nil { |
| 1237 | return nil, errors.New("nil BlockID") |
| 1238 | } |
| 1239 | |
| 1240 | blockID := new(BlockID) |
| 1241 | ph, err := PartSetHeaderFromProto(&bID.PartSetHeader) |
| 1242 | if err != nil { |
| 1243 | return nil, err |
| 1244 | } |
| 1245 | |
| 1246 | blockID.PartSetHeader = *ph |
| 1247 | blockID.Hash = bID.Hash |
| 1248 | |
| 1249 | return blockID, blockID.ValidateBasic() |
| 1250 | } |