mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Bugfix and some more missing pieces.
This commit is contained in:
@@ -99,7 +99,7 @@ TransactionMetaNode::TransactionMetaNode(const uint256& node, SerializerIterator
|
||||
{
|
||||
type = sit.get8();
|
||||
if (type == TransactionMetaNodeEntry::TMNChangedBalance)
|
||||
mEntries.push_back(boost::shared_ptr<TransactionMetaNodeEntry>(new TMNEBalance(sit)));
|
||||
mEntries.insert(boost::shared_ptr<TransactionMetaNodeEntry>(new TMNEBalance(sit)));
|
||||
else if (type != TransactionMetaNodeEntry::TMNEndOfMetadata)
|
||||
throw std::runtime_error("Unparseable metadata");
|
||||
} while (type != TransactionMetaNodeEntry::TMNEndOfMetadata);
|
||||
@@ -110,12 +110,28 @@ void TransactionMetaNode::addRaw(Serializer& s) const
|
||||
s.add256(mNode);
|
||||
s.add256(mPreviousTransaction);
|
||||
s.add32(mPreviousLedger);
|
||||
for (std::list<TransactionMetaNodeEntry::pointer>::const_iterator it = mEntries.begin(), end = mEntries.end();
|
||||
for (std::set<TransactionMetaNodeEntry::pointer>::const_iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
(*it)->addRaw(s);
|
||||
s.add8(TransactionMetaNodeEntry::TMNEndOfMetadata);
|
||||
}
|
||||
|
||||
Json::Value TransactionMetaNode::getJson(int v) const
|
||||
{
|
||||
Json::Value ret = Json::objectValue;
|
||||
ret["node"] = mNode.GetHex();
|
||||
ret["previous_transaction"] = mPreviousTransaction.GetHex();
|
||||
ret["previous_ledger"] = mPreviousLedger;
|
||||
|
||||
Json::Value e = Json::arrayValue;
|
||||
for (std::set<TransactionMetaNodeEntry::pointer>::const_iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
e.append((*it)->getJson(v));
|
||||
ret["entries"] = e;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
TransactionMetaSet::TransactionMetaSet(uint32 ledger, const std::vector<unsigned char>& vec) : mLedger(ledger)
|
||||
{
|
||||
Serializer s(vec);
|
||||
@@ -140,3 +156,19 @@ void TransactionMetaSet::addRaw(Serializer& s) const
|
||||
it->addRaw(s);
|
||||
s.add256(uint256());
|
||||
}
|
||||
|
||||
Json::Value TransactionMetaSet::getJson(int v) const
|
||||
{
|
||||
Json::Value ret = Json::objectValue;
|
||||
|
||||
ret["transaction_id"] = mTransactionID.GetHex();
|
||||
ret["ledger"] = mLedger;
|
||||
|
||||
Json::Value e = Json::arrayValue;
|
||||
for (std::set<TransactionMetaNode>::const_iterator it = mNodes.begin(), end = mNodes.end();
|
||||
it != end; ++it)
|
||||
e.append(it->getJson(v));
|
||||
ret["nodes_affected"] = e;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define __TRANSACTIONMETA__
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
@@ -78,7 +77,7 @@ protected:
|
||||
uint256 mNode;
|
||||
uint256 mPreviousTransaction;
|
||||
uint32 mPreviousLedger;
|
||||
std::list<TransactionMetaNodeEntry::pointer> mEntries;
|
||||
std::set<TransactionMetaNodeEntry::pointer> mEntries;
|
||||
|
||||
public:
|
||||
TransactionMetaNode(const uint256 &node) : mNode(node) { ; }
|
||||
@@ -86,7 +85,7 @@ public:
|
||||
const uint256& getNode() const { return mNode; }
|
||||
const uint256& getPreviousTransaction() const { return mPreviousTransaction; }
|
||||
uint32 getPreviousLedger() const { return mPreviousLedger; }
|
||||
const std::list<TransactionMetaNodeEntry::pointer>& peekEntries() const { return mEntries; }
|
||||
const std::set<TransactionMetaNodeEntry::pointer>& peekEntries() const { return mEntries; }
|
||||
|
||||
bool operator<(const TransactionMetaNode& n) const { return mNode < n.mNode; }
|
||||
bool operator<=(const TransactionMetaNode& n) const { return mNode <= n.mNode; }
|
||||
@@ -95,6 +94,7 @@ public:
|
||||
|
||||
TransactionMetaNode(const uint256&node, SerializerIterator&);
|
||||
void addRaw(Serializer&) const;
|
||||
Json::Value getJson(int) const;
|
||||
};
|
||||
|
||||
class TransactionMetaSet
|
||||
|
||||
Reference in New Issue
Block a user