20#ifndef RIPPLE_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED
21#define RIPPLE_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED
23#include <xrpld/app/paths/detail/AmountSpec.h>
25#include <xrpl/ledger/PaymentSandbox.h>
26#include <xrpl/protocol/IOUAmount.h>
27#include <xrpl/protocol/XRPAmount.h>
29#include <boost/container/flat_map.hpp>
43 boost::container::flat_map<std::string, std::pair<time_point, time_point>>
45 boost::container::flat_map<std::string, std::size_t>
counts;
86 out.push_back(out_amt);
95 "ripple::path::detail::FlowDebugInfo::pushLiquiditySrc : "
96 "non-empty liquidity source");
130 "ripple::path::detail::FlowDebugInfo::duration : timepoint not "
134 auto const& t = i->second;
135 return std::chrono::duration_cast<std::chrono::duration<double>>(
142 auto i =
counts.find(tag);
157 : tag(std::move(name)), info(&pi)
159 auto const start = FlowDebugInfo::clock::now();
164 auto const end = FlowDebugInfo::clock::now();
167 Stopper(Stopper&&) =
default;
169 return Stopper(std::move(name), *
this);
175 auto i =
counts.find(tag);
223 ostr <<
"duration: " << d.count() <<
", pass_count: " <<
passCount();
228 [&ostr](
auto const& vals,
auto&& fun,
char delim =
';') {
232 ostr << fun(vals[0]);
233 for (
size_t i = 1, e = vals.size(); i < e; ++i)
234 ostr << delim << fun(vals[i]);
238 auto writeXrpAmtList = [&write_list](
244 write_list(amts, get_val, delim);
246 auto writeIouAmtList = [&write_list](
252 write_list(amts, get_val, delim);
254 auto writeIntList = [&write_list](
257 auto get_val = [](
size_t const& v) ->
size_t const& {
260 write_list(vals, get_val);
262 auto writeNestedIouAmtList =
263 [&ostr, &writeIouAmtList](
268 writeIouAmtList(amts[0],
'|');
269 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
272 writeIouAmtList(amts[i],
'|');
277 auto writeNestedXrpAmtList =
278 [&ostr, &writeXrpAmtList](
283 writeXrpAmtList(amts[0],
'|');
284 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
287 writeXrpAmtList(amts[i],
'|');
293 ostr <<
", in_pass: ";
298 ostr <<
", out_pass: ";
303 ostr <<
", num_active: ";
308 ostr <<
", l_src_in: ";
313 ostr <<
", l_src_out: ";
331 auto const k = elem.first;
332 auto const v = elem.second;
333 ostr << '[' << get<0>(k) <<
'|' << get<1>(k) <<
'|' << get<2>(k) <<
'|' << v
347 for (; begin != end; ++begin)
370 auto const& diffs = bd->first;
371 auto const& xrpDestroyed = bd->second;
373 ostr <<
", xrpDestroyed: " <<
to_string(xrpDestroyed);
374 ostr <<
", balanceDiffs: ";
A wrapper which makes credits unavailable to balances.
XRPAmount xrpDestroyed() const
std::map< std::tuple< AccountID, AccountID, Currency >, STAmount > balanceChanges(ReadView const &view) const
void writeDiffElement(std::ostringstream &ostr, std::pair< std::tuple< AccountID, AccountID, Currency >, STAmount > const &elem)
std::string balanceDiffsToString(std::optional< BalanceDiffs > const &bd)
BalanceDiffs balanceDiffs(PaymentSandbox const &sb, ReadView const &rv)
void writeDiffs(std::ostringstream &ostr, Iter begin, Iter end)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::string to_string(base_uint< Bits, Tag > const &a)
PassInfo(bool nativeIn_, bool nativeOut_)
std::vector< std::vector< EitherAmount > > liquiditySrcIn
std::vector< std::vector< EitherAmount > > liquiditySrcOut
void pushLiquiditySrc(EitherAmount const &eIn, EitherAmount const &eOut)
std::vector< EitherAmount > in
std::vector< EitherAmount > out
void push_back(EitherAmount const &in_amt, EitherAmount const &out_amt, std::size_t active)
std::vector< size_t > numActive
std::string to_string(bool writePassInfo) const
auto timeBlock(std::string name)
std::size_t passCount() const
void pushPass(EitherAmount const &in, EitherAmount const &out, std::size_t activeStrands)
clock::time_point time_point
auto duration(std::string const &tag) const
std::size_t count(std::string const &tag) const
void pushLiquiditySrc(EitherAmount const &in, EitherAmount const &out)
FlowDebugInfo(bool nativeIn, bool nativeOut)
void inc(std::string const &tag)
boost::container::flat_map< std::string, std::size_t > counts
boost::container::flat_map< std::string, std::pair< time_point, time_point > > timePoints
void setCount(std::string const &tag, std::size_t c)