• Daniel Martí's avatar
    allow decoding PBNode fields in any order · d0b86f76
    Daniel Martí authored
    We recently updated the spec to say that decoders "should" allow
    decoding a PBNode in either order of its fields. That is because some
    IPFS data out in the wild is already encoded in the non-canonical
    format, which is what Protobuf uses as a default, too.
    
    This change makes the decoder here comply with the spec change, adding a
    test with the encoded block that caused this entire spec change in the
    first place: go-ipfs/test/sharness/t0110-gateway-data/foofoo.block.
    
    The change to the decoder is slightly subtle, because the decoder used
    to leverage the knowledge that Links must come before Data to start the
    Links list early, and finish it as soon as Data arrives.
    
    Since that order is now unknown, we must have some extra logic to
    support either order. We also need special code to make sure Links is
    always set, just like before.
    
    We also add a test to double check that Data between Links is rejected.
    d0b86f76
unmarshal.go 6.51 KB