Documentation
¶
Overview ¶
Package keystore holds the keys a node provides, enumerable by prefix so a region publish can find every key that falls inside a surveyed region. It provides the Keystore contract and an in-memory Trie implementation of it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Keystore ¶
type Keystore[K kad.Key[K]] interface { // KeysUnder yields every provided key whose leading bits equal prefix. The empty prefix yields // every key. KeysUnder(prefix bitstr.Key) iter.Seq[K] }
Keystore enumerates the keys a node provides by prefix, so a region publish can find every key inside a surveyed region. An implementation must be safe for concurrent use: KeysUnder is called on the event loop while the provide path records keys. The in-memory Trie is the default; a driver may instead read from its own persistent datastore.
type Trie ¶
Trie is an in-memory Keystore backed by a binary trie. It is safe for concurrent use: a read takes a lock-free snapshot of the trie while a write rebuilds the changed path and swaps the root in atomically.
func (*Trie[K]) Add ¶
func (t *Trie[K]) Add(k K)
Add records a key this node provides. Adding a key already present has no effect.