-
Notifications
You must be signed in to change notification settings - Fork 3
/
rules.mk
102 lines (83 loc) · 3.29 KB
/
rules.mk
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
EXTRACTOR_DIR ?= extractor
fetch:
@echo "Backup from: $(FROM_BLOCK) to $(TO_BLOCK)"
go run -C "../$(EXTRACTOR_DIR)" github.com/gnolang/tx-archive/cmd backup \
--remote $(REMOTE) \
--from-block $(FROM_BLOCK) \
--to-block $(TO_BLOCK) \
--output-path "$(shell pwd)/backup_$(shell printf '%07d' $(FROM_BLOCK))-$(shell printf '%07d' $(TO_BLOCK)).jsonl"
# Update metadata
@cat metadata.json | jq -a '.latest_block_height = $(TO_BLOCK)' > /tmp/aa.json
@mv /tmp/aa.json metadata.json
fetch-all:
@for i in `seq $(FROM_BLOCK) $(MAX_INTERVAL) $(LATEST_BLOCK_HEIGHT)`; do \
make -C . fetch FROM_BLOCK="$$i"; \
done
stats:
echo "# $(REMOTE)" > README.md
echo >> README.md
echo "## TXs" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | wc -l >> README.md
echo '```' >> README.md
echo >> README.md
echo "## addpkgs" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | jq '.tx.msg[].package.Path | select( . != null )' | sort | uniq -c | sort --stable -nr >> README.md
echo '```' >> README.md
echo >> README.md
echo "## top realm calls" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | jq '.tx.msg[].pkg_path | select( . != null )' | sort | uniq -c | sort --stable -nr >> README.md
echo '```' >> README.md
echo >> README.md
echo "## top faucet requesters" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | jq -r '.tx.msg[] | select(.["@type"]=="/bank.MsgSend") | select(.["from_address"]=="g127jydsh6cms3lrtdenydxsckh23a8d6emqcvfa") | .to_address + " " + .amount' | sed 's/ugnot$$//' | awk 'NR == 1 {next} {a[$$1] += $$2} {b[$$1] += 1} END {for (i in a) {if (a[i] >= 500000000){printf "%-15s\t%s\t%s\n", i, b[i], a[i]}}}' | sort -rnk2 >> README.md
echo '```' >> README.md
echo >> README.md
stats-legacy:
echo "# $(REMOTE)" > README.md
echo >> README.md
echo "## TXs" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | wc -l >> README.md
echo '```' >> README.md
echo >> README.md
echo "## addpkgs" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | jq '.msg[].package.Path | select( . != null )' | sort | uniq -c | sort --stable -nr >> README.md
echo '```' >> README.md
echo >> README.md
echo "## top realm calls" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | jq '.msg[].pkg_path | select( . != null )' | sort | uniq -c | sort --stable -nr >> README.md
echo '```' >> README.md
echo >> README.md
echo "## top faucet requesters" >> README.md
echo '```' >> README.md
cat backup_*.jsonl | jq -r '.msg[] | select(.["@type"]=="/bank.MsgSend") | select(.["from_address"]=="g127jydsh6cms3lrtdenydxsckh23a8d6emqcvfa") | .to_address + " " + .amount' | sed 's/ugnot$$//' | awk 'NR == 1 {next} {a[$$1] += $$2} {b[$$1] += 1} END {for (i in a) {if (a[i] >= 500000000){printf "%-15s\t%s\t%s\n", i, b[i], a[i]}}}' | sort -rnk2 >> README.md
echo '```' >> README.md
echo >> README.md
extractor:
go run -C "../$(EXTRACTOR_DIR)" . \
-source-path "$(shell pwd)" \
-output-dir "$(shell pwd)/extracted"
extractor-legacy:
go run -C "../$(EXTRACTOR_DIR)" . \
-source-path "$(shell pwd)" \
-output-dir "$(shell pwd)/extracted" \
--legacy-mode
loop:
while true; do \
( \
set -xe; \
make fetch; \
make stats; \
git add .; \
git commit . -sm "chore: update $(SHORTNAME)"; \
git push; \
); \
date; \
sleep $(LOOP_DURATION); \
done