Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

stats.gno

0.67 Kb · 21 lines
 1package bolo
 2
 3// statsState holds Bolo-wide counters (API §2.4), kept as things happen, never by
 4// walking the campaigns. Gift and refund totals aren't kept: an indexer sums them.
 5type statsState struct {
 6	open    int // campaigns whose close isn't recorded yet
 7	settled int // campaigns settled
 8}
 9
10var stats statsState
11
12// StatsView is what GetStats returns (API §2.4).
13type StatsView struct {
14	Campaigns, Open, Settled int
15}
16
17// GetStats returns Bolo-wide figures (API §4). Open counts a campaign past a deadline
18// nobody recorded until someone does (§3.1).
19func GetStats() StatsView {
20	return StatsView{Campaigns: campaigns.Size(), Open: stats.open, Settled: stats.settled}
21}