From b0529757903630ea97256d3a404d6f67d9b7986b Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 11 Apr 2013 14:40:13 -0700 Subject: [PATCH] Manual fixes. --- src/cpp/ripple/Amount.cpp | 4 ---- src/cpp/ripple/LedgerAcquire.cpp | 8 +++----- src/cpp/ripple/LedgerConsensus.cpp | 9 ++++++--- src/cpp/ripple/Pathfinder.h | 5 +++++ src/cpp/ripple/RippleState.h | 2 +- src/cpp/ripple/SHAMapDiff.cpp | 22 ++++++++++++---------- src/cpp/ripple/SHAMapSync.cpp | 3 +-- src/cpp/ripple/SerializedTypes.h | 5 +++-- 8 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/cpp/ripple/Amount.cpp b/src/cpp/ripple/Amount.cpp index 8dd45f1472..796bdb7d31 100644 --- a/src/cpp/ripple/Amount.cpp +++ b/src/cpp/ripple/Amount.cpp @@ -230,10 +230,6 @@ std::string STAmount::createHumanCurrency(const uint160& uCurrency) { return "1"; } - else if (CURRENCY_BAD == uCurrency) - { - return uCurrency.ToString(); - } else { Serializer s(160/8); diff --git a/src/cpp/ripple/LedgerAcquire.cpp b/src/cpp/ripple/LedgerAcquire.cpp index 2ca423e981..f48087c9e1 100644 --- a/src/cpp/ripple/LedgerAcquire.cpp +++ b/src/cpp/ripple/LedgerAcquire.cpp @@ -80,8 +80,7 @@ void PeerSet::TimerEntry(boost::weak_ptr wptr, const boost::system::err cLog(lsDEBUG) << "Deferring PeerSet timer due to load"; ptr->setTimer(); } - else theApp->getJobQueue().addJob(jtLEDGER_DATA, "timerEntry", - BIND_TYPE(&PeerSet::TimerJobEntry, P_1, ptr)); + else theApp->getJobQueue().addJob(jtLEDGER_DATA, "timerEntry", BIND_TYPE(&PeerSet::TimerJobEntry, P_1, ptr)); } } @@ -306,11 +305,10 @@ bool LedgerAcquire::addOnComplete(FUNCTION_TYPE t void LedgerAcquire::trigger(Peer::ref peer) { boost::recursive_mutex::scoped_lock sl(mLock); - if (mAborted || mComplete || mFailed) + if (isDone()) { cLog(lsDEBUG) << "Trigger on ledger:" << - (mAborted ? " aborted": "") << (mComplete ? " completed": "") << (mFailed ? " failed" : "") << - " wc=" << mWaitCount; + (mAborted ? " aborted": "") << (mComplete ? " completed": "") << (mFailed ? " failed" : ""); return; } diff --git a/src/cpp/ripple/LedgerConsensus.cpp b/src/cpp/ripple/LedgerConsensus.cpp index f7ebf30fc9..9a2ee1e093 100644 --- a/src/cpp/ripple/LedgerConsensus.cpp +++ b/src/cpp/ripple/LedgerConsensus.cpp @@ -754,7 +754,7 @@ SHAMap::pointer LedgerConsensus::getTransactionTree(const uint256& hash, bool do TransactionAcquire::pointer& acquiring = mAcquiring[hash]; if (!acquiring) { - if (!hash) + if (hash.isZero()) { SHAMap::pointer empty = boost::make_shared(smtTRANSACTION); mapComplete(hash, empty, false); @@ -1336,10 +1336,13 @@ Json::Value LedgerConsensus::getJson(bool full) if (!mAcquired.empty()) { // acquired typedef boost::unordered_map::value_type ac_t; - Json::Value acq(Json::arrayValue); + Json::Value acq(Json::objectValue); BOOST_FOREACH(ac_t& at, mAcquired) { - acq.append(at.first.GetHex()); + if (at.second) + acq[at.first.GetHex()] = "acquired"; + else + acq[at.first.GetHex()] = "failed"; } ret["acquired"] = acq; } diff --git a/src/cpp/ripple/Pathfinder.h b/src/cpp/ripple/Pathfinder.h index 84a25f32e4..acc5e5a7d9 100644 --- a/src/cpp/ripple/Pathfinder.h +++ b/src/cpp/ripple/Pathfinder.h @@ -63,6 +63,11 @@ class Pathfinder bool matchesOrigin(const uint160& currency, const uint160& issuer); + AccountItems& getRippleLines(const uint160& accountID); + + int getPathsOut(const uint160& currency, const uint160& accountID, + bool isAuthRequired, bool isDestCurrency, const uint160& dest); + public: Pathfinder(Ledger::ref ledger, const RippleAddress& srcAccountID, const RippleAddress& dstAccountID, diff --git a/src/cpp/ripple/RippleState.h b/src/cpp/ripple/RippleState.h index c889c64e99..bdc30ce3b5 100644 --- a/src/cpp/ripple/RippleState.h +++ b/src/cpp/ripple/RippleState.h @@ -43,7 +43,7 @@ public: AccountItem::pointer makeItem(const uint160& accountID, SerializedLedgerEntry::ref ledgerEntry); LedgerEntryType getType(){ return(ltRIPPLE_STATE); } - void setViewAccount(const uint160& accountID); + void setViewAccount(const uint160& accountID); const uint160& getAccountID() const { return mViewLowest ? mLowID : mHighID; } const uint160& getAccountIDPeer() const { return !mViewLowest ? mLowID : mHighID; } diff --git a/src/cpp/ripple/SHAMapDiff.cpp b/src/cpp/ripple/SHAMapDiff.cpp index 9ab9121c43..c621233d0e 100644 --- a/src/cpp/ripple/SHAMapDiff.cpp +++ b/src/cpp/ripple/SHAMapDiff.cpp @@ -16,7 +16,7 @@ class SHAMapDiffNode SHAMapNode mNodeID; uint256 mOurHash, mOtherHash; - SHAMapDiffNode(SHAMapNode id, const uint256& ourHash, const uint256& otherHash) : + SHAMapDiffNode(const SHAMapNode& id, const uint256& ourHash, const uint256& otherHash) : mNodeID(id), mOurHash(ourHash), mOtherHash(otherHash) { ; } }; @@ -33,7 +33,7 @@ bool SHAMap::walkBranch(SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, bool { SHAMapTreeNode* node = nodeStack.top(); nodeStack.pop(); - if(node->isInner()) + if (node->isInner()) { // This is an inner node, add all non-empty branches for(int i = 0; i < 16; ++i) if (!node->isEmptyBranch(i)) @@ -56,15 +56,16 @@ bool SHAMap::walkBranch(SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, bool emptyBranch = true; } - if (emptyBranch || (item->getTag() < otherMapItem->getTag())) + if (emptyBranch || (item->getTag() != otherMapItem->getTag())) { // unmatched if (isFirstMap) differences.insert(std::make_pair(item->getTag(), std::make_pair(item, SHAMapItem::pointer()))); else differences.insert(std::make_pair(item->getTag(), std::make_pair(SHAMapItem::pointer(), item))); - if (--maxCount <= 0) return false; + if (--maxCount <= 0) + return false; } - else if (item->getTag() == otherMapItem->getTag()) + else { if (item->peekData() != otherMapItem->peekData()) { // non-matching items @@ -72,11 +73,11 @@ bool SHAMap::walkBranch(SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, bool std::make_pair(item, otherMapItem))); else differences.insert(std::make_pair(otherMapItem->getTag(), std::make_pair(otherMapItem, item))); - if(--maxCount <= 0) return false; - item.reset(); + if(--maxCount <= 0) + return false; } + emptyBranch = true; } - else assert(false); } } @@ -88,7 +89,8 @@ bool SHAMap::walkBranch(SHAMapTreeNode* node, SHAMapItem::ref otherMapItem, bool else differences.insert(std::make_pair(otherMapItem->getTag(), std::make_pair(otherMapItem, SHAMapItem::pointer()))); - if (--maxCount <= 0) return false; + if (--maxCount <= 0) + return false; } return true; @@ -160,7 +162,7 @@ bool SHAMap::compare(SHAMap::ref otherMap, SHAMapDiff& differences, int maxCount else if (ourNode->isInner() && otherNode->isInner()) { for (int i = 0; i < 16; ++i) - if (ourNode->getChildHash(i) != otherNode->getChildHash(i) ) + if (ourNode->getChildHash(i) != otherNode->getChildHash(i)) { if (otherNode->isEmptyBranch(i)) { // We have a branch, the other tree does not diff --git a/src/cpp/ripple/SHAMapSync.cpp b/src/cpp/ripple/SHAMapSync.cpp index 98f6235a40..86ec7d3eb5 100644 --- a/src/cpp/ripple/SHAMapSync.cpp +++ b/src/cpp/ripple/SHAMapSync.cpp @@ -122,11 +122,10 @@ std::vector SHAMap::getNeededHashes(int max) int branch = (base + ii) % 16; if (!node->isEmptyBranch(branch)) { - SHAMapNode childID = node->getChildNodeID(branch); const uint256& childHash = node->getChildHash(branch); try { - SHAMapTreeNode* d = getNodePointer(childID, childHash); + SHAMapTreeNode* d = getNodePointer(node->getChildNodeID(branch), childHash); assert(d); if (d->isInner() && !d->isFullBelow()) { diff --git a/src/cpp/ripple/SerializedTypes.h b/src/cpp/ripple/SerializedTypes.h index bd12388b1a..c0a4fd4529 100644 --- a/src/cpp/ripple/SerializedTypes.h +++ b/src/cpp/ripple/SerializedTypes.h @@ -39,9 +39,10 @@ static inline const uint160& get_u160_zero() { return u160_zero; } static inline const uint160& get_u160_one() { return u160_one; } #define CURRENCY_XRP get_u160_zero() -#define CURRENCY_ONE get_u160_one() // Used as a place holder +#define CURRENCY_ONE get_u160_one() // Used as a place holder +#define CURRENCY_BAD uint160(0x5852500000000000) // Do not allow XRP as an IOU currency. #define ACCOUNT_XRP get_u160_zero() -#define ACCOUNT_ONE get_u160_one() // Used as a place holder +#define ACCOUNT_ONE get_u160_one() // Used as a place holder class SerializedType {