|
valueTest = `opts.writeDefaults === true || (obj.${name} != null && __${fieldDef.type}Values[obj.${name}] !== 0)` |
message HopMessage {
enum Type {
RESERVE = 0;
CONNECT = 1;
STATUS = 2;
}
required Type type = 1;
optional Peer peer = 2;
optional Reservation reservation = 3;
optional Limit limit = 4;
optional Status status = 5;
}
When I protons this proto, it will gnenerate the code like this:
export const codec = (): Codec<HopMessage> => {
if (_codec == null) {
_codec = message<HopMessage>((obj, w, opts = {}) => {
if (opts.lengthDelimited !== false) {
w.fork()
}
if (opts.writeDefaults === true || (obj.type != null && ___TypeValues[obj.type] !== 0) {
w.uint32(8)
HopMessage.Type.codec().encode(obj.type, w)
}
This will cause the wrong binary data(MALFORM) when I encode the HopMessage with type value is RESERVE when the relay node is kubo
protons/packages/protons/src/index.ts
Line 405 in 51746ec
When I protons this proto, it will gnenerate the code like this:
This will cause the wrong binary data(MALFORM) when I encode the HopMessage with type value is RESERVE when the relay node is kubo