Skip to content

XDR-JSON Snake casing has surprising behavior #471

Description

@drebelsky

SEP-51 discusses snake_caseing multiple kinds of identifiers, but the specific algorithm is a little unclear. Consider the following

enum IPAddrType
{
    IPv4 = 0,
    IPv6 = 1
};

struct PeerAddress
{
    union switch (IPAddrType type)
    {
    case IPv4:
        opaque ipv4[4];
    case IPv6:
        opaque ipv6[16];
    }
    ip;
    uint32 port;
    uint32 numFailures;
};
$ echo 'AAAAAAAAAAA=' | stellar xdr decode --type PeerAddressIp
{"i_pv4":[0,0,0,0]}
$ echo 'AAAAAAAAAAAAAAAAAAAAAA==' | stellar xdr decode --type PeerAddress
{"ip":{"i_pv4":[0,0,0,0]},"port":0,"num_failures":0}

Note the suboptimal IPv4 to i_pv4 conversion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions