mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
fix: clean up catalogue.cpp todos and improve rippled compatibility
- Remove redundant hash comparison in prevMap check (state maps always differ) - Simplify conditional compilation for CATALOGUE_NODE checks using static_cast - Add proper closeFlags handling for rippled with future-proofing exception - Document that only sLCF_NoConsensusTime exists currently 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -438,7 +438,9 @@ serializeSHAMapToStream(
|
|||||||
std::size_t nodeCount = 0;
|
std::size_t nodeCount = 0;
|
||||||
|
|
||||||
// If we have a previous map, compute differences
|
// If we have a previous map, compute differences
|
||||||
if (prevMap && prevMap->get().getHash() != shaMap.getHash())
|
// State maps are always different between ledgers due to at least the
|
||||||
|
// skiplist updates
|
||||||
|
if (prevMap)
|
||||||
{
|
{
|
||||||
SHAMap::Delta differences;
|
SHAMap::Delta differences;
|
||||||
|
|
||||||
@@ -525,11 +527,7 @@ deserializeSHAMapFromStream(
|
|||||||
SHAMapNodeType& parsedType /* out */) -> bool {
|
SHAMapNodeType& parsedType /* out */) -> bool {
|
||||||
stream.read(reinterpret_cast<char*>(&parsedType), 1);
|
stream.read(reinterpret_cast<char*>(&parsedType), 1);
|
||||||
|
|
||||||
#if IS_XAHAUD
|
|
||||||
if (parsedType == CATALOGUE_NODE_TERMINAL)
|
|
||||||
#else
|
|
||||||
if (static_cast<uint8_t>(parsedType) == CATALOGUE_NODE_TERMINAL)
|
if (static_cast<uint8_t>(parsedType) == CATALOGUE_NODE_TERMINAL)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// end of map
|
// end of map
|
||||||
return false;
|
return false;
|
||||||
@@ -548,11 +546,7 @@ deserializeSHAMapFromStream(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_XAHAUD
|
|
||||||
if (parsedType == CATALOGUE_NODE_REMOVE)
|
|
||||||
#else
|
|
||||||
if (static_cast<uint8_t>(parsedType) == CATALOGUE_NODE_REMOVE)
|
if (static_cast<uint8_t>(parsedType) == CATALOGUE_NODE_REMOVE)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
// deletion
|
// deletion
|
||||||
if (!allowRemoval)
|
if (!allowRemoval)
|
||||||
@@ -616,11 +610,7 @@ deserializeSHAMapFromStream(
|
|||||||
while (!stream.eof() && deserializeLeaf(lastParsed))
|
while (!stream.eof() && deserializeLeaf(lastParsed))
|
||||||
;
|
;
|
||||||
|
|
||||||
#if IS_XAHAUD
|
|
||||||
if (lastParsed != CATALOGUE_NODE_TERMINAL)
|
|
||||||
#else
|
|
||||||
if (static_cast<uint8_t>(lastParsed) != CATALOGUE_NODE_TERMINAL)
|
if (static_cast<uint8_t>(lastParsed) != CATALOGUE_NODE_TERMINAL)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
JLOG(j.error())
|
JLOG(j.error())
|
||||||
<< "Deserialization: Unexpected EOF, terminal node not found.";
|
<< "Deserialization: Unexpected EOF, terminal node not found.";
|
||||||
@@ -1638,7 +1628,19 @@ doCatalogueLoad(RPC::JsonContext& context)
|
|||||||
#if IS_XAHAUD
|
#if IS_XAHAUD
|
||||||
ledger->setCloseFlags(info.closeFlags);
|
ledger->setCloseFlags(info.closeFlags);
|
||||||
#else
|
#else
|
||||||
// rippled doesn't have setCloseFlags - it's set during setAccepted
|
// rippled doesn't have setCloseFlags method - close flags are set
|
||||||
|
// during setAccepted Currently only sLCF_NoConsensusTime (0x01) exists,
|
||||||
|
// which setAccepted() handles properly This check is future-proofing in
|
||||||
|
// case additional close flags are added later
|
||||||
|
if (info.closeFlags & ~sLCF_NoConsensusTime)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
"Catalogue contains close flags that rippled cannot handle. "
|
||||||
|
"closeFlags=0x" +
|
||||||
|
std::to_string(info.closeFlags) +
|
||||||
|
" but rippled only supports sLCF_NoConsensusTime via "
|
||||||
|
"setAccepted()");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
ledger->setImmutable(true);
|
ledger->setImmutable(true);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user