Documentation
¶
Index ¶
- Constants
- type CallHeader
- type Contact
- type ContactList
- type Contacts
- type FindNodeRequest
- type FindNodeResponse
- type FindValueRequest
- type FindValueResponse
- type KBucket
- type Kademlia
- func (k *Kademlia) Bootstrap(target, self Contact) ([]Contact, error)
- func (k *Kademlia) FindNode(contact Contact, target NodeID, done chan Contacts)
- func (k *Kademlia) FindNodeHandler(req FindNodeRequest, res *FindNodeResponse) error
- func (k *Kademlia) FindValue(contact Contact, target NodeID) ([]Contact, []byte, error)
- func (k *Kademlia) FindValueHandler(req FindValueRequest, res *FindValueResponse) error
- func (k *Kademlia) HandleCall(request CallHeader, response *CallHeader) error
- func (k *Kademlia) IterativeFindNode(target NodeID, delta int, final chan Contacts)
- func (k *Kademlia) NewFindNodeRequest(target NodeID) FindNodeRequest
- func (k *Kademlia) NewFindValueRequest(target NodeID) FindValueRequest
- func (k *Kademlia) NewPingRequest() PingRequest
- func (k *Kademlia) NewStoreValueRequest(target NodeID, value []byte) StoreValueRequest
- func (k *Kademlia) Ping(target Contact) error
- func (k *Kademlia) PingHandler(req PingRequest, res *PingResponse) error
- func (k *Kademlia) StoreValue(contact Contact, target NodeID, value []byte) ([]Contact, error)
- func (k *Kademlia) StoreValueHandler(req StoreValueRequest, res *StoreValueResponse) error
- type KademliaClient
- type KademliaNetwork
- type KademliaNodeHandler
- type KademliaStorage
- type MapStorage
- type NodeID
- type PingRequest
- type PingResponse
- type RPCClientConnection
- func (c *RPCClientConnection) FindNode(req FindNodeRequest, res *FindNodeResponse) (err error)
- func (c *RPCClientConnection) FindValue(req FindValueRequest, res *FindValueResponse) (err error)
- func (c *RPCClientConnection) Ping(req PingRequest, res *PingResponse) (err error)
- func (c *RPCClientConnection) StoreValue(req StoreValueRequest, res *StoreValueResponse) (err error)
- type RPCNetwork
- type RPCNode
- type RPCNodeCore
- func (n *RPCNodeCore) FindNodeRPC(req FindNodeRequest, res *FindNodeResponse) error
- func (n *RPCNodeCore) FindValueRPC(req FindValueRequest, res *FindValueResponse) error
- func (n *RPCNodeCore) PingRPC(req PingRequest, res *PingResponse) error
- func (n *RPCNodeCore) StoreValueRPC(req StoreValueRequest, res *StoreValueResponse) error
- type RoutingTable
- type StoreValueRequest
- type StoreValueResponse
Constants ¶
View Source
const ( Delta = 3 IDLength = 20 IDBytesLength = 8 * IDLength BucketSize = 20 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Contact ¶
func NewContact ¶
type ContactList ¶
type FindNodeRequest ¶
type FindNodeRequest struct {
CallHeader
Target NodeID
}
type FindNodeResponse ¶
type FindNodeResponse struct {
CallHeader
Contacts Contacts
}
type FindValueRequest ¶
type FindValueRequest struct {
CallHeader
Target NodeID
}
type FindValueResponse ¶
type FindValueResponse struct {
CallHeader
Contacts Contacts
Value []byte
}
type KBucket ¶
func NewKBucket ¶
func NewKBucket() *KBucket
type Kademlia ¶
type Kademlia struct {
Storage KademliaStorage
Network KademliaNetwork
NetworkID string
// contains filtered or unexported fields
}
func NewKademlia ¶
func (*Kademlia) FindNodeHandler ¶
func (k *Kademlia) FindNodeHandler(req FindNodeRequest, res *FindNodeResponse) error
func (*Kademlia) FindValueHandler ¶
func (k *Kademlia) FindValueHandler(req FindValueRequest, res *FindValueResponse) error
func (*Kademlia) HandleCall ¶
func (k *Kademlia) HandleCall(request CallHeader, response *CallHeader) error
Every call updates routing tables in Kademlia
func (*Kademlia) IterativeFindNode ¶
func (*Kademlia) NewFindNodeRequest ¶
func (k *Kademlia) NewFindNodeRequest(target NodeID) FindNodeRequest
func (*Kademlia) NewFindValueRequest ¶
func (k *Kademlia) NewFindValueRequest(target NodeID) FindValueRequest
func (*Kademlia) NewPingRequest ¶
func (k *Kademlia) NewPingRequest() PingRequest
func (*Kademlia) NewStoreValueRequest ¶
func (k *Kademlia) NewStoreValueRequest(target NodeID, value []byte) StoreValueRequest
func (*Kademlia) PingHandler ¶
func (k *Kademlia) PingHandler(req PingRequest, res *PingResponse) error
func (*Kademlia) StoreValue ¶
func (*Kademlia) StoreValueHandler ¶
func (k *Kademlia) StoreValueHandler(req StoreValueRequest, res *StoreValueResponse) error
type KademliaClient ¶
type KademliaClient interface {
FindNode(req FindNodeRequest, res *FindNodeResponse) error
FindValue(req FindValueRequest, res *FindValueResponse) error
Ping(req PingRequest, res *PingResponse) error
StoreValue(req StoreValueRequest, res *StoreValueResponse) error
}
type KademliaNetwork ¶
type KademliaNetwork interface {
Connect(contact Contact) (client KademliaClient, err error)
}
type KademliaNodeHandler ¶
type KademliaNodeHandler interface {
FindNodeHandler(req FindNodeRequest, res *FindNodeResponse) error
FindValueHandler(req FindValueRequest, res *FindValueResponse) error
PingHandler(req PingRequest, res *PingResponse) error
StoreValueHandler(req StoreValueRequest, res *StoreValueResponse) error
}
type KademliaStorage ¶
type MapStorage ¶
func NewMapStorage ¶
func NewMapStorage() *MapStorage
type NodeID ¶
func NewRandomNodeID ¶
func NewRandomNodeID() (ret NodeID)
type PingRequest ¶
type PingRequest struct {
CallHeader
}
type PingResponse ¶
type PingResponse struct {
CallHeader
}
type RPCClientConnection ¶
type RPCClientConnection struct {
// contains filtered or unexported fields
}
func (*RPCClientConnection) FindNode ¶
func (c *RPCClientConnection) FindNode(req FindNodeRequest, res *FindNodeResponse) (err error)
func (*RPCClientConnection) FindValue ¶
func (c *RPCClientConnection) FindValue(req FindValueRequest, res *FindValueResponse) (err error)
func (*RPCClientConnection) Ping ¶
func (c *RPCClientConnection) Ping(req PingRequest, res *PingResponse) (err error)
func (*RPCClientConnection) StoreValue ¶
func (c *RPCClientConnection) StoreValue(req StoreValueRequest, res *StoreValueResponse) (err error)
type RPCNetwork ¶
type RPCNetwork struct{}
func NewRPCNetwork ¶
func NewRPCNetwork() *RPCNetwork
func (*RPCNetwork) Connect ¶
func (n *RPCNetwork) Connect(contact Contact) (c KademliaClient, err error)
type RPCNode ¶
type RPCNode struct {
// contains filtered or unexported fields
}
func NewRPCNode ¶
func NewRPCNode(handler KademliaNodeHandler) *RPCNode
type RPCNodeCore ¶
type RPCNodeCore struct {
// contains filtered or unexported fields
}
func (*RPCNodeCore) FindNodeRPC ¶
func (n *RPCNodeCore) FindNodeRPC(req FindNodeRequest, res *FindNodeResponse) error
func (*RPCNodeCore) FindValueRPC ¶
func (n *RPCNodeCore) FindValueRPC(req FindValueRequest, res *FindValueResponse) error
func (*RPCNodeCore) PingRPC ¶
func (n *RPCNodeCore) PingRPC(req PingRequest, res *PingResponse) error
func (*RPCNodeCore) StoreValueRPC ¶
func (n *RPCNodeCore) StoreValueRPC(req StoreValueRequest, res *StoreValueResponse) error
type RoutingTable ¶
type RoutingTable struct {
// contains filtered or unexported fields
}
func NewRoutingTable ¶
func NewRoutingTable(self Contact) *RoutingTable
func (*RoutingTable) FindClosest ¶
func (rt *RoutingTable) FindClosest(target NodeID, delta int) Contacts
func (RoutingTable) Self ¶
func (rt RoutingTable) Self() Contact
func (*RoutingTable) Update ¶
func (rt *RoutingTable) Update(contact Contact)
type StoreValueRequest ¶
type StoreValueRequest struct {
CallHeader
Target NodeID
Value []byte
}
type StoreValueResponse ¶
type StoreValueResponse struct {
CallHeader
Contacts Contacts
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.