Skip to content
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

Define custom cereal override for ConfigUpgradeSetKey and use it #4247

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/herder/Upgrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "util/Logging.h"
#include "util/ProtocolVersion.h"
#include "util/Timer.h"
#include "util/XDRCereal.h"
#include "util/types.h"
#include "xdrpp/printer.h"
#include <Tracy.hpp>
Expand All @@ -33,7 +34,6 @@
#include <fmt/format.h>
#include <optional>
#include <regex>
#include <xdrpp/cereal.h>
#include <xdrpp/marshal.h>

namespace cereal
Expand Down Expand Up @@ -393,7 +393,7 @@ Upgrades::toString(LedgerUpgrade const& upgrade)
case LEDGER_UPGRADE_CONFIG:
return fmt::format(
FMT_STRING("{}"),
xdr::xdr_to_string(upgrade.newConfig(), "configupgradesetkey"));
sisuresh marked this conversation as resolved.
Show resolved Hide resolved
xdr_to_string(upgrade.newConfig(), "configupgradesetkey"));
case LEDGER_UPGRADE_MAX_SOROBAN_TX_SET_SIZE:
return fmt::format(FMT_STRING("maxsorobantxsetsize={:d}"),
upgrade.newMaxSorobanTxSetSize());
Expand Down Expand Up @@ -436,8 +436,8 @@ Upgrades::toString() const
{
maybePrintUpgradeTime();
r << fmt::format(FMT_STRING(", {}"),
xdr::xdr_to_string(*mParams.mConfigUpgradeSetKey,
"configupgradesetkey"));
xdr_to_string(*mParams.mConfigUpgradeSetKey,
"configupgradesetkey"));
}
return r.str();
}
Expand Down
17 changes: 17 additions & 0 deletions src/util/XDRCereal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ cereal_override(cereal::JSONOutputArchive& ar, const stellar::SCAddress& addr,
}
}

void
cereal_override(cereal::JSONOutputArchive& ar,
const stellar::ConfigUpgradeSetKey& key, const char* field)
{
ar.setNextName(field);
ar.startNode();

xdr::archive(ar,
stellar::strKey::toStrKey(stellar::strKey::STRKEY_CONTRACT,
key.contractID)
.value,
"contractID");
xdr::archive(ar, key.contentHash, "contentHash");

ar.finishNode();
}

void
cereal_override(cereal::JSONOutputArchive& ar,
const stellar::MuxedAccount& muxedAccount, const char* field)
Expand Down
4 changes: 4 additions & 0 deletions src/util/XDRCereal.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ void cereal_override(cereal::JSONOutputArchive& ar, const stellar::PublicKey& s,
void cereal_override(cereal::JSONOutputArchive& ar,
const stellar::SCAddress& addr, const char* field);

void cereal_override(cereal::JSONOutputArchive& ar,
const stellar::ConfigUpgradeSetKey& key,
const char* field);

void cereal_override(cereal::JSONOutputArchive& ar,
const stellar::MuxedAccount& muxedAccount,
const char* field);
Expand Down
Loading