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; walRunning = true;
if (mWalQ) 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 else
boost::thread(boost::bind(&SqliteDatabase::runWal, this)).detach(); boost::thread(boost::bind(&SqliteDatabase::runWal, this)).detach();
} }

View File

@@ -35,6 +35,7 @@ class AccountItems
void fillItems(const uint160& accountID, Ledger::ref ledger); void fillItems(const uint160& accountID, Ledger::ref ledger);
public: public:
typedef boost::shared_ptr<AccountItems> pointer;
AccountItems(const uint160& accountID, Ledger::ref ledger, AccountItem::pointer ofType); 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) 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) : 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; } 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; } void rename(const std::string& n) { mName = n; }
bool operator<(const Job& j) const; bool operator<(const Job& j) const;
@@ -110,10 +110,10 @@ public:
void shutdown(); void shutdown();
void setThreadCount(int c = 0); void setThreadCount(int c = 0);
LoadEvent::pointer getLoadEvent(JobType t) LoadEvent::pointer getLoadEvent(JobType t, const std::string& name)
{ return boost::make_shared<LoadEvent>(boost::ref(mJobLoads[t]), true, 1); } { return boost::make_shared<LoadEvent>(boost::ref(mJobLoads[t]), name, true, 1); }
LoadEvent::autoptr getLoadEventAP(JobType t) LoadEvent::autoptr getLoadEventAP(JobType t, const std::string& name)
{ return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], true, 1)); } { return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], name, true, 1)); }
int isOverloaded(); int isOverloaded();
Json::Value getJson(int c = 0); Json::Value getJson(int c = 0);

View File

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

View File

@@ -1091,7 +1091,7 @@ void LedgerConsensus::beginAccept(bool synchronous)
else else
{ {
theApp->getIOService().post(boost::bind(&LedgerConsensus::accept, shared_from_this(), consensusSet, 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; boost::posix_time::ptime mStartTime;
public: 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(); mStartTime = boost::posix_time::microsec_clock::universal_time();
if (shouldStart) if (shouldStart)
@@ -77,7 +78,7 @@ public:
stop(); stop();
} }
void setName(const std::string& name) void reName(const std::string& name)
{ {
mName = name; mName = name;
} }

View File

@@ -259,7 +259,7 @@ void NetworkOPs::runTransactionQueue()
return; 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()); boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());
@@ -328,7 +328,7 @@ void NetworkOPs::runTransactionQueue()
Transaction::pointer NetworkOPs::processTransaction(Transaction::pointer trans, stCallback callback) 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()); int newFlags = theApp->getSuppression().getFlags(trans->getID());
if ((newFlags & SF_BAD) != 0) if ((newFlags & SF_BAD) != 0)

View File

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

View File

@@ -141,7 +141,7 @@ Pathfinder::Pathfinder(Ledger::ref ledger,
theApp->getOrderBookDB().setup(mLedger); theApp->getOrderBookDB().setup(mLedger);
mLoadMonitor = theApp->getJobQueue().getLoadEvent(jtPATH_FIND); mLoadMonitor = theApp->getJobQueue().getLoadEvent(jtPATH_FIND, "FindPath");
// Construct the default path for later comparison. // 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); LedgerEntrySet lesActive(mLedger);
boost::unordered_map<uint160, AccountItems::pointer> aiMap;
SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID)); SLE::pointer sleSrc = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(mSrcAccountID));
if (!sleSrc) if (!sleSrc)
@@ -285,15 +286,18 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
continue; continue;
} }
cLog(lsTRACE) << "findPaths: finish? account: " << (speEnd.mAccountID == mDstAccountID); if (sLog(lsTRACE))
cLog(lsTRACE) << "findPaths: finish? currency: " << (speEnd.mCurrencyID == mDstAmount.getCurrency()); {
cLog(lsTRACE) << "findPaths: finish? issuer: " cLog(lsTRACE) << "findPaths: finish? account: " << (speEnd.mAccountID == mDstAccountID);
<< RippleAddress::createHumanAccountID(speEnd.mIssuerID) cLog(lsTRACE) << "findPaths: finish? currency: " << (speEnd.mCurrencyID == mDstAmount.getCurrency());
<< " / " cLog(lsTRACE) << "findPaths: finish? issuer: "
<< RippleAddress::createHumanAccountID(mDstAmount.getIssuer()) << RippleAddress::createHumanAccountID(speEnd.mIssuerID)
<< " / " << " / "
<< RippleAddress::createHumanAccountID(mDstAccountID); << RippleAddress::createHumanAccountID(mDstAmount.getIssuer())
cLog(lsDEBUG) << "findPaths: finish? issuer is desired: " << (speEnd.mIssuerID == mDstAmount.getIssuer()); << " / "
<< RippleAddress::createHumanAccountID(mDstAccountID);
cLog(lsTRACE) << "findPaths: finish? issuer is desired: " << (speEnd.mIssuerID == mDstAmount.getIssuer());
}
// YYY Allows going through self. Is this wanted? // YYY Allows going through self. Is this wanted?
if (speEnd.mAccountID == mDstAccountID // Tail is destination account. 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. // 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")); << boost::str(boost::format("findPaths: dropping: path would exceed max steps"));
continue; 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. // 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. // 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)); SLE::pointer sleEnd = lesActive.entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(speEnd.mAccountID));
tLog(!sleEnd, lsDEBUG) 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()) BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
{ {
RippleState* rspEntry = (RippleState*) item.get(); RippleState* rspEntry = (RippleState*) item.get();
const uint160 uPeerID = rspEntry->getAccountIDPeer().getAccountID(); const uint160 uPeerID = rspEntry->getAccountIDPeer();
if (spPath.hasSeen(uPeerID, speEnd.mCurrencyID, uPeerID)) 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; // 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()); 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); 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 positive if current account holds other account's IOUs.
// Amount reported is negative if other account holds current account's IOUs. // Amount reported is negative if other account holds current account's IOUs.
jPeer["balance"] = saBalance.getText(); jPeer["balance"] = saBalance.getText();
@@ -2879,7 +2879,7 @@ Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole)
cLog(lsTRACE) << "COMMAND:" << strCommand; cLog(lsTRACE) << "COMMAND:" << strCommand;
cLog(lsTRACE) << "REQUEST:" << jvRequest; cLog(lsTRACE) << "REQUEST:" << jvRequest;
LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC)); LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC, "RPC"));
mRole = iRole; 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; int iIndex = 0;
BOOST_FOREACH(const STPath& spPath, spsPaths) BOOST_FOREACH(const STPath& spPath, spsPaths)

View File

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

View File

@@ -19,8 +19,8 @@ public:
private: private:
uint32 mFlags; uint32 mFlags;
RippleAddress mLowID; uint160 mLowID;
RippleAddress mHighID; uint160 mHighID;
STAmount mLowLimit; STAmount mLowLimit;
STAmount mHighLimit; STAmount mHighLimit;
@@ -44,8 +44,8 @@ public:
void setViewAccount(const uint160& accountID); void setViewAccount(const uint160& accountID);
const RippleAddress getAccountID() const { return mViewLowest ? mLowID : mHighID; } const uint160& getAccountID() const { return mViewLowest ? mLowID : mHighID; }
const RippleAddress getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; } const uint160& getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; }
bool getAuth() const { return isSetBit(mFlags, mViewLowest ? lsfLowAuth : lsfHighAuth); } bool getAuth() const { return isSetBit(mFlags, mViewLowest ? lsfLowAuth : lsfHighAuth); }
bool getAuthPeer() 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); int branch = inNode->selectBranch(id);
const uint256& nextHash = inNode->getChildHash(branch); const uint256& nextHash = inNode->getChildHash(branch);
if (nextHash.isZero()) return NULL; if (nextHash.isZero())
return NULL;
inNode = getNodePointer(inNode->getChildNodeID(branch), nextHash); inNode = getNodePointer(inNode->getChildNodeID(branch), nextHash);
assert(inNode); assert(inNode);
} }

View File

@@ -299,7 +299,7 @@ void ValidationCollection::condWrite()
void ValidationCollection::doWrite(Job&) 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 " static boost::format insVal("INSERT INTO Validations "
"(LedgerHash,NodePubKey,SignTime,RawData) VALUES ('%s','%s','%u',%s);"); "(LedgerHash,NodePubKey,SignTime,RawData) VALUES ('%s','%s','%u',%s);");