1#ifndef XRPL_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED
2#define XRPL_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED
4#include <xrpld/app/paths/detail/AmountSpec.h>
6#include <xrpl/ledger/PaymentSandbox.h>
7#include <xrpl/protocol/IOUAmount.h>
8#include <xrpl/protocol/XRPAmount.h>
10#include <boost/container/flat_map.hpp>
24 boost::container::flat_map<std::string, std::pair<time_point, time_point>>
26 boost::container::flat_map<std::string, std::size_t>
counts;
67 out.push_back(out_amt);
76 "ripple::path::detail::FlowDebugInfo::pushLiquiditySrc : "
77 "non-empty liquidity source");
112 "ripple::path::detail::FlowDebugInfo::duration : timepoint not "
117 auto const& t = i->second;
118 return std::chrono::duration_cast<std::chrono::duration<double>>(
125 auto i =
counts.find(tag);
140 : tag(std::move(name)), info(&pi)
142 auto const start = FlowDebugInfo::clock::now();
147 auto const end = FlowDebugInfo::clock::now();
150 Stopper(Stopper&&) =
default;
152 return Stopper(std::move(name), *
this);
158 auto i =
counts.find(tag);
206 ostr <<
"duration: " << d.count() <<
", pass_count: " <<
passCount();
211 [&ostr](
auto const& vals,
auto&& fun,
char delim =
';') {
215 ostr << fun(vals[0]);
216 for (
size_t i = 1, e = vals.size(); i < e; ++i)
217 ostr << delim << fun(vals[i]);
221 auto writeXrpAmtList = [&write_list](
227 write_list(amts, get_val, delim);
229 auto writeIouAmtList = [&write_list](
235 write_list(amts, get_val, delim);
237 auto writeIntList = [&write_list](
240 auto get_val = [](
size_t const& v) ->
size_t const& {
243 write_list(vals, get_val);
245 auto writeNestedIouAmtList =
246 [&ostr, &writeIouAmtList](
251 writeIouAmtList(amts[0],
'|');
252 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
255 writeIouAmtList(amts[i],
'|');
260 auto writeNestedXrpAmtList =
261 [&ostr, &writeXrpAmtList](
266 writeXrpAmtList(amts[0],
'|');
267 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
270 writeXrpAmtList(amts[i],
'|');
276 ostr <<
", in_pass: ";
281 ostr <<
", out_pass: ";
286 ostr <<
", num_active: ";
291 ostr <<
", l_src_in: ";
296 ostr <<
", l_src_out: ";
314 auto const k = elem.first;
315 auto const v = elem.second;
316 ostr << '[' << get<0>(k) <<
'|' << get<1>(k) <<
'|' << get<2>(k) <<
'|' << v
330 for (; begin != end; ++begin)
353 auto const& diffs = bd->first;
354 auto const& xrpDestroyed = bd->second;
356 ostr <<
", xrpDestroyed: " <<
to_string(xrpDestroyed);
357 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)