diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/ripple/app/ledger/LedgerMaster.h index bb29456e3..eb296f0de 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/ripple/app/ledger/LedgerMaster.h @@ -312,8 +312,6 @@ private: std::size_t getNeededValidations(); void - advanceThread(); - void fetchForHistory( std::uint32_t missing, bool& progress, diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/ripple/app/ledger/impl/LedgerMaster.cpp index ecd00e4ba..0bf69dde0 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/ripple/app/ledger/impl/LedgerMaster.cpp @@ -1266,27 +1266,6 @@ LedgerMaster::consensusBuilt( } } -void -LedgerMaster::advanceThread() -{ - std::unique_lock sl(m_mutex); - assert(!mValidLedger.empty() && mAdvanceThread); - - JLOG(m_journal.trace()) << "advanceThread<"; - - try - { - doAdvance(sl); - } - catch (std::exception const&) - { - JLOG(m_journal.fatal()) << "doAdvance throws an exception"; - } - - mAdvanceThread = false; - JLOG(m_journal.trace()) << "advanceThread>"; -} - std::optional LedgerMaster::getLedgerHashForHistory( LedgerIndex index, @@ -1464,8 +1443,25 @@ LedgerMaster::tryAdvance() if (!mAdvanceThread && !mValidLedger.empty()) { mAdvanceThread = true; - app_.getJobQueue().addJob( - jtADVANCE, "advanceLedger", [this](Job&) { advanceThread(); }); + app_.getJobQueue().addJob(jtADVANCE, "advanceLedger", [this](Job&) { + std::unique_lock sl(m_mutex); + + assert(!mValidLedger.empty() && mAdvanceThread); + + JLOG(m_journal.trace()) << "advanceThread<"; + + try + { + doAdvance(sl); + } + catch (std::exception const& ex) + { + JLOG(m_journal.fatal()) << "doAdvance throws: " << ex.what(); + } + + mAdvanceThread = false; + JLOG(m_journal.trace()) << "advanceThread>"; + }); } } diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index a1c8db3b6..73719c4a9 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -42,15 +42,12 @@ #include #include #include -#include #include #include -#include #include #include #include #include -#include #include #include #include diff --git a/src/ripple/app/paths/NodeDirectory.h b/src/ripple/app/paths/NodeDirectory.h deleted file mode 100644 index b9d4a3f07..000000000 --- a/src/ripple/app/paths/NodeDirectory.h +++ /dev/null @@ -1,114 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_APP_PATHS_NODEDIRECTORY_H_INCLUDED -#define RIPPLE_APP_PATHS_NODEDIRECTORY_H_INCLUDED - -#include -#include -#include - -namespace ripple { - -// VFALCO TODO de-inline these function definitions - -class NodeDirectory -{ -public: - explicit NodeDirectory() = default; - - // Current directory - the last 64 bits of this are the quality. - uint256 current; - - // Start of the next order book - one past the worst quality possible - // for the current order book. - uint256 next; - - // TODO(tom): directory.current and directory.next should be of type - // Directory. - - bool advanceNeeded; // Need to advance directory. - bool restartNeeded; // Need to restart directory. - - SLE::pointer ledgerEntry; - - void - restart(bool multiQuality) - { - if (multiQuality) - current = beast::zero; // Restart book searching. - else - restartNeeded = true; // Restart at same quality. - } - - bool - initialize(Book const& book, ApplyView& view) - { - if (current != beast::zero) - return false; - - current = getBookBase(book); - next = getQualityNext(current); - - // TODO(tom): it seems impossible that any actual offers with - // quality == 0 could occur - we should disallow them, and clear - // directory.ledgerEntry without the database call in the next line. - ledgerEntry = view.peek(keylet::page(current)); - - // Advance, if didn't find it. Normal not to be unable to lookup - // firstdirectory. Maybe even skip this lookup. - advanceNeeded = !ledgerEntry; - restartNeeded = false; - - // Associated vars are dirty, if found it. - return bool(ledgerEntry); - } - - enum Advance { NO_ADVANCE, NEW_QUALITY, END_ADVANCE }; - - /** Advance to the next quality directory in the order book. */ - // VFALCO Consider renaming this to `nextQuality` or something - Advance - advance(ApplyView& view) - { - if (!(advanceNeeded || restartNeeded)) - return NO_ADVANCE; - - // Get next quality. - // The Merkel radix tree is ordered by key so we can go to the next - // quality in O(1). - if (advanceNeeded) - { - auto const opt = view.succ(current, next); - current = opt ? *opt : uint256{}; - } - advanceNeeded = false; - restartNeeded = false; - - if (current == beast::zero) - return END_ADVANCE; - - ledgerEntry = view.peek(keylet::page(current)); - return NEW_QUALITY; - } -}; - -} // namespace ripple - -#endif diff --git a/src/ripple/app/paths/Pathfinder.cpp b/src/ripple/app/paths/Pathfinder.cpp index b11d45c31..dec564f3f 100644 --- a/src/ripple/app/paths/Pathfinder.cpp +++ b/src/ripple/app/paths/Pathfinder.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -68,6 +67,10 @@ namespace ripple { namespace { +// This is an arbitrary cutoff, and it might cause us to miss other +// good paths with this arbitrary cut off. +constexpr std::size_t PATHFINDER_MAX_COMPLETE_PATHS = 1000; + struct AccountCandidate { int priority; @@ -318,8 +321,6 @@ Pathfinder::findPaths(int searchLevel) { addPathsForType(costedPath.type); - // TODO(tom): we might be missing other good paths with this - // arbitrary cut off. if (mCompletePaths.size() > PATHFINDER_MAX_COMPLETE_PATHS) break; } diff --git a/src/ripple/app/paths/RippleCalc.cpp b/src/ripple/app/paths/RippleCalc.cpp index 83da1398c..6feb276c6 100644 --- a/src/ripple/app/paths/RippleCalc.cpp +++ b/src/ripple/app/paths/RippleCalc.cpp @@ -19,7 +19,6 @@ #include #include -#include #include #include #include diff --git a/src/ripple/app/paths/Tuning.h b/src/ripple/app/paths/Tuning.h deleted file mode 100644 index b07d3b16f..000000000 --- a/src/ripple/app/paths/Tuning.h +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_APP_PATHS_TUNING_H_INCLUDED -#define RIPPLE_APP_PATHS_TUNING_H_INCLUDED - -namespace ripple { - -int const CALC_NODE_DELIVER_MAX_LOOPS = 100; -int const CALC_NODE_DELIVER_MAX_LOOPS_MQ = 2000; -int const NODE_ADVANCE_MAX_LOOPS = 100; -int const PAYMENT_MAX_LOOPS = 1000; -int const PATHFINDER_HIGH_PRIORITY = 100000; -int const PATHFINDER_MAX_PATHS = 50; -int const PATHFINDER_MAX_COMPLETE_PATHS = 1000; -int const PATHFINDER_MAX_PATHS_FROM_SOURCE = 10; - -} // namespace ripple - -#endif diff --git a/src/ripple/app/paths/Types.h b/src/ripple/app/paths/Types.h deleted file mode 100644 index ce1055e29..000000000 --- a/src/ripple/app/paths/Types.h +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2012, 2013 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_APP_PATHS_TYPES_H_INCLUDED -#define RIPPLE_APP_PATHS_TYPES_H_INCLUDED - -namespace ripple { - -// account id, issue. -using AccountIssue = std::pair; - -// Map of account, issue to node index. -namespace path { - -using NodeIndex = unsigned int; - -} - -using AccountIssueToNodeIndex = hash_map; - -} // namespace ripple - -#endif diff --git a/src/ripple/app/paths/impl/BookStep.cpp b/src/ripple/app/paths/impl/BookStep.cpp index c0fd87458..a80ee13f8 100644 --- a/src/ripple/app/paths/impl/BookStep.cpp +++ b/src/ripple/app/paths/impl/BookStep.cpp @@ -18,7 +18,6 @@ //============================================================================== #include -#include #include #include #include