dht

package
v0.4.0-3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DHT

type DHT interface {
	surge.Surger

	// InsertAddr into the DHT. Returns true if the address is new, otherwise
	// returns false.
	InsertAddr(wire.Address) bool
	// DeleteAddr from the DHT.
	DeleteAddr(id.Signatory)
	// Addr returns the address associated with a signatory. If there is no
	// associated address, it returns false. Otherwise, it returns true.
	Addr(id.Signatory) (wire.Address, bool)
	// Addrs returns a random number of addresses.
	Addrs(n int) []wire.Address
	// NumAddrs returns the number of addresses in the store.
	NumAddrs() (int, error)

	// InsertContent into the DHT. This will override existing content, so it is
	// important to call the HasContent method to check whether or not you are
	// able to override existing content.
	InsertContent(id.Hash, []byte)
	// DeleteContent from the DHT.
	DeleteContent(id.Hash)
	// Content returns the content associated with a hash. If there is no
	// associated content, it returns false. Otherwise, it returns true.
	Content(id.Hash) ([]byte, bool)
	// HasContent returns true when there is content associated with the given
	// hash. Otherwise, it returns false. This is more efficiently for checking
	// existence than the Content method, because no bytes are copied.
	HasContent(id.Hash) bool
	// HasContent returns true when there empty/nil content associated with the
	// given hash. Otherwise, it returns false. This is more efficiently for
	// checking existence than the Content method, because no bytes are copied.
	// Note: not having content is different from having empty/nil content.
	HasEmptyContent(id.Hash) bool

	// AddSubnet to the DHT. Returns the merkle root hash of the subnet.
	AddSubnet([]id.Signatory) id.Hash
	// DeleteSubnet from the DHT by specifying its merkle root hash. Does
	// nothing if the subnet is not in the DHT.
	DeleteSubnet(id.Hash)
	// Subnet returns the signatories associated with the specified subnet
	// merkle root hash.
	Subnet(id.Hash) []id.Signatory
}

DHT defines a distributed hash table, used for storing addresses/content that have been discovered in the network. All DHT implementations must be safe for concurrent use. All DHT implementations must be able to marshal/unmarshal to/from binary.

func New

func New(identity id.Signatory) DHT

New returns an empty DHT.

type Identifiable added in v0.4.0

type Identifiable interface {
	Hash() id.Hash
}

An Identifiable type is any type that is able to return a hash that uniquely identifies it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL