Check if amendment is enabled

This commit is contained in:
Bart
2026-02-12 06:31:32 -05:00
parent 52dabc1f79
commit 1cb7c0293f
4 changed files with 8 additions and 11 deletions

View File

@@ -833,7 +833,7 @@ InboundLedger::receiveNode(protocol::TMLedgerData& packet, SHAMapAddNode& san)
auto const nodeKey = static_cast<SHAMapLeafNode const*>(treeNode.get())->peekItem()->key();
SHAMapNodeID nodeID;
if (app_.getAmendmentTable().isSupported(fixLedgerNodeDepth))
if (app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth))
{
nodeID = SHAMapNodeID::createID(ledgerNode.nodedepth(), nodeKey);
}
@@ -1081,8 +1081,8 @@ InboundLedger::processData(std::shared_ptr<Peer> peer, protocol::TMLedgerData& p
for (auto const& ledgerNode : packet.nodes())
{
if (!ledgerNode.has_nodedata() ||
(app_.getAmendmentTable().isSupported(fixLedgerNodeDepth) && !ledgerNode.has_nodedepth()) ||
(!app_.getAmendmentTable().isSupported(fixLedgerNodeDepth) && !ledgerNode.has_nodeid()))
(app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth) && !ledgerNode.has_nodedepth()) ||
(!app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth) && !ledgerNode.has_nodeid()))
{
JLOG(journal_.warn()) << "Got malformed ledger node";
peer->charge(Resource::feeMalformedRequest, "ledger_node");

View File

@@ -219,10 +219,7 @@ public:
for (int i = 0; i < packet_ptr->nodes().size(); ++i)
{
auto const& ledgerNode = packet_ptr->nodes(i);
if (!ledgerNode.has_nodedata() ||
(app_.getAmendmentTable().isSupported(fixLedgerNodeDepth) && !ledgerNode.has_nodedepth()) ||
(!app_.getAmendmentTable().isSupported(fixLedgerNodeDepth) && !ledgerNode.has_nodeid()))
if (!ledgerNode.has_nodedata())
return;
auto treeNode = SHAMapTreeNode::makeFromWire(makeSlice(ledgerNode.nodedata()));

View File

@@ -134,8 +134,8 @@ public:
for (auto const& ledgerNode : packet.nodes())
{
if (!ledgerNode.has_nodedata() ||
(app_.getAmendmentTable().isSupported(fixLedgerNodeDepth) && !ledgerNode.has_nodedepth()) ||
(!app_.getAmendmentTable().isSupported(fixLedgerNodeDepth) && !ledgerNode.has_nodeid()))
(app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth) && !ledgerNode.has_nodedepth()) ||
(!app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth) && !ledgerNode.has_nodeid()))
{
JLOG(j_.warn()) << "Got malformed ledger node";
peer->charge(Resource::feeMalformedRequest, "ledger_node");
@@ -153,7 +153,7 @@ public:
auto const nodeKey = static_cast<SHAMapLeafNode const*>(treeNode.get())->peekItem()->key();
SHAMapNodeID nodeID;
if (app_.getAmendmentTable().isSupported(fixLedgerNodeDepth))
if (app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth))
{
nodeID = SHAMapNodeID::createID(ledgerNode.nodedepth(), nodeKey);
}

View File

@@ -3154,7 +3154,7 @@ PeerImp::processLedgerRequest(std::shared_ptr<protocol::TMGetLedger> const& m)
break;
protocol::TMLedgerNode* node{ledgerData.add_nodes()};
node->set_nodedata(d.second.data(), d.second.size());
if (app_.getAmendmentTable().isSupported(fixLedgerNodeDepth))
if (app_.getAmendmentTable().isEnabled(fixLedgerNodeDepth))
node->set_nodedepth(d.first.getDepth());
else
node->set_nodeid(d.first.getRawString());