Documentation
¶
Overview ¶
Package chord
This package is a collection of structures and functions associated with the Chord distributed lookup protocol.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InRange ¶
InRange is a helper function that returns true if the value x is between the values (min, max)
func Lookup ¶
Lookup returns the address of the successor of key in the Chord DHT. The lookup process is iterative. Beginning with the address of a Chord node, start, this function will request the finger tables of the closest preceeding Chord node to key until the successor is found.
If the start address is unreachable, the error is of type PeerError.
Types ¶
type ChordApp ¶
type ChordApp interface {
//Notify will alert the application of changes in the ChordNode's predecessor
Notify(id [sha256.Size]byte, me [sha256.Size]byte, addr string)
//Message will forward a message that was received through the DHT to the application
Message(data []byte) []byte
}
ChordApp is an interface for applications to run on top of a Chord DHT.
type ChordNode ¶
type ChordNode struct {
// contains filtered or unexported fields
}
ChordNode type denoting a Chord server.
func Join ¶
Join will add a new ChordNode to an existing DHT. It looks up the successor of the new node starting at an existing Chord node specified by addr. Join returns the new ChordNode when completed.
If the start address is unreachable, the error is of type PeerError.
func (*ChordNode) Finalize ¶
func (node *ChordNode) Finalize()
Finalize stops all communication and removes the ChordNode from the DHT.
func (*ChordNode) Register ¶
Register allows chord applications to register themselves and receive notifications and messages through the Chord DHT.
A Chord node registers an application app and forwards all messages with the identifier id by calling the interface method Message. Applications will also be notified of any changes in the underlying node's predecessor.
func (*ChordNode) ShowFingers ¶
ShowFingers returns a string representation of the ChordNode's finger table.