Skip to content

Doesn't adhere to enum ordering #908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dignifiedquire opened this issue Sep 5, 2017 · 0 comments
Open

Doesn't adhere to enum ordering #908

dignifiedquire opened this issue Sep 5, 2017 · 0 comments

Comments

@dignifiedquire
Copy link

protobuf.js version: 6.8.0

Given a proto definition like this

// An IPFS MerkleDAG Link
message PBLink {

  // multihash of the target object
  optional bytes Hash = 1;

  // utf string name. should be unique per object
  optional string Name = 2;

  // cumulative size of target object
  optional uint64 Tsize = 3;
}

// An IPFS MerkleDAG Node
message PBNode {

  // refs to other objects
  repeated PBLink Links = 2;

  // opaque user data
  optional bytes Data = 1;
}

I would expect that Links is written before Data, but looking at the generated source code it is the other way around

if (message.Data != null && message.hasOwnProperty("Data"))
            writer.uint32(/* id 1, wireType 2 =*/10).bytes(message.Data);
        if (message.Links != null && message.Links.length)
            for (var i = 0; i < message.Links.length; ++i)
                $root.PBLink.encode(message.Links[i], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim();

As I am doing hash comparisons between serialised objects, this breaks quite a lot of things for me currently.

(Full source: https://github.com/ipld/js-ipld-dag-pb/tree/master/src)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant