44
55class ChordNet :
66 """Interface for interacting with Chord networks."""
7-
87 _node : _Node
98
109 def __init__ (self ,
@@ -15,7 +14,8 @@ def __init__(self,
1514 """Initializes a new Chord node.
1615
1716 Args:
18- ip: IP address for the node.
17+ ip: IP address for the node. This should be the public IP
18+ (unless the whole ring is local, it is unlikely to be 127.0.0.1)
1919 port: Port number to listen on.
2020 interval: daemon interval (how often to 'sync' with the network)
2121 """
@@ -25,14 +25,17 @@ def __init__(self,
2525 def create (self ) -> None :
2626 """Create a new ChordNet network (a new "ring").
2727
28- This creates a new network with one node (this one).
28+ This creates a new network with one node (this one), using the
29+ ip and port passed to the class constructor.
2930 """
3031 self ._node .create ()
3132
3233 def join (self , known_ip : str , known_port : int ) -> None :
3334 """Joins an existing ChordNet network (an existing ring).
3435
35- An existing chordnet can be joined through any node already on the ring.
36+ An existing chordnet can be joined through any node already on running
37+ on the ring. Note that this means a node cannot join itself to create
38+ a ring, and trivially, joining itself once running is meaningless.
3639
3740 Args:
3841 known_ip: IP address of an existing node in the Chord ring.
@@ -43,7 +46,9 @@ def join(self, known_ip: str, known_port: int) -> None:
4346 def leave (self ) -> None :
4447 """Leave the current network.
4548
46- Allows for a graceful shutdown of this node. Should be called before
47- program exit, but the network can recover if this does not happen.
49+ Allows for a graceful shutdown of this node. This is optional and
50+ can help the ring recover faster. It should be called before
51+ program exit (or before a node shuts down in the network), but the
52+ network can still recover if this does not happen.
4853 """
4954 pass
0 commit comments