Documentation ¶
Index ¶
- Variables
- func TrieKeyEqual(x, y TrieKey) bool
- type BalancedIdentityGenerator
- func (bg *BalancedIdentityGenerator) AddBalanced() (crypto.PrivKey, error)
- func (bg *BalancedIdentityGenerator) AddUnbalanced() (crypto.PrivKey, error)
- func (bg *BalancedIdentityGenerator) Count() int
- func (bg *BalancedIdentityGenerator) Depth() int
- func (bg *BalancedIdentityGenerator) Remove(privKey crypto.PrivKey) error
- type TrieKey
- type XorTrie
Constants ¶
This section is empty.
Variables ¶
var HydraIdentityGenerator = NewBalancedIdentityGenerator()
HydraIdentityGenerator is a shared balanced ID generator.
Functions ¶
func TrieKeyEqual ¶
Types ¶
type BalancedIdentityGenerator ¶
BalancedIdentityGenerator is a facility for generating IPFS identities (i.e. IPFS private keys), whose corresponding DHT keys are highly balanced, compared to just generating random keys. Balancing is accomplished using "the power of two choices" paradigm: https://www.eecs.harvard.edu/~michaelm/postscripts/mythesis.pdf
New identities are generated by calling AddBalanced. BalancedIdentityGenerator remembers generated identities, in order to ensure balance for future identities. Generated identities can be removed using Remove.
BalancedIdentityGenerator maintains the invariant that all identities, presently in its memory, form an almost-perfectly balanced set.
func NewBalancedIdentityGenerator ¶
func NewBalancedIdentityGenerator() *BalancedIdentityGenerator
NewBalancedIdentityGenerator creates a new balanced identity generator.
func (*BalancedIdentityGenerator) AddBalanced ¶
func (bg *BalancedIdentityGenerator) AddBalanced() (crypto.PrivKey, error)
AddBalanced generates a random identity, which is balanced with respect to the existing identities in the generator. The generated identity is stored in the generator's memory.
func (*BalancedIdentityGenerator) AddUnbalanced ¶
func (bg *BalancedIdentityGenerator) AddUnbalanced() (crypto.PrivKey, error)
AddUnbalanced is used for testing purposes. It generates a purely random identity, which is not balanced with respect to the existing identities in the generator. The generated identity is stored in the generator's memory.
func (*BalancedIdentityGenerator) Count ¶
func (bg *BalancedIdentityGenerator) Count() int
func (*BalancedIdentityGenerator) Depth ¶
func (bg *BalancedIdentityGenerator) Depth() int
type TrieKey ¶
type TrieKey []byte
TrieKey is a vector of bits backed by a Go byte slice in big endian byte order and big-endian bit order.