20#ifndef RIPPLE_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED
21#define RIPPLE_PATH_IMPL_FLOWDEBUGINFO_H_INCLUDED
23#include <xrpld/app/paths/detail/AmountSpec.h>
24#include <xrpld/ledger/PaymentSandbox.h>
25#include <xrpl/protocol/IOUAmount.h>
26#include <xrpl/protocol/XRPAmount.h>
28#include <boost/container/flat_map.hpp>
42 boost::container::flat_map<std::string, std::pair<time_point, time_point>>
44 boost::container::flat_map<std::string, std::size_t>
counts;
85 out.push_back(out_amt);
94 "ripple::path::detail::FlowDebugInfo::pushLiquiditySrc : "
95 "non-empty liquidity source");
129 "ripple::path::detail::FlowDebugInfo::duration : timepoint not "
133 auto const& t = i->second;
134 return std::chrono::duration_cast<std::chrono::duration<double>>(
141 auto i =
counts.find(tag);
156 : tag(std::move(name)), info(&pi)
158 auto const start = FlowDebugInfo::clock::now();
163 auto const end = FlowDebugInfo::clock::now();
166 Stopper(Stopper&&) =
default;
168 return Stopper(std::move(name), *
this);
174 auto i =
counts.find(tag);
222 ostr <<
"duration: " << d.count() <<
", pass_count: " <<
passCount();
227 [&ostr](
auto const& vals,
auto&& fun,
char delim =
';') {
231 ostr << fun(vals[0]);
232 for (
size_t i = 1, e = vals.size(); i < e; ++i)
233 ostr << delim << fun(vals[i]);
237 auto writeXrpAmtList = [&write_list](
243 write_list(amts, get_val, delim);
245 auto writeIouAmtList = [&write_list](
251 write_list(amts, get_val, delim);
253 auto writeIntList = [&write_list](
256 auto get_val = [](
size_t const& v) ->
size_t const& {
259 write_list(vals, get_val);
261 auto writeNestedIouAmtList =
262 [&ostr, &writeIouAmtList](
267 writeIouAmtList(amts[0],
'|');
268 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
271 writeIouAmtList(amts[i],
'|');
276 auto writeNestedXrpAmtList =
277 [&ostr, &writeXrpAmtList](
282 writeXrpAmtList(amts[0],
'|');
283 for (
size_t i = 1, e = amts.
size(); i < e; ++i)
286 writeXrpAmtList(amts[i],
'|');
292 ostr <<
", in_pass: ";
297 ostr <<
", out_pass: ";
302 ostr <<
", num_active: ";
307 ostr <<
", l_src_in: ";
312 ostr <<
", l_src_out: ";
330 auto const k = elem.first;
331 auto const v = elem.second;
332 ostr << '[' << get<0>(k) <<
'|' << get<1>(k) <<
'|' << get<2>(k) <<
'|' << v
346 for (; begin != end; ++begin)
369 auto const& diffs = bd->first;
370 auto const& xrpDestroyed = bd->second;
372 ostr <<
", xrpDestroyed: " <<
to_string(xrpDestroyed);
373 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)