| 83 | } |
| 84 | |
| 85 | static const char *last_time_check(const struct rune *rune, |
| 86 | struct cond_info *cinfo, |
| 87 | u64 n_sec) |
| 88 | { |
| 89 | u64 diff; |
| 90 | struct timeabs last_used; |
| 91 | |
| 92 | if (!wallet_get_rune(tmpctx, cinfo->runes->ld->wallet, atol(rune->unique_id), &last_used)) { |
| 93 | /* Never used: update_rune_usage_time will add it. */ |
| 94 | return NULL; |
| 95 | } |
| 96 | if (time_before(cinfo->now, last_used)) { |
| 97 | last_used = cinfo->now; |
| 98 | } |
| 99 | |
| 100 | diff = time_to_nsec(time_between(cinfo->now, last_used)); |
| 101 | if (diff < n_sec) { |
| 102 | return "too soon"; |
| 103 | } |
| 104 | return NULL; |
| 105 | } |
| 106 | |
| 107 | static const char *per_time_check(const tal_t *ctx, |
| 108 | const struct runes *runes, |
no test coverage detected