31 #include <type_traits>
39 template<
typename U, u
int64_t (U::*)>
struct SFINAE {};
41 template<
typename U>
static int Test(...);
42 static const bool Has =
sizeof(Test<T>(0)) ==
sizeof(
char);
61 uint64_t expected_credits = (uint64_t)expected_cost;
62 if (expected_credits == 0)
65 rpc_payment_state.
credits = post_call_credits;
68 if (pre_call_credits <= post_call_credits)
71 uint64_t cost = pre_call_credits - post_call_credits;
73 if (cost == expected_credits)
75 MDEBUG(
"Call " << call <<
" cost " << cost <<
" credits");
78 MWARNING(
"Call " << call <<
" cost " << cost <<
" credits, expected " << expected_credits);
80 if (cost > expected_credits)
82 uint64_t
d = cost - expected_credits;
83 if (rpc_payment_state.
discrepancy > std::numeric_limits<uint64_t>::max() -
d)
85 MERROR(
"Integer overflow in credit discrepancy calculation, setting to max");
86 rpc_payment_state.
discrepancy = std::numeric_limits<uint64_t>::max();
int d
Definition: base.py:14
#define true
Definition: stdbool.h:36
Definition: wallet_rpc_helpers.h:39
Definition: wallet_rpc_helpers.h:38
static char Test(SFINAE< U, &U::credits > *)