diff --git a/src/cpp/ripple/Application.cpp b/src/cpp/ripple/Application.cpp index 7b5dd2191..f62cb0632 100644 --- a/src/cpp/ripple/Application.cpp +++ b/src/cpp/ripple/Application.cpp @@ -184,6 +184,10 @@ void Application::setup() theApp->getHashNodeDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") % (theConfig.getSize(siHashNodeDBCache) * 1024))); + theApp->getLedgerDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") % + (theConfig.getSize(siTxnDBCache) * 1024))); + theApp->getTxnDB()->getDB()->executeSQL(boost::str(boost::format("PRAGMA cache_size=-%d;") % + (theConfig.getSize(siLgrDBCache) * 1024))); // // Allow peer connections. diff --git a/src/cpp/ripple/Config.cpp b/src/cpp/ripple/Config.cpp index 8afef2873..096683d3f 100644 --- a/src/cpp/ripple/Config.cpp +++ b/src/cpp/ripple/Config.cpp @@ -498,7 +498,9 @@ int Config::getSize(SizedItemName item) { siLineCacheSize, { 8192, 32768, 131072, 1048576, 0 } }, { siLineCacheAge, { 500, 600, 1800, 3600, 7200 } }, { siHashNodeDBCache, { 24, 48, 64, 128, 256 } }, - }; + { siTxnDBCache, { 4, 8, 32, 64, 128 } }, + { siLgrDBCache, { 4, 8, 32, 64, 128 } } + }; for (int i = 0; i < (sizeof(sizeTable) / sizeof(SizedItem)); ++i) { diff --git a/src/cpp/ripple/Config.h b/src/cpp/ripple/Config.h index 0ceceba59..f6e65856f 100644 --- a/src/cpp/ripple/Config.h +++ b/src/cpp/ripple/Config.h @@ -65,7 +65,9 @@ enum SizedItemName siLedgerFetch, siLineCacheSize, siLineCacheAge, - siHashNodeDBCache + siHashNodeDBCache, + siTxnDBCache, + siLgrDBCache }; struct SizedItem diff --git a/src/cpp/ripple/Ledger.cpp b/src/cpp/ripple/Ledger.cpp index fd34ddd4a..737bda480 100644 --- a/src/cpp/ripple/Ledger.cpp +++ b/src/cpp/ripple/Ledger.cpp @@ -842,14 +842,11 @@ Json::Value Ledger::getJson(int options) if (mCloseTime != 0) { + ledger["close_time"] = mCloseTime; + ledger["close_time_human"] = boost::posix_time::to_simple_string(ptFromSeconds(mCloseTime)); + ledger["close_time_resolution"] = mCloseResolution; if ((mCloseFlags & sLCF_NoConsensusTime) != 0) - ledger["close_time_estimate"] = boost::posix_time::to_simple_string(ptFromSeconds(mCloseTime)); - else - { - ledger["close_time"] = mCloseTime; - ledger["close_time_human"] = boost::posix_time::to_simple_string(ptFromSeconds(mCloseTime)); - ledger["close_time_resolution"] = mCloseResolution; - } + ledger["close_time_estimated"] = true; } } else diff --git a/src/cpp/ripple/LedgerConsensus.cpp b/src/cpp/ripple/LedgerConsensus.cpp index 971bb332a..23744cb1e 100644 --- a/src/cpp/ripple/LedgerConsensus.cpp +++ b/src/cpp/ripple/LedgerConsensus.cpp @@ -201,7 +201,7 @@ void LedgerConsensus::checkOurValidation() v->setTrusted(); v->sign(signingHash, mValPrivate); theApp->isNew(signingHash); - theApp->getValidations().addValidation(v); + theApp->getValidations().addValidation(v, "localMissing"); std::vector validation = v->getSigned(); ripple::TMValidation val; val.set_validation(&validation[0], validation.size()); @@ -1182,7 +1182,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer) v->sign(signingHash, mValPrivate); v->setTrusted(); theApp->isNew(signingHash); // suppress it if we receive it - theApp->getValidations().addValidation(v); + theApp->getValidations().addValidation(v, "local"); theApp->getOPs().setLastValidation(v); std::vector validation = v->getSigned(); ripple::TMValidation val; diff --git a/src/cpp/ripple/LedgerMaster.cpp b/src/cpp/ripple/LedgerMaster.cpp index 50e96b347..4d4920f74 100644 --- a/src/cpp/ripple/LedgerMaster.cpp +++ b/src/cpp/ripple/LedgerMaster.cpp @@ -289,6 +289,9 @@ bool LedgerMaster::shouldAcquire(uint32 currentLedger, uint32 ledgerHistory, uin void LedgerMaster::resumeAcquiring() { + if (theApp->getOPs().isNeedNetworkLedger()) + return; + boost::recursive_mutex::scoped_lock ml(mLock); if (mMissingLedger && mMissingLedger->isDone()) @@ -355,6 +358,9 @@ void LedgerMaster::setFullLedger(Ledger::pointer ledger) cLog(lsDEBUG) << "Ledger " << ledger->getLedgerSeq() << " accepted :" << ledger->getHash(); assert(ledger->peekAccountStateMap()->getHash().isNonZero()); + if (theApp->getOPs().isNeedNetworkLedger()) + return; + boost::recursive_mutex::scoped_lock ml(mLock); mCompleteLedgers.setValue(ledger->getLedgerSeq()); diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 41de7ec1f..0eb3eab40 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1164,10 +1164,10 @@ std::vector return accounts; } -bool NetworkOPs::recvValidation(SerializedValidation::ref val) +bool NetworkOPs::recvValidation(SerializedValidation::ref val, const std::string& source) { - cLog(lsDEBUG) << "recvValidation " << val->getLedgerHash(); - return theApp->getValidations().addValidation(val); + cLog(lsDEBUG) << "recvValidation " << val->getLedgerHash() << " from " << source; + return theApp->getValidations().addValidation(val, source); } Json::Value NetworkOPs::getConsensusInfo() @@ -1665,18 +1665,20 @@ void NetworkOPs::unsubAccountChanges(InfoSub* isrListener) // <-- bool: true=added, false=already there bool NetworkOPs::subLedger(InfoSub::ref isrListener, Json::Value& jvResult) { - Ledger::pointer lpClosed = getClosedLedger(); + Ledger::pointer lpClosed = getValidatedLedger(); + if (lpClosed) + { + jvResult["ledger_index"] = lpClosed->getLedgerSeq(); + jvResult["ledger_hash"] = lpClosed->getHash().ToString(); + jvResult["ledger_time"] = Json::Value::UInt(lpClosed->getCloseTimeNC()); - jvResult["ledger_index"] = lpClosed->getLedgerSeq(); - jvResult["ledger_hash"] = lpClosed->getHash().ToString(); - jvResult["ledger_time"] = Json::Value::UInt(lpClosed->getCloseTimeNC()); + jvResult["fee_ref"] = Json::UInt(lpClosed->getReferenceFeeUnits()); + jvResult["fee_base"] = Json::UInt(lpClosed->getBaseFee()); + jvResult["reserve_base"] = Json::UInt(lpClosed->getReserve(0)); + jvResult["reserve_inc"] = Json::UInt(lpClosed->getReserveInc()); + } - jvResult["fee_ref"] = Json::UInt(lpClosed->getReferenceFeeUnits()); - jvResult["fee_base"] = Json::UInt(lpClosed->getBaseFee()); - jvResult["reserve_base"] = Json::UInt(lpClosed->getReserve(0)); - jvResult["reserve_inc"] = Json::UInt(lpClosed->getReserveInc()); - - if ((mMode == omFULL) || (mMode == omTRACKING)) + if (((mMode == omFULL) || (mMode == omTRACKING)) && !isNeedNetworkLedger()) jvResult["validated_ledgers"] = theApp->getLedgerMaster().getCompleteLedgers(); boost::recursive_mutex::scoped_lock sl(mMonitorLock); diff --git a/src/cpp/ripple/NetworkOPs.h b/src/cpp/ripple/NetworkOPs.h index a7207d7de..3047aa139 100644 --- a/src/cpp/ripple/NetworkOPs.h +++ b/src/cpp/ripple/NetworkOPs.h @@ -253,7 +253,7 @@ public: RippleAddress nodePublic, uint256 checkLedger, bool sigGood); SMAddNode gotTXData(const boost::shared_ptr& peer, const uint256& hash, const std::list& nodeIDs, const std::list< std::vector >& nodeData); - bool recvValidation(SerializedValidation::ref val); + bool recvValidation(SerializedValidation::ref val, const std::string& source); void takePosition(int seq, SHAMap::ref position); SHAMap::pointer getTXMap(const uint256& hash); bool hasTXSet(const boost::shared_ptr& peer, const uint256& set, ripple::TxSetStatus status); diff --git a/src/cpp/ripple/Peer.cpp b/src/cpp/ripple/Peer.cpp index 5f2629131..4a87a4dc4 100644 --- a/src/cpp/ripple/Peer.cpp +++ b/src/cpp/ripple/Peer.cpp @@ -1056,8 +1056,16 @@ static void checkValidation(Job&, SerializedValidation::pointer val, uint256 sig return; } + std::string source; + Peer::pointer lp = peer.lock(); + if (lp) + source = lp->getDisplayName(); + else + source = "unknown"; + std::set peers; - if (theApp->getOPs().recvValidation(val) && theApp->getSuppression().swapSet(signingHash, peers, SF_RELAYED)) + if (theApp->getOPs().recvValidation(val, source) && + theApp->getSuppression().swapSet(signingHash, peers, SF_RELAYED)) { PackedMessage::pointer message = boost::make_shared(*packet, ripple::mtVALIDATION); theApp->getConnectionPool().relayMessageBut(peers, message); diff --git a/src/cpp/ripple/Peer.h b/src/cpp/ripple/Peer.h index 1244a5170..36ba93714 100644 --- a/src/cpp/ripple/Peer.h +++ b/src/cpp/ripple/Peer.h @@ -117,6 +117,7 @@ public: //bool operator == (const Peer& other); std::string& getIP() { return mIpPort.first; } + std::string getDisplayName() { return mCluster ? mNodeName : mIpPort.first; } int getPort() { return mIpPort.second; } void setIpPort(const std::string& strIP, int iPort); diff --git a/src/cpp/ripple/ValidationCollection.cpp b/src/cpp/ripple/ValidationCollection.cpp index 2827c36f5..a9ffab3e1 100644 --- a/src/cpp/ripple/ValidationCollection.cpp +++ b/src/cpp/ripple/ValidationCollection.cpp @@ -34,7 +34,7 @@ VSpointer ValidationCollection::findSet(const uint256& ledgerHash) return mValidations.fetch(ledgerHash); } -bool ValidationCollection::addValidation(SerializedValidation::ref val) +bool ValidationCollection::addValidation(SerializedValidation::ref val, const std::string& source) { RippleAddress signer = val->getSignerPublic(); bool isCurrent = false; @@ -53,7 +53,7 @@ bool ValidationCollection::addValidation(SerializedValidation::ref val) else { cLog(lsDEBUG) << "Node " << signer.humanNodePublic() << " not in UNL st=" << val->getSignTime() << - ", hash=" << val->getLedgerHash() << ", shash=" << val->getSigningHash(); + ", hash=" << val->getLedgerHash() << ", shash=" << val->getSigningHash() << " src=" << source; } uint256 hash = val->getLedgerHash(); diff --git a/src/cpp/ripple/ValidationCollection.h b/src/cpp/ripple/ValidationCollection.h index 112e9c111..d73a546c6 100644 --- a/src/cpp/ripple/ValidationCollection.h +++ b/src/cpp/ripple/ValidationCollection.h @@ -37,7 +37,7 @@ public: ValidationCollection() : mValidations("Validations", 128, 600), mWriting(false) { mStaleValidations.reserve(512); } - bool addValidation(SerializedValidation::ref); + bool addValidation(SerializedValidation::ref, const std::string& source); ValidationSet getValidations(const uint256& ledger); void getValidationCount(const uint256& ledger, bool currentOnly, int& trusted, int& untrusted); void getValidationTypes(const uint256& ledger, int& full, int& partial);