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

state.gno

0.65 Kb · 32 lines
 1package whitelist
 2
 3import (
 4	rotree "gno.land/p/nt/bptree/rotree/v0"
 5	bptree "gno.land/p/nt/bptree/v0"
 6)
 7
 8// State holds one independently managed pool whitelist.
 9type State struct {
10	pools *bptree.BPTree
11}
12
13func NewState() State {
14	return State{pools: bptree.NewBPTreeN(16)}
15}
16
17func (s *State) AddPool(poolPath string) {
18	s.pools.Set(poolPath, true)
19}
20
21func (s *State) RemovePool(poolPath string) {
22	s.pools.Remove(poolPath)
23}
24
25func (s *State) HasPool(poolPath string) bool {
26	return s.pools.Has(poolPath)
27}
28
29// Pools exposes membership and iteration without mutable tree access.
30func (s *State) Pools() *rotree.ReadOnlyTree {
31	return rotree.Wrap(s.pools, nil)
32}