rate
float64// one token every 2 blocks
Value
0.5
burst
float64Limiter configuration, shared by every caller bucket. rate = tokens replenished per block. burst = bucket capacity (max tokens, also the largest single burst).
Value
5
bucket
typebucket is the per-caller state persisted in the avl tree.
Value
ratelimit.bucket
buckets
*v0.Treebuckets maps address string -> \*bucket, ordered by key (deterministic).
- OID
- 03950c…4fe8:6
buckets details
fmin
func(a float64, b float64) float64fmin returns the smaller of two float64 values.
- OID
- 03950c…4fe8:8
fmin details
refill
func(tokens float64, last int64, now int64, r float64, cap float64) float64refill returns the token count at height \`now\` given \`tokens\` observed at height \`last\`, replenishing at \`r\` tokens/block up to capacity \`cap\`. It never decreases below the stored value and never exceeds \`cap\`.
- OID
- 03950c…4fe8:10
refill details
tokensToInt
func(t float64) inttokensToInt floors a token count to a whole, non-negative token.
- OID
- 03950c…4fe8:11
tokensToInt details
load
func(key string, now int64) *ratelimit.bucketload returns the live bucket for addr, refilled to \`now\`, creating a full bucket the first time an address is seen.
- OID
- 03950c…4fe8:12
load details
Allow
func() boolAllow consumes one token for the calling realm/user and reports whether the request is permitted. Returns false (and consumes nothing) when the bucket is empty.
- OID
- 03950c…4fe8:13
Allow details
SetConfig
func(newRate float64, newBurst float64)SetConfig updates the shared rate (tokens per block) and burst (capacity). Values are clamped to be non-negative; burst is forced to at least 1.
- OID
- 03950c…4fe8:14
SetConfig details
Tokens
func(addr .uverse.address) intTokens is a read-only view of how many whole tokens \`addr\` has available at the current block height, without mutating any state.
- OID
- 03950c…4fe8:15
Tokens details
ftoa
func(f float64) string- OID
- 03950c…4fe8:16
ftoa details
Render
func(path string) stringRender shows the limiter config and a table of known callers with their current tokens and last-seen height. Path "/addr/\<address>" focuses one caller.
- OID
- 03950c…4fe8:17