mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Some cleanups that should make Arthur happy.
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
bool TransactionMetaNodeEntry::operator<(const TransactionMetaNodeEntry& e) const
|
||||
{
|
||||
@@ -167,27 +168,24 @@ void TransactionMetaNode::addRaw(Serializer& s)
|
||||
s.add8(mType);
|
||||
s.add256(mNode);
|
||||
mEntries.sort();
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::const_iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
it->addRaw(s);
|
||||
BOOST_FOREACH(TransactionMetaNodeEntry& it, mEntries)
|
||||
it.addRaw(s);
|
||||
s.add8(TMSEndOfNode);
|
||||
}
|
||||
|
||||
TransactionMetaNodeEntry* TransactionMetaNode::findEntry(int nodeType)
|
||||
{
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
if (it->getType() == nodeType)
|
||||
return &*it;
|
||||
BOOST_FOREACH(TransactionMetaNodeEntry& it, mEntries)
|
||||
if (it.getType() == nodeType)
|
||||
return ⁢
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TMNEAmount* TransactionMetaNode::findAmount(int nType)
|
||||
{
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
if (it->getType() == nType)
|
||||
return dynamic_cast<TMNEAmount *>(&*it);
|
||||
BOOST_FOREACH(TransactionMetaNodeEntry& it, mEntries)
|
||||
if (it.getType() == nType)
|
||||
return dynamic_cast<TMNEAmount *>(&it);
|
||||
TMNEAmount* node = new TMNEAmount(nType);
|
||||
mEntries.push_back(node);
|
||||
return node;
|
||||
@@ -200,9 +198,8 @@ void TransactionMetaNode::addNode(TransactionMetaNodeEntry* node)
|
||||
|
||||
bool TransactionMetaNode::thread(const uint256& prevTx, uint32 prevLgr)
|
||||
{
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
if (it->getType() == TMSThread)
|
||||
BOOST_FOREACH(TransactionMetaNodeEntry& it, mEntries)
|
||||
if (it.getType() == TMSThread)
|
||||
return false;
|
||||
addNode(new TMNEThread(prevTx, prevLgr));
|
||||
return true;
|
||||
@@ -210,11 +207,10 @@ bool TransactionMetaNode::thread(const uint256& prevTx, uint32 prevLgr)
|
||||
|
||||
bool TransactionMetaNode::addAmount(int nodeType, const STAmount& amount)
|
||||
{
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
if (it->getType() == nodeType)
|
||||
BOOST_FOREACH(TransactionMetaNodeEntry& it, mEntries)
|
||||
if (it.getType() == nodeType)
|
||||
{
|
||||
TMNEAmount* a = dynamic_cast<TMNEAmount *>(&*it);
|
||||
TMNEAmount* a = dynamic_cast<TMNEAmount *>(&it);
|
||||
assert(a && (a->getAmount() == amount));
|
||||
return false;
|
||||
}
|
||||
@@ -224,11 +220,10 @@ bool TransactionMetaNode::addAmount(int nodeType, const STAmount& amount)
|
||||
|
||||
bool TransactionMetaNode::addAccount(int nodeType, const NewcoinAddress& account)
|
||||
{
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
if (it->getType() == nodeType)
|
||||
BOOST_FOREACH(TransactionMetaNodeEntry& it, mEntries)
|
||||
if (it.getType() == nodeType)
|
||||
{
|
||||
TMNEAccount* a = dynamic_cast<TMNEAccount *>(&*it);
|
||||
TMNEAccount* a = dynamic_cast<TMNEAccount *>(&it);
|
||||
assert(a && (a->getAccount() == account));
|
||||
return false;
|
||||
}
|
||||
@@ -252,9 +247,8 @@ Json::Value TransactionMetaNode::getJson(int v) const
|
||||
ret["node"] = mNode.GetHex();
|
||||
|
||||
Json::Value e = Json::arrayValue;
|
||||
for (boost::ptr_vector<TransactionMetaNodeEntry>::const_iterator it = mEntries.begin(), end = mEntries.end();
|
||||
it != end; ++it)
|
||||
e.append(it->getJson(v));
|
||||
BOOST_FOREACH(const TransactionMetaNodeEntry& it, mEntries)
|
||||
e.append(it.getJson(v));
|
||||
ret["entries"] = e;
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user