From 38dd9f3f88076720a863b56ddd47298e3f99ce0b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 13 Sep 2012 12:29:06 -0700 Subject: [PATCH] Add metadata JSON to set JSON. Fix a bug where we try to access the existing node when we're creating a node. Extra asserts to catch original node mishandlig. --- src/LedgerEntrySet.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/LedgerEntrySet.cpp b/src/LedgerEntrySet.cpp index 2e5a83c172..0c09282c3a 100644 --- a/src/LedgerEntrySet.cpp +++ b/src/LedgerEntrySet.cpp @@ -257,6 +257,8 @@ Json::Value LedgerEntrySet::getJson(int) const } ret["nodes" ] = nodes; + ret["metaData"] = mSet.getJson(0); + return ret; } @@ -358,7 +360,8 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) continue; SLE::pointer origNode = mLedger->getSLE(it->first); - if (origNode->getType() == ltDIR_NODE) // No metadata for dir nodes + + if (origNode && (origNode->getType() == ltDIR_NODE)) // No metadata for dir nodes continue; SLE::pointer curNode = it->second.mEntry; @@ -366,6 +369,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) if (nType == TMNDeletedNode) { + assert(origNode); threadOwners(metaNode, origNode, mLedger, newMod); if (origNode->getIFieldPresent(sfAmount)) @@ -398,7 +402,10 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) } if (nType == TMNCreatedNode) // if created, thread to owner(s) + { + assert(!origNode); threadOwners(metaNode, curNode, mLedger, newMod); + } if ((nType == TMNCreatedNode) || (nType == TMNModifiedNode)) { @@ -408,6 +415,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s) if (nType == TMNModifiedNode) { + assert(origNode); if (origNode->getIFieldPresent(sfAmount)) { // node has an amount, covers account root nodes and ripple nodes STAmount amount = origNode->getIValueFieldAmount(sfAmount);