Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2013-03-04 19:25:17 -08:00
16 changed files with 54 additions and 41 deletions

View File

@@ -223,7 +223,7 @@ void SqliteDatabase::doHook(const char *db, int pages)
{
walRunning = true;
if (mWalQ)
mWalQ->addJob(jtWAL, std::string("WAL:") + db, boost::bind(&SqliteDatabase::runWal, this));
mWalQ->addJob(jtWAL, std::string("WAL:") + mHost, boost::bind(&SqliteDatabase::runWal, this));
else
boost::thread(boost::bind(&SqliteDatabase::runWal, this)).detach();
}

View File

@@ -35,6 +35,7 @@ class AccountItems
void fillItems(const uint160& accountID, Ledger::ref ledger);
public:
typedef boost::shared_ptr<AccountItems> pointer;
AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType);

View File

@@ -66,11 +66,11 @@ public:
Job(JobType type, const std::string& name, uint64 index, LoadMonitor& lm, const boost::function<void(Job&)>& job)
: mType(type), mJobIndex(index), mJob(job), mName(name)
{
mLoadMonitor = boost::make_shared<LoadEvent>(boost::ref(lm), false, 1);
mLoadMonitor = boost::make_shared<LoadEvent>(boost::ref(lm), name, false, 1);
}
JobType getType() const { return mType; }
void doJob(void) { mLoadMonitor->start(); mJob(*this); mLoadMonitor->setName(mName); }
void doJob(void) { mLoadMonitor->start(); mJob(*this); mLoadMonitor->reName(mName); }
void rename(const std::string& n) { mName = n; }
bool operator<(const Job& j) const;
@@ -110,10 +110,10 @@ public:
void shutdown();
void setThreadCount(int c = 0);
LoadEvent::pointer getLoadEvent(JobType t)
{ return boost::make_shared<LoadEvent>(boost::ref(mJobLoads[t]), true, 1); }
LoadEvent::autoptr getLoadEventAP(JobType t)
{ return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], true, 1)); }
LoadEvent::pointer getLoadEvent(JobType t, const std::string& name)
{ return boost::make_shared<LoadEvent>(boost::ref(mJobLoads[t]), name, true, 1); }
LoadEvent::autoptr getLoadEventAP(JobType t, const std::string& name)
{ return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], name, true, 1)); }
int isOverloaded();
Json::Value getJson(int c = 0);

View File

@@ -1530,8 +1530,8 @@ void Ledger::pendSave(bool fromConsensus)
++sPendingSaves;
}
boost::thread(boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(),
fromConsensus, theApp->getJobQueue().getLoadEvent(jtDISK))).detach();
boost::thread(boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(), fromConsensus,
theApp->getJobQueue().getLoadEvent(jtDISK, fromConsensus ? "Ledger::cSave" : "Ledger::save"))).detach();
}

View File

@@ -1091,7 +1091,7 @@ void LedgerConsensus::beginAccept(bool synchronous)
else
{
theApp->getIOService().post(boost::bind(&LedgerConsensus::accept, shared_from_this(), consensusSet,
theApp->getJobQueue().getLoadEvent(jtACCEPTLEDGER)));
theApp->getJobQueue().getLoadEvent(jtACCEPTLEDGER, "LedgerConsensus::beginAccept")));
}
}

View File

@@ -64,7 +64,8 @@ protected:
boost::posix_time::ptime mStartTime;
public:
LoadEvent(LoadMonitor& monitor, bool shouldStart, int count) : mMonitor(monitor), mRunning(false), mCount(count)
LoadEvent(LoadMonitor& monitor, const std::string& name, bool shouldStart, int count) :
mMonitor(monitor), mRunning(false), mCount(count), mName(name)
{
mStartTime = boost::posix_time::microsec_clock::universal_time();
if (shouldStart)
@@ -77,7 +78,7 @@ public:
stop();
}
void setName(const std::string& name)
void reName(const std::string& name)
{
mName = name;
}

View File

@@ -259,7 +259,7 @@ void NetworkOPs::runTransactionQueue()
return;
{
LoadEvent::autoptr ev = theApp->getJobQueue().getLoadEventAP(jtTXN_PROC);
LoadEvent::autoptr ev = theApp->getJobQueue().getLoadEventAP(jtTXN_PROC, "runTxnQ");
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
@@ -328,7 +328,7 @@ void NetworkOPs::runTransactionQueue()
Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, stCallback callback)
{
LoadEvent::autoptr ev = theApp->getJobQueue().getLoadEventAP(jtTXN_PROC);
LoadEvent::autoptr ev = theApp->getJobQueue().getLoadEventAP(jtTXN_PROC, "ProcessTXN");
int newFlags = theApp->getSuppression().getFlags(trans->getID());
if ((newFlags & SF_BAD) != 0)

View File

@@ -26,7 +26,7 @@ void OrderBookDB::setup(Ledger::ref ledger)
return;
mSeq = ledger->getLedgerSeq();
LoadEvent::autoptr ev = theApp->getJobQueue().getLoadEventAP(jtOB_SETUP);
LoadEvent::autoptr ev = theApp->getJobQueue().getLoadEventAP(jtOB_SETUP, "OrderBookDB::setup");
mXRPOrders.clear();
mIssuerMap.clear();

View File

@@ -141,7 +141,7 @@ Pathfinder::Pathfinder(Ledger::ref ledger,
theApp->getOrderBookDB().setup(mLedger);
mLoadMonitor = theApp->getJobQueue().getLoadEvent(jtPATH_FIND);
mLoadMonitor = theApp->getJobQueue().getLoadEvent(jtPATH_FIND, "FindPath");
// Construct the default path for later comparison.
@@ -205,6 +205,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
}
LedgerEntrySet lesActive(mLedger);
boost::unordered_map<uint160, AccountItems::pointer> aiMap;
SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID));
if (!sleSrc)
@@ -285,6 +286,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
continue;
}
if (sLog(lsTRACE))
{
cLog(lsTRACE) << "findPaths: finish? account: " << (speEnd.mAccountID == mDstAccountID);
cLog(lsTRACE) << "findPaths: finish? currency: " << (speEnd.mCurrencyID == mDstAmount.getCurrency());
cLog(lsTRACE) << "findPaths: finish? issuer: "
@@ -293,7 +296,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
<< RippleAddress::createHumanAccountID(mDstAmount.getIssuer())
<< " / "
<< RippleAddress::createHumanAccountID(mDstAccountID);
cLog(lsDEBUG) << "findPaths: finish? issuer is desired: " << (speEnd.mIssuerID == mDstAmount.getIssuer());
cLog(lsTRACE) << "findPaths: finish? issuer is desired: " << (speEnd.mIssuerID == mDstAmount.getIssuer());
}
// YYY Allows going through self. Is this wanted?
if (speEnd.mAccountID == mDstAccountID // Tail is destination account.
@@ -343,7 +347,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
{
// Path is at maximum size. Don't want to add more.
cLog(lsDEBUG)
cLog(lsTRACE)
<< boost::str(boost::format("findPaths: dropping: path would exceed max steps"));
continue;
@@ -384,7 +388,13 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
// Last element is for non-XRP, continue by adding ripple lines and order books.
// Create new paths for each outbound account not already in the path.
AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState()));
boost::unordered_map<uint160, AccountItems::pointer>::iterator it = aiMap.find(speEnd.mAccountID);
if (it == aiMap.end())
it = aiMap.insert(std::make_pair(speEnd.mAccountID,
boost::make_shared<AccountItems>(
boost::cref(speEnd.mAccountID), boost::cref(mLedger), AccountItem::pointer(new RippleState())))).first;
AccountItems& rippleLines = *it->second;
SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID));
tLog(!sleEnd, lsDEBUG)
@@ -400,7 +410,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
{
RippleState* rspEntry = (RippleState*) item.get();
const uint160 uPeerID = rspEntry->getAccountIDPeer().getAccountID();
const uint160 uPeerID = rspEntry->getAccountIDPeer();
if (spPath.hasSeen(uPeerID, speEnd.mCurrencyID, uPeerID))
{

View File

@@ -424,7 +424,7 @@ void Peer::processReadBuffer()
// std::cerr << "Peer::processReadBuffer: " << mIpPort.first << " " << mIpPort.second << std::endl;
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtPEER));
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtPEER, "Peer::read"));
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());

View File

@@ -929,7 +929,7 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest)
Json::Value jPeer = Json::Value(Json::objectValue);
jPeer["account"] = line->getAccountIDPeer().humanAccountID();
jPeer["account"] = RippleAddress::createHumanAccountID(line->getAccountIDPeer());
// Amount reported is positive if current account holds other account's IOUs.
// Amount reported is negative if other account holds current account's IOUs.
jPeer["balance"] = saBalance.getText();
@@ -2879,7 +2879,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole)
cLog(lsTRACE) << "COMMAND:" << strCommand;
cLog(lsTRACE) << "REQUEST:" << jvRequest;
LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC));
LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC, "RPC"));
mRole = iRole;

View File

@@ -2521,7 +2521,7 @@ cLog(lsDEBUG) << boost::str(boost::format("rippleCalc: Build direct: status: %s"
}
}
cLog(lsINFO) << "rippleCalc: Paths in set: " << spsPaths.size();
cLog(lsTRACE) << "rippleCalc: Paths in set: " << spsPaths.size();
int iIndex = 0;
BOOST_FOREACH(const STPath& spPath, spsPaths)

View File

@@ -19,8 +19,8 @@ RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(l
mLowLimit = mLedgerEntry->getFieldAmount(sfLowLimit);
mHighLimit = mLedgerEntry->getFieldAmount(sfHighLimit);
mLowID = RippleAddress::createAccountID(mLowLimit.getIssuer());
mHighID = RippleAddress::createAccountID(mHighLimit.getIssuer());
mLowID = mLowLimit.getIssuer();
mHighID = mHighLimit.getIssuer();
mLowQualityIn = mLedgerEntry->getFieldU32(sfLowQualityIn);
mLowQualityOut = mLedgerEntry->getFieldU32(sfLowQualityOut);
@@ -35,7 +35,7 @@ RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(l
void RippleState::setViewAccount(const uint160& accountID)
{
bool bViewLowestNew = mLowID.getAccountID() == accountID;
bool bViewLowestNew = mLowID == accountID;
if (bViewLowestNew != mViewLowest)
{

View File

@@ -19,8 +19,8 @@ public:
private:
uint32 mFlags;
RippleAddress mLowID;
RippleAddress mHighID;
uint160 mLowID;
uint160 mHighID;
STAmount mLowLimit;
STAmount mHighLimit;
@@ -44,8 +44,8 @@ public:
void setViewAccount(const uint160& accountID);
const RippleAddress getAccountID() const { return mViewLowest ? mLowID : mHighID; }
const RippleAddress getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; }
const uint160& getAccountID() const { return mViewLowest ? mLowID : mHighID; }
const uint160& getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; }
bool getAuth() const { return isSetBit(mFlags, mViewLowest ? lsfLowAuth : lsfHighAuth); }
bool getAuthPeer() const { return isSetBit(mFlags, !mViewLowest ? lsfLowAuth : lsfHighAuth); }

View File

@@ -194,7 +194,8 @@ SHAMapTreeNode* SHAMap::walkToPointer(const uint256& id)
{
int branch = inNode->selectBranch(id);
const uint256& nextHash = inNode->getChildHash(branch);
if (nextHash.isZero()) return NULL;
if (nextHash.isZero())
return NULL;
inNode = getNodePointer(inNode->getChildNodeID(branch), nextHash);
assert(inNode);
}

View File

@@ -299,7 +299,7 @@ void ValidationCollection::condWrite()
void ValidationCollection::doWrite(Job&)
{
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK));
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK, "ValidationWrite"));
static boost::format insVal("INSERT INTO Validations "
"(LedgerHash,NodePubKey,SignTime,RawData) VALUES ('%s','%s','%u',%s);");