Added Protobuf marshal and unmarshal compatiablity function in block.g…#2705
Added Protobuf marshal and unmarshal compatiablity function in block.g…#2705vlasfama wants to merge 1 commit intotendermint:developfrom vlasfama:grpcdev
Conversation
…o,blockmeta.go,peerround and roundstate.go
|
@melekes Could you please check this PR? |
That's weird. Could you share your |
|
my colleague is working on grpc and as he explained to me he is unable to get block information due to some functions are missed (and it looks they are necessary for marshaling and unmarshaling) |
|
You're using custom types. Now everything makes sense. Thank you |
|
@melekes Hi, any update on GRPC for using custom types in proto. |
Codecov Report
@@ Coverage Diff @@
## develop #2705 +/- ##
===========================================
- Coverage 61.72% 61.49% -0.24%
===========================================
Files 207 207
Lines 16942 16865 -77
===========================================
- Hits 10458 10371 -87
- Misses 5622 5631 +9
- Partials 862 863 +1
|
ebuchman
left a comment
There was a problem hiding this comment.
Would you mind adding a godoc comment to each of these methods stating the interface they satisfy? Even if it's the same comment on each method, ie. // Implements XXX interface for Protobuf compatibility or something, whatever XXX is.
| return cdc.MarshalBinaryBare(ps) | ||
| } | ||
|
|
||
| func (ps *PeerRoundState) MarshalTo(data []byte) (int, error) { |
There was a problem hiding this comment.
Is the idea that Size() is called before calling MarshalTo to ensure the data buffer is correctly sized?
There was a problem hiding this comment.
@ebuchman, yes its used to check the size/len of the buffer.
| } | ||
| // Protobuf Compatiablity | ||
|
|
||
| func (bc *Block) Unmarshal(bs []byte) error { |
There was a problem hiding this comment.
These should be moved up to where the rest of the Block methods live
Added Protbuf marshal and unmarshal compatiablity function in block.go,blockmeta.go,peerround and roundstate.go
As you have mentioned the methods using (https://github.com/gogo/protobuf) for marshal and unmarshal here #2660 , I am using same in my proto file.
but when i create protobuf using above code in my proto, Its generate MarshalTo(),Size(),Unmarshal ()and marshal() methods in protobuf. And gives error from protobuf file saying that its unable to detect MarshalTo() Size() function for particular types, which is not present in tendermint block,blockmeta.go