Documentation ¶
Index ¶
- Constants
- Variables
- func Broadcast(node *noise.Node, message noise.Message) (errs []error)
- func BroadcastAsync(node *noise.Node, message noise.Message)
- func BucketSize() int
- func FindClosestPeers(t *table, target []byte, K int) (peers []protocol.ID)
- func New() *block
- func Table(node *noise.Node) *table
- func UpdateTable(node *noise.Node, target protocol.ID) (err error)
- func VerifyPuzzle(publicKey, id, nonce []byte, c1, c2 int) bool
- func WaitUntilAuthenticated(peer *noise.Peer)
- type Evict
- type ID
- type Keypair
- type LookupRequest
- type LookupResponse
- type Ping
Constants ¶
const ( // DefaultC1 is the prefix-matching length for the static crypto puzzle. DefaultC1 = 8 // DefaultC2 is the prefix-matching length for the dynamic crypto puzzle. DefaultC2 = 8 // MaxPuzzleIterations is an internal limit for performing cryptographic puzzles for S/Kademlia. // This is set to stop the puzzle after about 1sec of failed continuous checks. MaxPuzzleIterations = 1000000 )
const ( DefaultPrefixDiffLen = 128 DefaultPrefixDiffMin = 32 )
Variables ¶
var (
ErrBucketFull = errors.New("kademlia: cannot add ID, bucket is full")
)
Functions ¶
func Broadcast ¶
Broadcast sends a message denoted by its opcode and content to all S/Kademlia IDs closest in terms of XOR distance to that of a specified node instances ID.
Every message sent will be blocking. To have every message sent not block the current goroutine, refer to `BroadcastAsync(node *noise.Node, message noise.Message)`
It returns a list of errors which have occurred in sending any messages to peers closest to a given node instance.
func BroadcastAsync ¶
BroadcastAsync sends a message denoted by its opcode and content to all S/Kademlia IDs closest in terms of XOR distance to that of a specified node instances ID.
Every message sent will be non-blocking. To have every message sent block the current goroutine, refer to `Broadcast(node *noise.Node, message noise.Message) (errs []error)`
func BucketSize ¶
func BucketSize() int
func FindClosestPeers ¶
FindClosestPeers returns a list of K peers with in order of ascending XOR distance.
func VerifyPuzzle ¶
VerifyPuzzle checks whether or not an id is a valid S/Kademlia id that suffices both S/Kademlia's static and dynamic puzzle given constants C1 and C2.
func WaitUntilAuthenticated ¶
Types ¶
type Evict ¶
type Evict struct{ noise.EmptyMessage }
type ID ¶
type ID struct {
// contains filtered or unexported fields
}
func FindNode ¶
FindNode implements the `FIND_NODE` RPC method denoted in Section 4.4 of the S/Kademlia paper: `Lookup over disjoint paths`.
Given a node instance N, and a S/Kademlia ID as a target T, α disjoint lookups take place in parallel over all closest peers to N to target T, with at most D lookups happening at once.
Each disjoint lookup queries at most α peers.
It returns at most BUCKET_SIZE S/Kademlia peer IDs closest to that of a specified target T.
type Keypair ¶
func LoadKeys ¶
LoadKeys loads a S/Kademlia given an Ed25519 private key, and validates it through both a static and dynamic crypto puzzle parameterized by constants C1 and C2 respectively.
func NewKeys ¶
NewKeys randomly generates a set of cryptographic keys by solving both a static and dynamic crypto puzzle parameterized by constants C1 and C2 respectively.
func RandomKeys ¶
func RandomKeys() *Keypair
RandomKeys randomly generates a set of cryptographic keys by solving both a static and dynamic crypto puzzle parameterized by constants C1 = 8, and C2 = 8 respectively.
func (*Keypair) PrivateKey ¶
type LookupRequest ¶
type LookupRequest struct{ ID }
type LookupResponse ¶
type LookupResponse struct {
// contains filtered or unexported fields
}
func (LookupResponse) Write ¶
func (l LookupResponse) Write() []byte