Interface DHTRouter
- All Known Implementing Classes:
DHTRouterImpl, DHTRouterWrapper
public interface DHTRouter
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a routing table observer if it is not already observing.voidcontactAlive(byte[] node_id, DHTRouterContactAttachment attachment) Adds a contact to the router and marks it as "known to be alive"contactDead(byte[] node_id, boolean force) Informs the router that an attempt to interact with the contact failedvoidcontactKnown(byte[] node_id, DHTRouterContactAttachment attachment, boolean force) Adds a contact to the router.booleanReturns whether the given observer is already observing.voiddestroy()findBestContacts(int max) returns a list of best contacts in terms of uptime, best firstfindClosestContacts(byte[] node_id, int num_to_return, boolean live_only) Returns num_to_return or a few more closest contacts, unorderedfindContact(byte[] node_id) Returns a list of DHTRouterContact objectsbyte[]getID()intgetK()getStats()booleanisID(byte[] node_id) voidprint()voidrecordLookup(byte[] node_id) voidrefreshIdleLeaves(long idle_max) byte[]booleanRemoves the observer if it is already observing.booleanrequestPing(byte[] node_id) voidseed()Tells the router to perform its "start of day" functions required to integrate it into the DHT (search for itself, refresh buckets)voidsetAdapter(DHTRouterAdapter _adapter) voidsetSleeping(boolean sleeping) voidsetSuspended(boolean susp)
-
Method Details
-
getK
int getK() -
getID
byte[] getID() -
isID
boolean isID(byte[] node_id) -
getLocalContact
DHTRouterContact getLocalContact() -
setAdapter
-
seed
void seed()Tells the router to perform its "start of day" functions required to integrate it into the DHT (search for itself, refresh buckets) -
contactKnown
Adds a contact to the router. The contact is not known to be alive (e.g. we've been returned the contact by someone but we've not either got a reply from it, nor has it invoked us.- Parameters:
node_id-attachment-
-
contactAlive
Adds a contact to the router and marks it as "known to be alive"- Parameters:
node_id-attachment-
-
contactDead
Informs the router that an attempt to interact with the contact failed- Parameters:
node_id-attachment-- Returns:
-
findContact
-
findClosestContacts
Returns num_to_return or a few more closest contacts, unordered -
recordLookup
void recordLookup(byte[] node_id) -
requestPing
boolean requestPing(byte[] node_id) -
refreshIdleLeaves
void refreshIdleLeaves(long idle_max) -
refreshRandom
byte[] refreshRandom() -
findBestContacts
returns a list of best contacts in terms of uptime, best first- Parameters:
max-- Returns:
-
getAllContacts
-
getStats
DHTRouterStats getStats() -
setSleeping
void setSleeping(boolean sleeping) -
setSuspended
void setSuspended(boolean susp) -
destroy
void destroy() -
print
void print() -
addObserver
Adds a routing table observer if it is not already observing.- Parameters:
rto- the observer to add- Returns:
trueif now observing,falseotherwise
-
containsObserver
Returns whether the given observer is already observing.- Parameters:
rto- the observer to query as observing- Returns:
trueif observing,falseotherwise
-
removeObserver
Removes the observer if it is already observing.- Parameters:
rto- the observer to remove- Returns:
trueif no longer observing,falseotherwise
-