kademlia package¶
The best place to start is the examples folder before diving into the API.
kademlia.crawling module¶
-
class
kademlia.crawling.
NodeSpiderCrawl
(protocol, node, peers, ksize, alpha)[source]¶ Bases:
kademlia.crawling.SpiderCrawl
Create a new C{SpiderCrawl}er.
- Parameters
-
class
kademlia.crawling.
RPCFindResponse
(response)[source]¶ Bases:
object
A wrapper for the result of a RPC find.
- Parameters
response – This will be a tuple of (<response received>, <value>) where <value> will be a list of tuples if not found or a dictionary of {‘value’: v} where v is the value desired
-
class
kademlia.crawling.
SpiderCrawl
(protocol, node, peers, ksize, alpha)[source]¶ Bases:
object
Crawl the network and look for given 160-bit keys.
Create a new C{SpiderCrawl}er.
-
class
kademlia.crawling.
ValueSpiderCrawl
(protocol, node, peers, ksize, alpha)[source]¶ Bases:
kademlia.crawling.SpiderCrawl
Create a new C{SpiderCrawl}er.
- Parameters
kademlia.network module¶
kademlia.node module¶
-
class
kademlia.node.
Node
(node_id, ip=None, port=None)[source]¶ Bases:
object
Simple object to encapsulate the concept of a Node (minimally an ID, but also possibly an IP and port if this represents a node on the network). This class should generally not be instantiated directly, as it is a low level construct mostly used by the router.
Create a Node instance.
- Parameters
node_id (int) – A value between 0 and 2^160
ip (string) – Optional IP address where this Node lives
port (int) – Optional port for this Node (set when IP is set)
-
class
kademlia.node.
NodeHeap
(node, maxsize)[source]¶ Bases:
object
A heap of nodes ordered by distance to a given node.
Constructor.
@param node: The node to measure all distnaces from. @param maxsize: The maximum size that this heap can grow to.
-
remove
(peers)[source]¶ Remove a list of peer ids from this heap. Note that while this heap retains a constant visible size (based on the iterator), it’s actual size may be quite a bit larger than what’s exposed. Therefore, removal of nodes may not change the visible size as previously added nodes suddenly become visible.
-
kademlia.protocol module¶
kademlia.routing module¶
-
class
kademlia.routing.
KBucket
(rangeLower, rangeUpper, ksize, replacementNodeFactor=5)[source]¶ Bases:
object
kademlia.storage module¶
-
class
kademlia.storage.
ForgetfulStorage
(ttl=604800)[source]¶ Bases:
kademlia.storage.IStorage
By default, max age is a week.
kademlia.utils module¶
General catchall for functions that don’t make sense as methods.
Find the shared prefix between the strings.
For instance:
sharedPrefix([‘blahblah’, ‘blahwhat’])
returns ‘blah’.