hiero-ledger / hiero-ledger/hiero-consensus-node
Write protobuf delimited events to PCES and gossip
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
Atm, the events serialized to PCES and gossip use protobuf, but the field length is determined externally, outside of PBJ. This is because there is no simple API to write a delimited message using the PBJ codec. In order to write an event as a delimited message, the following approach would need to be taken:
```
FieldDefinition EVENT_CORE = new FieldDefinition("gossip_event", FieldType.MESSAGE, false, false, false, 0);
ProtoWriterTools.writeDelimited(writableSequentialData, fieldDefinition, GossipEvent.PROTOBUF.measureRecord(record), out -> GossipEvent.PROTOBUF.write(record, out));
```
This is not a friendly API. It would be better for the `Codec` to have methods like `writeDelimited` and `parseDelimited`. To make it even simpler, the records could have methods `write` and `writeDelimited`, so that we don't need to reference the codec at all when writing.
The `writeDelimited` and `parseDelimited` methods should also have extra checks to see if the appropriate amount of data was written/read.
This needs a discussion on what the best way forward is.
Contributor guide
Research direction
Start with the PBJ Codec, ProtoWriterTools.writeDelimited, and the current PCES and gossip serialization flow described in the issue. Review the discussion needed for Codec or record-level writeDelimited and parseDelimited APIs, including checks for the expected data length; done means the project has agreed on the API and its scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100