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

streak state

Back to all declarations

BlocksPerDay

untyped bigint

BlocksPerDay is the length of a check-in window, in blocks. Chosen so a window is a meaningful stretch of chain activity while keeping tests and demos quick to reason about.

Value

(1000 <untyped> bigint)

maxLeaderboard

untyped bigint

maxLeaderboard caps how many entries Render lists.

Value

(10 <untyped> bigint)

record

type

record is one address's streak state.

Value

streak.record

users

*v0.Tree

users maps address string -> \*record.

Open
OID
063383…cee0:4
users details

Inspect pointer

today

func() int64

today returns the current day index: block height divided into fixed windows.

Open
OID
063383…cee0:6
today details

Inspect func

CheckIn

func() int

CheckIn records a check-in for the caller and returns the resulting streak. Checking in twice in the same window is rejected — the streak only moves when the window does. A gap of exactly one window continues the streak; any larger gap restarts it at 1.

Open
OID
063383…cee0:8
CheckIn details

Inspect func

get

func(addr .uverse.address) *streak.record

get returns the caller's record, or nil. avl/v0's Get returns a single \`any\` (not the value, ok pair Go maps use), so a missing key surfaces as a nil interface rather than a second return value.

Open
OID
063383…cee0:9
get details

Inspect func

Current

func(addr .uverse.address) int

Current returns addr's live streak — 0 once a window has been missed, even though the stored value only updates on the next check-in.

Open
OID
063383…cee0:10
Current details

Inspect func

Best

func(addr .uverse.address) int

Best returns addr's record streak, which is never lowered.

Open
OID
063383…cee0:11
Best details

Inspect func

Day

func() int64

Day returns the current day index.

Open
OID
063383…cee0:12
Day details

Inspect func

entry

type

entry is a flattened record for rendering.

Value

streak.entry

byBest

type

byBest ranks entries by best streak descending, then by address so equal scores always come out in the same order (Render must be deterministic).

Value

streak.byBest

Render

func(path string) string

Render renders the streak board for gnoweb. Render("") / Render("/") -> leaderboard by best streak Render("/<address>") -> that address's standing

Open
OID
063383…cee0:13
Render details

Inspect func

renderOne

func(q string) string

renderOne renders a single address's standing.

Open
OID
063383…cee0:14
renderOne details

Inspect func

all

func() []streak.entry

all flattens the tree into a slice.

Open
OID
063383…cee0:15
all details

Inspect func

parseArg

func(path string) string

parseArg extracts the first path segment.

Open
OID
063383…cee0:16
parseArg details

Inspect func
BlocksPerDay : untyped bigint =(1000 <untyped> bigint)
maxLeaderboard : untyped bigint =(10 <untyped> bigint)
record : type =streak.record
users : *v0.Tree Inspect
today : func() int64 Inspect
CheckIn : func() int Inspect
get : func(addr .uverse.address) *streak.record Inspect
Current : func(addr .uverse.address) int Inspect
Best : func(addr .uverse.address) int Inspect
Day : func() int64 Inspect
entry : type =streak.entry
byBest : type =streak.byBest
Render : func(path string) string Inspect
renderOne : func(q string) string Inspect
all : func() []streak.entry Inspect
parseArg : func(path string) string Inspect