From 841813702444e1f7f975e83441b0dd04015413a1 Mon Sep 17 00:00:00 2001 From: Cameron Dale Date: Sun, 16 Dec 2007 18:41:27 -0800 Subject: [PATCH] Added the new DHT interface and a bare implmentation of it. --- apt_dht/interfaces.py | 39 +++++++++++++++++++++++++++++++++++++++ apt_dht_Khashmir/DHT.py | 11 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 apt_dht/interfaces.py create mode 100644 apt_dht_Khashmir/DHT.py diff --git a/apt_dht/interfaces.py b/apt_dht/interfaces.py new file mode 100644 index 0000000..c6bea9d --- /dev/null +++ b/apt_dht/interfaces.py @@ -0,0 +1,39 @@ + +""" +Some interfaces that are used by the apt-dht classes. + +""" + +from zope.interface import Interface + +class IDHT(Interface): + """An abstract interface for using a DHT implementation.""" + + def loadConfig(self, config): + """Load the DHTs configuration from a dictionary. + + @type config: C{dictionary} + @param config: the dictionary of config values + """ + + def join(self, bootstrap_nodes): + """Bootstrap the new DHT node into the DHT. + + @type bootstrap_nodes: C{list} of (C{string}, C{int}) + @param bootstrap_nodes: a list of the nodes to contact to join the DHT + @rtype: C{Deffered} + @return: a deferred that will fire when the node has joined + """ + + def leave(self): + """Depart gracefully from the DHT. + + @rtype: C{Deffered} + @return: a deferred that will fire when the node has joined + """ + + def getValue(self, key): + """Get a value from the DHT for the specified key.""" + + def storeValue(self, key, value): + """Store a value in the DHT for the specified key.""" diff --git a/apt_dht_Khashmir/DHT.py b/apt_dht_Khashmir/DHT.py new file mode 100644 index 0000000..78d913b --- /dev/null +++ b/apt_dht_Khashmir/DHT.py @@ -0,0 +1,11 @@ + +from zope.interface import implements + +from apt_dht.interfaces import IDHT + +class DHT: + + implements(IDHT) + + def __init__(self): + pass \ No newline at end of file -- 2.39.2