blob: c9f348b81a27fc0280ed13e32b7ad60d59c8a6c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/usr/bin/env bash
# Money-moving payout lines must print every time they fire: they are the
# audit trail for obligations created, moved and destroyed, and LogPrint's
# burst collapse can stand one line in for any number of events inside one
# 3-second window (issue #3: 100 voids totalling 4,950 BTF read as one
# 49.49 BTF line). Every line carrying one of the phrases below must use
# LogPrintAlways, which keeps the category gate but skips the collapse.
#
# Adding a payout line that reports money moving? Use LogPrintAlways and
# add its phrase here. A phrase found in a plain LogPrint call fails this
# check; anything else passes, so a non-money line is never held up by it.
set -euo pipefail
cd "$(dirname "$0")/.."
phrases='was orphaned -- voiding|orphaned while queued|\[payout\] paid %s to %s|FAILED to pay|writing off|SKIPPED bad address'
# Call sites span several lines; flatten each call to a single line first so
# the phrase and the macro it belongs to are matched together. Only a line
# whose first token is the macro starts a call, so comments mentioning
# LogPrint are never mistaken for one.
bad=$(awk '
/^[ \t]*LogPrint(Always)?[(]/ {
if (collecting) print buf
buf = $0; collecting = 1; next
}
collecting {
buf = buf $0
if (/;[ \t]*$/) { print buf; collecting = 0 }
}
END { if (collecting) print buf }
' src/rpc.cpp | grep -E '^[[:space:]]*LogPrint[(]' | grep -E "$phrases" || true)
if [ -n "$bad" ]; then
echo "error: money-moving payout line(s) on collapsing LogPrint:" >&2
echo "$bad" >&2
exit 1
fi
echo "ok: every money-moving payout line in src/rpc.cpp uses LogPrintAlways"
|