diff --git a/PathRequest_8cpp_source.html b/PathRequest_8cpp_source.html index 4f421f2133..64302e154b 100644 --- a/PathRequest_8cpp_source.html +++ b/PathRequest_8cpp_source.html @@ -609,233 +609,232 @@ $(function() {
538  continueCallback);
539  if (!pathfinder)
540  {
-
541  assert(continueCallback && !continueCallback());
-
542  JLOG(m_journal.debug()) << iIdentifier << " No paths found";
-
543  continue;
-
544  }
-
545 
-
546  STPath fullLiquidityPath;
-
547  auto ps = pathfinder->getBestPaths(
-
548  max_paths_,
-
549  fullLiquidityPath,
-
550  mContext[issue],
-
551  issue.account,
-
552  continueCallback);
-
553  mContext[issue] = ps;
-
554 
-
555  auto const& sourceAccount = [&] {
-
556  if (!isXRP(issue.account))
-
557  return issue.account;
-
558 
-
559  if (isXRP(issue.currency))
-
560  return xrpAccount();
-
561 
-
562  return *raSrcAccount;
-
563  }();
-
564 
-
565  STAmount saMaxAmount = saSendMax.value_or(
-
566  STAmount({issue.currency, sourceAccount}, 1u, 0, true));
-
567 
-
568  JLOG(m_journal.debug())
-
569  << iIdentifier << " Paths found, calling rippleCalc";
-
570 
-
571  path::RippleCalc::Input rcInput;
-
572  if (convert_all_)
-
573  rcInput.partialPaymentAllowed = true;
-
574  auto sandbox =
-
575  std::make_unique<PaymentSandbox>(&*cache->getLedger(), tapNONE);
-
576  auto rc = path::RippleCalc::rippleCalculate(
-
577  *sandbox,
-
578  saMaxAmount, // --> Amount to send is unlimited
-
579  // to get an estimate.
-
580  dst_amount, // --> Amount to deliver.
-
581  *raDstAccount, // --> Account to deliver to.
-
582  *raSrcAccount, // --> Account sending from.
-
583  ps, // --> Path set.
-
584  app_.logs(),
-
585  &rcInput);
-
586 
-
587  if (!convert_all_ && !fullLiquidityPath.empty() &&
-
588  (rc.result() == terNO_LINE || rc.result() == tecPATH_PARTIAL))
-
589  {
-
590  JLOG(m_journal.debug())
-
591  << iIdentifier << " Trying with an extra path element";
-
592 
-
593  ps.push_back(fullLiquidityPath);
-
594  sandbox =
-
595  std::make_unique<PaymentSandbox>(&*cache->getLedger(), tapNONE);
-
596  rc = path::RippleCalc::rippleCalculate(
-
597  *sandbox,
-
598  saMaxAmount, // --> Amount to send is unlimited
-
599  // to get an estimate.
-
600  dst_amount, // --> Amount to deliver.
-
601  *raDstAccount, // --> Account to deliver to.
-
602  *raSrcAccount, // --> Account sending from.
-
603  ps, // --> Path set.
-
604  app_.logs());
-
605 
-
606  if (rc.result() != tesSUCCESS)
-
607  {
-
608  JLOG(m_journal.warn())
-
609  << iIdentifier << " Failed with covering path "
-
610  << transHuman(rc.result());
-
611  }
-
612  else
-
613  {
-
614  JLOG(m_journal.debug())
-
615  << iIdentifier << " Extra path element gives "
-
616  << transHuman(rc.result());
-
617  }
-
618  }
-
619 
-
620  if (rc.result() == tesSUCCESS)
-
621  {
-
622  Json::Value jvEntry(Json::objectValue);
-
623  rc.actualAmountIn.setIssuer(sourceAccount);
-
624  jvEntry[jss::source_amount] =
-
625  rc.actualAmountIn.getJson(JsonOptions::none);
-
626  jvEntry[jss::paths_computed] = ps.getJson(JsonOptions::none);
-
627 
-
628  if (convert_all_)
-
629  jvEntry[jss::destination_amount] =
-
630  rc.actualAmountOut.getJson(JsonOptions::none);
-
631 
-
632  if (hasCompletion())
-
633  {
-
634  // Old ripple_path_find API requires this
-
635  jvEntry[jss::paths_canonical] = Json::arrayValue;
-
636  }
-
637 
-
638  jvArray.append(jvEntry);
-
639  }
-
640  else
-
641  {
-
642  JLOG(m_journal.debug()) << iIdentifier << " rippleCalc returns "
-
643  << transHuman(rc.result());
-
644  }
-
645  }
-
646 
-
647  /* The resource fee is based on the number of source currencies used.
-
648  The minimum cost is 50 and the maximum is 400. The cost increases
-
649  after four source currencies, 50 - (4 * 4) = 34.
-
650  */
-
651  int const size = sourceCurrencies.size();
-
652  consumer_.charge({std::clamp(size * size + 34, 50, 400), "path update"});
-
653  return true;
-
654 }
-
655 
-
656 Json::Value
-
657 PathRequest::doUpdate(
-
658  std::shared_ptr<RippleLineCache> const& cache,
-
659  bool fast,
-
660  std::function<bool(void)> const& continueCallback)
-
661 {
-
662  using namespace std::chrono;
-
663  JLOG(m_journal.debug())
-
664  << iIdentifier << " update " << (fast ? "fast" : "normal");
-
665 
-
666  {
-
667  std::lock_guard sl(mLock);
-
668 
-
669  if (!isValid(cache))
-
670  return jvStatus;
-
671  }
-
672 
-
673  Json::Value newStatus = Json::objectValue;
-
674 
-
675  if (hasCompletion())
-
676  {
-
677  // Old ripple_path_find API gives destination_currencies
-
678  auto& destCurrencies =
-
679  (newStatus[jss::destination_currencies] = Json::arrayValue);
-
680  auto usCurrencies = accountDestCurrencies(*raDstAccount, cache, true);
-
681  for (auto const& c : usCurrencies)
-
682  destCurrencies.append(to_string(c));
-
683  }
-
684 
-
685  newStatus[jss::source_account] = toBase58(*raSrcAccount);
-
686  newStatus[jss::destination_account] = toBase58(*raDstAccount);
-
687  newStatus[jss::destination_amount] = saDstAmount.getJson(JsonOptions::none);
-
688  newStatus[jss::full_reply] = !fast;
-
689 
-
690  if (jvId)
-
691  newStatus[jss::id] = jvId;
-
692 
-
693  bool loaded = app_.getFeeTrack().isLoadedLocal();
-
694 
-
695  if (iLevel == 0)
-
696  {
-
697  // first pass
-
698  if (loaded || fast)
-
699  iLevel = app_.config().PATH_SEARCH_FAST;
-
700  else
-
701  iLevel = app_.config().PATH_SEARCH;
-
702  }
-
703  else if ((iLevel == app_.config().PATH_SEARCH_FAST) && !fast)
-
704  {
-
705  // leaving fast pathfinding
-
706  iLevel = app_.config().PATH_SEARCH;
-
707  if (loaded && (iLevel > app_.config().PATH_SEARCH_FAST))
-
708  --iLevel;
-
709  }
-
710  else if (bLastSuccess)
-
711  {
-
712  // decrement, if possible
-
713  if (iLevel > app_.config().PATH_SEARCH ||
-
714  (loaded && (iLevel > app_.config().PATH_SEARCH_FAST)))
-
715  --iLevel;
-
716  }
-
717  else
-
718  {
-
719  // adjust as needed
-
720  if (!loaded && (iLevel < app_.config().PATH_SEARCH_MAX))
-
721  ++iLevel;
-
722  if (loaded && (iLevel > app_.config().PATH_SEARCH_FAST))
-
723  --iLevel;
-
724  }
-
725 
-
726  JLOG(m_journal.debug()) << iIdentifier << " processing at level " << iLevel;
-
727 
-
728  Json::Value jvArray = Json::arrayValue;
-
729  if (findPaths(cache, iLevel, jvArray, continueCallback))
-
730  {
-
731  bLastSuccess = jvArray.size() != 0;
-
732  newStatus[jss::alternatives] = std::move(jvArray);
-
733  }
-
734  else
-
735  {
-
736  bLastSuccess = false;
-
737  newStatus = rpcError(rpcINTERNAL);
-
738  }
-
739 
-
740  if (fast && quick_reply_ == steady_clock::time_point{})
-
741  {
-
742  quick_reply_ = steady_clock::now();
-
743  mOwner.reportFast(duration_cast<milliseconds>(quick_reply_ - created_));
-
744  }
-
745  else if (!fast && full_reply_ == steady_clock::time_point{})
-
746  {
-
747  full_reply_ = steady_clock::now();
-
748  mOwner.reportFull(duration_cast<milliseconds>(full_reply_ - created_));
-
749  }
-
750 
-
751  {
-
752  std::lock_guard sl(mLock);
-
753  jvStatus = newStatus;
-
754  }
-
755 
-
756  JLOG(m_journal.debug())
-
757  << iIdentifier << " update finished " << (fast ? "fast" : "normal");
-
758  return newStatus;
-
759 }
-
760 
-
761 InfoSub::pointer
-
762 PathRequest::getSubscriber() const
-
763 {
-
764  return wpSubscriber.lock();
-
765 }
-
766 
-
767 } // namespace ripple
+
541  JLOG(m_journal.debug()) << iIdentifier << " No paths found";
+
542  continue;
+
543  }
+
544 
+
545  STPath fullLiquidityPath;
+
546  auto ps = pathfinder->getBestPaths(
+
547  max_paths_,
+
548  fullLiquidityPath,
+
549  mContext[issue],
+
550  issue.account,
+
551  continueCallback);
+
552  mContext[issue] = ps;
+
553 
+
554  auto const& sourceAccount = [&] {
+
555  if (!isXRP(issue.account))
+
556  return issue.account;
+
557 
+
558  if (isXRP(issue.currency))
+
559  return xrpAccount();
+
560 
+
561  return *raSrcAccount;
+
562  }();
+
563 
+
564  STAmount saMaxAmount = saSendMax.value_or(
+
565  STAmount({issue.currency, sourceAccount}, 1u, 0, true));
+
566 
+
567  JLOG(m_journal.debug())
+
568  << iIdentifier << " Paths found, calling rippleCalc";
+
569 
+
570  path::RippleCalc::Input rcInput;
+
571  if (convert_all_)
+
572  rcInput.partialPaymentAllowed = true;
+
573  auto sandbox =
+
574  std::make_unique<PaymentSandbox>(&*cache->getLedger(), tapNONE);
+
575  auto rc = path::RippleCalc::rippleCalculate(
+
576  *sandbox,
+
577  saMaxAmount, // --> Amount to send is unlimited
+
578  // to get an estimate.
+
579  dst_amount, // --> Amount to deliver.
+
580  *raDstAccount, // --> Account to deliver to.
+
581  *raSrcAccount, // --> Account sending from.
+
582  ps, // --> Path set.
+
583  app_.logs(),
+
584  &rcInput);
+
585 
+
586  if (!convert_all_ && !fullLiquidityPath.empty() &&
+
587  (rc.result() == terNO_LINE || rc.result() == tecPATH_PARTIAL))
+
588  {
+
589  JLOG(m_journal.debug())
+
590  << iIdentifier << " Trying with an extra path element";
+
591 
+
592  ps.push_back(fullLiquidityPath);
+
593  sandbox =
+
594  std::make_unique<PaymentSandbox>(&*cache->getLedger(), tapNONE);
+
595  rc = path::RippleCalc::rippleCalculate(
+
596  *sandbox,
+
597  saMaxAmount, // --> Amount to send is unlimited
+
598  // to get an estimate.
+
599  dst_amount, // --> Amount to deliver.
+
600  *raDstAccount, // --> Account to deliver to.
+
601  *raSrcAccount, // --> Account sending from.
+
602  ps, // --> Path set.
+
603  app_.logs());
+
604 
+
605  if (rc.result() != tesSUCCESS)
+
606  {
+
607  JLOG(m_journal.warn())
+
608  << iIdentifier << " Failed with covering path "
+
609  << transHuman(rc.result());
+
610  }
+
611  else
+
612  {
+
613  JLOG(m_journal.debug())
+
614  << iIdentifier << " Extra path element gives "
+
615  << transHuman(rc.result());
+
616  }
+
617  }
+
618 
+
619  if (rc.result() == tesSUCCESS)
+
620  {
+
621  Json::Value jvEntry(Json::objectValue);
+
622  rc.actualAmountIn.setIssuer(sourceAccount);
+
623  jvEntry[jss::source_amount] =
+
624  rc.actualAmountIn.getJson(JsonOptions::none);
+
625  jvEntry[jss::paths_computed] = ps.getJson(JsonOptions::none);
+
626 
+
627  if (convert_all_)
+
628  jvEntry[jss::destination_amount] =
+
629  rc.actualAmountOut.getJson(JsonOptions::none);
+
630 
+
631  if (hasCompletion())
+
632  {
+
633  // Old ripple_path_find API requires this
+
634  jvEntry[jss::paths_canonical] = Json::arrayValue;
+
635  }
+
636 
+
637  jvArray.append(jvEntry);
+
638  }
+
639  else
+
640  {
+
641  JLOG(m_journal.debug()) << iIdentifier << " rippleCalc returns "
+
642  << transHuman(rc.result());
+
643  }
+
644  }
+
645 
+
646  /* The resource fee is based on the number of source currencies used.
+
647  The minimum cost is 50 and the maximum is 400. The cost increases
+
648  after four source currencies, 50 - (4 * 4) = 34.
+
649  */
+
650  int const size = sourceCurrencies.size();
+
651  consumer_.charge({std::clamp(size * size + 34, 50, 400), "path update"});
+
652  return true;
+
653 }
+
654 
+
655 Json::Value
+
656 PathRequest::doUpdate(
+
657  std::shared_ptr<RippleLineCache> const& cache,
+
658  bool fast,
+
659  std::function<bool(void)> const& continueCallback)
+
660 {
+
661  using namespace std::chrono;
+
662  JLOG(m_journal.debug())
+
663  << iIdentifier << " update " << (fast ? "fast" : "normal");
+
664 
+
665  {
+
666  std::lock_guard sl(mLock);
+
667 
+
668  if (!isValid(cache))
+
669  return jvStatus;
+
670  }
+
671 
+
672  Json::Value newStatus = Json::objectValue;
+
673 
+
674  if (hasCompletion())
+
675  {
+
676  // Old ripple_path_find API gives destination_currencies
+
677  auto& destCurrencies =
+
678  (newStatus[jss::destination_currencies] = Json::arrayValue);
+
679  auto usCurrencies = accountDestCurrencies(*raDstAccount, cache, true);
+
680  for (auto const& c : usCurrencies)
+
681  destCurrencies.append(to_string(c));
+
682  }
+
683 
+
684  newStatus[jss::source_account] = toBase58(*raSrcAccount);
+
685  newStatus[jss::destination_account] = toBase58(*raDstAccount);
+
686  newStatus[jss::destination_amount] = saDstAmount.getJson(JsonOptions::none);
+
687  newStatus[jss::full_reply] = !fast;
+
688 
+
689  if (jvId)
+
690  newStatus[jss::id] = jvId;
+
691 
+
692  bool loaded = app_.getFeeTrack().isLoadedLocal();
+
693 
+
694  if (iLevel == 0)
+
695  {
+
696  // first pass
+
697  if (loaded || fast)
+
698  iLevel = app_.config().PATH_SEARCH_FAST;
+
699  else
+
700  iLevel = app_.config().PATH_SEARCH;
+
701  }
+
702  else if ((iLevel == app_.config().PATH_SEARCH_FAST) && !fast)
+
703  {
+
704  // leaving fast pathfinding
+
705  iLevel = app_.config().PATH_SEARCH;
+
706  if (loaded && (iLevel > app_.config().PATH_SEARCH_FAST))
+
707  --iLevel;
+
708  }
+
709  else if (bLastSuccess)
+
710  {
+
711  // decrement, if possible
+
712  if (iLevel > app_.config().PATH_SEARCH ||
+
713  (loaded && (iLevel > app_.config().PATH_SEARCH_FAST)))
+
714  --iLevel;
+
715  }
+
716  else
+
717  {
+
718  // adjust as needed
+
719  if (!loaded && (iLevel < app_.config().PATH_SEARCH_MAX))
+
720  ++iLevel;
+
721  if (loaded && (iLevel > app_.config().PATH_SEARCH_FAST))
+
722  --iLevel;
+
723  }
+
724 
+
725  JLOG(m_journal.debug()) << iIdentifier << " processing at level " << iLevel;
+
726 
+
727  Json::Value jvArray = Json::arrayValue;
+
728  if (findPaths(cache, iLevel, jvArray, continueCallback))
+
729  {
+
730  bLastSuccess = jvArray.size() != 0;
+
731  newStatus[jss::alternatives] = std::move(jvArray);
+
732  }
+
733  else
+
734  {
+
735  bLastSuccess = false;
+
736  newStatus = rpcError(rpcINTERNAL);
+
737  }
+
738 
+
739  if (fast && quick_reply_ == steady_clock::time_point{})
+
740  {
+
741  quick_reply_ = steady_clock::now();
+
742  mOwner.reportFast(duration_cast<milliseconds>(quick_reply_ - created_));
+
743  }
+
744  else if (!fast && full_reply_ == steady_clock::time_point{})
+
745  {
+
746  full_reply_ = steady_clock::now();
+
747  mOwner.reportFull(duration_cast<milliseconds>(full_reply_ - created_));
+
748  }
+
749 
+
750  {
+
751  std::lock_guard sl(mLock);
+
752  jvStatus = newStatus;
+
753  }
+
754 
+
755  JLOG(m_journal.debug())
+
756  << iIdentifier << " update finished " << (fast ? "fast" : "normal");
+
757  return newStatus;
+
758 }
+
759 
+
760 InfoSub::pointer
+
761 PathRequest::getSubscriber() const
+
762 {
+
763  return wpSubscriber.lock();
+
764 }
+
765 
+
766 } // namespace ripple
ripple::badCurrency
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
Definition: UintTypes.cpp:129
ripple::Application
Definition: Application.h:116
@@ -879,7 +878,7 @@ $(function() {
ripple::PathRequest::raDstAccount
std::optional< AccountID > raDstAccount
Definition: PathRequest.h:151
ripple::Config::PATH_SEARCH_MAX
int PATH_SEARCH_MAX
Definition: Config.h:208
ripple::PathRequest::doStatus
Json::Value doStatus(Json::Value const &) override
Definition: PathRequest.cpp:453
-
ripple::PathRequest::doUpdate
Json::Value doUpdate(std::shared_ptr< RippleLineCache > const &, bool fast, std::function< bool(void)> const &continueCallback={})
Definition: PathRequest.cpp:657
+
ripple::PathRequest::doUpdate
Json::Value doUpdate(std::shared_ptr< RippleLineCache > const &, bool fast, std::function< bool(void)> const &continueCallback={})
Definition: PathRequest.cpp:656
ripple::Application::getFeeTrack
virtual LoadFeeTrack & getFeeTrack()=0
ripple::STAmount::getIssuer
AccountID const & getIssuer() const
Definition: STAmount.h:362
ripple::PathRequest::quick_reply_
std::chrono::steady_clock::time_point quick_reply_
Definition: PathRequest.h:170
@@ -962,7 +961,7 @@ $(function() {
ripple::PathRequest::needsUpdate
bool needsUpdate(bool newOnly, LedgerIndex index)
Definition: PathRequest.cpp:125
std::unordered_map
STL class.
ripple::STAmount::getCurrency
Currency const & getCurrency() const
Definition: STAmount.h:356
-
ripple::PathRequest::getSubscriber
InfoSub::pointer getSubscriber() const
Definition: PathRequest.cpp:762
+
ripple::PathRequest::getSubscriber
InfoSub::pointer getSubscriber() const
Definition: PathRequest.cpp:761
ripple::PathRequest::m_journal
beast::Journal m_journal
Definition: PathRequest.h:136
ripple::tesSUCCESS
@ tesSUCCESS
Definition: TER.h:233
ripple::PathRequest::parseJson
int parseJson(Json::Value const &)
Definition: PathRequest.cpp:274
diff --git a/PathRequest_8h_source.html b/PathRequest_8h_source.html index ee495a551f..afa9191625 100644 --- a/PathRequest_8h_source.html +++ b/PathRequest_8h_source.html @@ -266,7 +266,7 @@ $(function() {
ripple::PathRequest::fCompletion
std::function< void(void)> fCompletion
Definition: PathRequest.h:143
ripple::PathRequest::raDstAccount
std::optional< AccountID > raDstAccount
Definition: PathRequest.h:151
ripple::PathRequest::doStatus
Json::Value doStatus(Json::Value const &) override
Definition: PathRequest.cpp:453
-
ripple::PathRequest::doUpdate
Json::Value doUpdate(std::shared_ptr< RippleLineCache > const &, bool fast, std::function< bool(void)> const &continueCallback={})
Definition: PathRequest.cpp:657
+
ripple::PathRequest::doUpdate
Json::Value doUpdate(std::shared_ptr< RippleLineCache > const &, bool fast, std::function< bool(void)> const &continueCallback={})
Definition: PathRequest.cpp:656
ripple::PathRequest::quick_reply_
std::chrono::steady_clock::time_point quick_reply_
Definition: PathRequest.h:170
ripple::base_uint
Integers of any length that is a multiple of 32-bits.
Definition: base_uint.h:82
ripple::PathRequest::PathRequest
PathRequest(Application &app, std::shared_ptr< InfoSub > const &subscriber, int id, PathRequests &, beast::Journal journal)
Definition: PathRequest.cpp:42
@@ -305,7 +305,7 @@ $(function() {
std::unique_ptr
STL class.
ripple::PathRequest::needsUpdate
bool needsUpdate(bool newOnly, LedgerIndex index)
Definition: PathRequest.cpp:125
std::unordered_map
STL class.
-
ripple::PathRequest::getSubscriber
InfoSub::pointer getSubscriber() const
Definition: PathRequest.cpp:762
+
ripple::PathRequest::getSubscriber
InfoSub::pointer getSubscriber() const
Definition: PathRequest.cpp:761
ripple::PathRequest::m_journal
beast::Journal m_journal
Definition: PathRequest.h:136
ripple::PathRequest::parseJson
int parseJson(Json::Value const &)
Definition: PathRequest.cpp:274
set
diff --git a/classripple_1_1PathRequest.html b/classripple_1_1PathRequest.html index 4ce9113159..b039bd518d 100644 --- a/classripple_1_1PathRequest.html +++ b/classripple_1_1PathRequest.html @@ -664,7 +664,7 @@ Static Private Attributes
-

Definition at line 657 of file PathRequest.cpp.

+

Definition at line 656 of file PathRequest.cpp.

@@ -683,7 +683,7 @@ Static Private Attributes
-

Definition at line 762 of file PathRequest.cpp.

+

Definition at line 761 of file PathRequest.cpp.

diff --git a/md____w_rippled_rippled_docs_build_conan.html b/md____w_rippled_rippled_docs_build_conan.html index 4c3fcf817a..aeee726b72 100644 --- a/md____w_rippled_rippled_docs_build_conan.html +++ b/md____w_rippled_rippled_docs_build_conan.html @@ -84,7 +84,7 @@ CMake Conan

These next few paragraphs on Conan are going to read much like the ones above for CMake.

Technically, you don't need Conan to build this project. You could manually download, configure, build, and install all of the dependencies yourself, and then pass all of the parameters necessary for CMake to link to those dependencies. To guarantee ABI compatibility, you must be sure to use the same set of compiler and linker options for all dependencies and this project. However, that is very tedious and error-prone, which is why we lean on tools like Conan.

-

We have written a Conan configuration file (conanfile.py) so that Conan can be used to correctly download, configure, build, and install all of the dependencies for this project, using a single set of compiler and linker options for all of them. It generates files that contain almost all of the parameters that CMake expects. Those files include:

+

We have written a Conan configuration file (conanfile.py) so that Conan can be used to correctly download, configure, build, and install all of the dependencies for this project, using a single set of compiler and linker options for all of them. It generates files that contain almost all of the parameters that CMake expects. Those files include: