MCPcopy Create free account
hub / github.com/ElementsProject/lightning / last_time_check

Function last_time_check

lightningd/runes.c:82–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82static const char *last_time_check(const struct rune *rune,
83 struct cond_info *cinfo,
84 u64 n_sec)
85{
86 u64 diff;
87 struct timeabs last_used;
88
89 if (!wallet_get_rune(tmpctx, cinfo->runes->ld->wallet, atol(rune->unique_id), &last_used)) {
90 /* FIXME: If we do not know the rune, per does not work */
91 return NULL;
92 }
93 if (time_before(cinfo->now, last_used)) {
94 last_used = cinfo->now;
95 }
96
97 diff = time_to_nsec(time_between(cinfo->now, last_used));
98 if (diff < n_sec) {
99 return "too soon";
100 }
101 return NULL;
102}
103
104static const char *per_time_check(const tal_t *ctx,
105 const struct runes *runes,

Callers 2

per_time_checkFunction · 0.85
rate_limit_checkFunction · 0.85

Calls 4

wallet_get_runeFunction · 0.85
time_beforeFunction · 0.85
time_to_nsecFunction · 0.85
time_betweenFunction · 0.85

Tested by

no test coverage detected