Address reviewer's feedback.

This commit is contained in:
Gregory Tsipenyuk
2026-05-11 10:23:05 -04:00
parent e59cb667e6
commit c33526f88d
2 changed files with 2 additions and 8 deletions

View File

@@ -59,19 +59,11 @@ STIssue::STIssue(SerialIter& sit, SField const& name) : STBase{name}
auto const seqSize = sizeof(std::uint32_t);
if (account == noAccount())
{
// get32() swaps BE wire bytes to host order; memcpy then stores
// host-order bytes into the MPTID. On LE this produces a
// byte-swapped MPTID relative to the canonical value from
// makeMptID(), but add() has the same inversion so the
// round-trip is consistent within a single-arch deployment.
std::uint32_t sequence = sit.get32();
memcpy(mptID.data(), &sequence, sizeof(sequence));
}
else
{
// V2: read raw wire bytes directly into the MPTID. No byte
// swapping; the canonical BE layout from makeMptID() is
// preserved end-to-end.
auto const rawBytes = sit.getRaw(seqSize);
memcpy(mptID.data(), rawBytes.data(), rawBytes.size());
}

View File

@@ -18,6 +18,7 @@
#include <xrpl/protocol/UintTypes.h>
#include <xrpl/protocol/jss.h>
#include <bit>
#include <cstdint>
#include <unordered_set>
@@ -165,6 +166,7 @@ public:
testcase("MPT serialization - serialized sequence bytes are canonical big-endian");
using namespace jtx;
Account const alice{"alice"};
BEAST_EXPECT(std::endian::native == std::endian::little);
// Sequence 240 = 0x000000F0.
// Canonical BE bytes a client would expect: {0x00, 0x00, 0x00, 0xF0}.