kademlia

package
v0.0.0-...-2eef10d Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

contract.go

kademlia.go

nodeid.go

routingtable.go

Documentation

Index

Constants

View Source
const BucketSize = 20
View Source
const IdLength = 20

Variables

This section is empty.

Functions

func Client

func Client()

func Equal

func Equal(x interface{}, table *RoutingTable) bool

func RunServer

func RunServer()

Types

type Contract

type Contract struct {
	Id      NodeID
	Address string
}

func (*Contract) String

func (contract *Contract) String() string

type ContractRecord

type ContractRecord struct {
	// contains filtered or unexported fields
}

func (*ContractRecord) Less

func (rec *ContractRecord) Less(other interface{}) bool

type FindNodeRequest

type FindNodeRequest struct {
	RPCHeader
	// contains filtered or unexported fields
}

type FindNodeResponse

type FindNodeResponse struct {
	RPCHeader
	// contains filtered or unexported fields
}

type Kademlia

type Kademlia struct {
	NetworkId string
	// contains filtered or unexported fields
}

func NewKademlia

func NewKademlia(contract *Contract, networkId string) (ret *Kademlia)

func (*Kademlia) Call

func (k *Kademlia) Call(contract *Contract, method string, args, reply interface{}) error

rpc client

func (*Kademlia) HandleRPC

func (k *Kademlia) HandleRPC(request, response *RPCHeader) error

func (*Kademlia) Serve

func (k *Kademlia) Serve() error

rpc server

type KademliaCore

type KademliaCore struct {
	// contains filtered or unexported fields
}

func (*KademliaCore) FindNode

func (kc *KademliaCore) FindNode(args *FindNodeRequest, response *FindNodeResponse) error

func (*KademliaCore) Ping

func (kc *KademliaCore) Ping(args *PingRequest, response *PingResponce) error

type NodeID

type NodeID [IdLength]byte

func NewNodeID

func NewNodeID(data string) (ret NodeID)

func NewRandomNodeID

func NewRandomNodeID() (ret NodeID)

func (NodeID) Equals

func (node NodeID) Equals(other NodeID) bool

func (NodeID) Less

func (node NodeID) Less(other interface{}) bool

func (NodeID) PrefixLen

func (node NodeID) PrefixLen() (ret int)

func (NodeID) String

func (node NodeID) String() string

func (NodeID) Xor

func (node NodeID) Xor(other NodeID) (ret NodeID)

type PingRequest

type PingRequest struct {
	RPCHeader
}

type PingResponce

type PingResponce struct {
	RPCHeader
}

type RPCHeader

type RPCHeader struct {
	Sender *Contract
	// contains filtered or unexported fields
}

type RoutingTable

type RoutingTable struct {
	// contains filtered or unexported fields
}

func NewRoutingTable

func NewRoutingTable(node *Contract) (ret *RoutingTable)

func (*RoutingTable) FindClosest

func (table *RoutingTable) FindClosest(target NodeID, count int) (ret []interface{})

func (*RoutingTable) Update

func (table *RoutingTable) Update(contract *Contract)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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