Playground
doc.gno
// Package whitelist holds the pool membership state used by the GnoSwap // order whitelist realm. // // Files: // - state.gno: State, a poolPath -> true B+tree with membership updates and queries // // Each NewState creates an independent whitelist. Pools exposes membership // and iteration through a read-only tree, without mutable tree access. // This package does not validate pool existence or authorize callers; those // checks and the separately managed DCA and Limit states live in // gno.land/r/gnoswap/order/whitelist. package whitelist
gnomod.toml
module = "gno.land/p/gnoswap/order/whitelist/v0" gno = "0.9" [addpkg] creator = "g1q5tjjv3kkslzwf2na9y9wk7e5a8ugph8xfsk04" height = 1108537 max_deposit = "100000000ugnot"
state.gno
package whitelist
import (
rotree "gno.land/p/nt/bptree/rotree/v0"
bptree "gno.land/p/nt/bptree/v0"
)
// State holds one independently managed pool whitelist.
type State struct {
pools *bptree.BPTree
}
func NewState() State {
return State{pools: bptree.NewBPTreeN(16)}
}
func (s *State) AddPool(poolPath string) {
s.pools.Set(poolPath, true)
}
func (s *State) RemovePool(poolPath string) {
s.pools.Remove(poolPath)
}
func (s *State) HasPool(poolPath string) bool {
return s.pools.Has(poolPath)
}
// Pools exposes membership and iteration without mutable tree access.
func (s *State) Pools() *rotree.ReadOnlyTree {
return rotree.Wrap(s.pools, nil)
}