Documentation ¶
Index ¶
- Constants
- Variables
- func NewBucketList(addr Address, pro *protocol) *bucketList
- func NewKBucket(initRange *IDRange) *kBucket
- func NewStorage() *storage
- func SharedPrefixLen(x, y Identifer) int
- type Address
- type BuckWithDist
- type ContWithDist
- type Contact
- type ContactHeap
- type DataPair
- type FindNodeReply
- type FindNodeRequest
- type FindValueReply
- type FindValueRequest
- type IDRange
- type Identifer
- type KademliaNode
- func (k *KademliaNode) Create()
- func (k *KademliaNode) Delete(key KeyType) bool
- func (k *KademliaNode) ForceQuit()
- func (k *KademliaNode) Get(key KeyType) (bool, ValueType)
- func (k *KademliaNode) Join(addr Address) bool
- func (k *KademliaNode) Ping(addr Address) bool
- func (k *KademliaNode) Put(key KeyType, value ValueType) bool
- func (k *KademliaNode) Quit()
- func (k *KademliaNode) Run()
- type KeyType
- type LookupRet
- type LookupRpc
- type PingReply
- type PingRequst
- type RpcHeader
- type StoreReply
- type StoreRequest
- type ValueType
Constants ¶
View Source
const ( NIL = "" M = 160 K = 20 B = 5 Alpha = 3 PingAttempt = 4 DialAttempt = 4 DialTimeOut = 300 * time.Millisecond PingTimeOut = 500 * time.Millisecond LookupTimeOut = 500 * time.Millisecond ExpireTime = 40 * time.Second RefreshInterval = 30 * time.Second RepublishInterval = 30 * time.Second )
Variables ¶
View Source
var IDGenerator *rand.Rand
Functions ¶
func NewBucketList ¶
func NewBucketList(addr Address, pro *protocol) *bucketList
func NewKBucket ¶
func NewKBucket(initRange *IDRange) *kBucket
func NewStorage ¶
func NewStorage() *storage
func SharedPrefixLen ¶
Types ¶
type BuckWithDist ¶
type BuckWithDist struct {
// contains filtered or unexported fields
}
type ContWithDist ¶
type Contact ¶
func NewContact ¶
type ContactHeap ¶
type ContactHeap []ContWithDist
func (ContactHeap) Len ¶
func (h ContactHeap) Len() int
func (ContactHeap) Less ¶
func (h ContactHeap) Less(i, j int) bool
func (*ContactHeap) Pop ¶
func (h *ContactHeap) Pop() interface{}
func (*ContactHeap) Push ¶
func (h *ContactHeap) Push(x interface{})
func (ContactHeap) Swap ¶
func (h ContactHeap) Swap(i, j int)
type FindNodeReply ¶
type FindNodeReply struct {
LookupRet
}
type FindNodeRequest ¶
type FindValueReply ¶
type FindValueReply struct {
LookupRet
}
type FindValueRequest ¶
type KademliaNode ¶
type KademliaNode struct {
// contains filtered or unexported fields
}
func NewKademliaNode ¶
func NewKademliaNode(addr Address) *KademliaNode
func (*KademliaNode) Create ¶
func (k *KademliaNode) Create()
func (*KademliaNode) Delete ¶
func (k *KademliaNode) Delete(key KeyType) bool
func (*KademliaNode) ForceQuit ¶
func (k *KademliaNode) ForceQuit()
func (*KademliaNode) Join ¶
func (k *KademliaNode) Join(addr Address) bool
func (*KademliaNode) Ping ¶
func (k *KademliaNode) Ping(addr Address) bool
func (*KademliaNode) Quit ¶
func (k *KademliaNode) Quit()
func (*KademliaNode) Run ¶
func (k *KademliaNode) Run()
type LookupRet ¶
type LookupRet struct { Found bool FoundBy Contact Cont []ContWithDist Value ValueType }
type PingRequst ¶
type PingRequst struct {
RpcHeader
}
type StoreReply ¶
type StoreReply struct{}
type StoreRequest ¶
Click to show internal directories.
Click to hide internal directories.