Package com.biglybt.core.dht.router
Interface DHTRouter
-
- All Known Implementing Classes:
DHTRouterImpl
,DHTRouterWrapper
public interface DHTRouter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
addObserver(DHTRouterObserver rto)
Adds a routing table observer if it is not already observing.void
contactAlive(byte[] node_id, DHTRouterContactAttachment attachment)
Adds a contact to the router and marks it as "known to be alive"DHTRouterContact
contactDead(byte[] node_id, boolean force)
Informs the router that an attempt to interact with the contact failedvoid
contactKnown(byte[] node_id, DHTRouterContactAttachment attachment, boolean force)
Adds a contact to the router.boolean
containsObserver(DHTRouterObserver rto)
Returns whether the given observer is already observing.void
destroy()
java.util.List<DHTRouterContact>
findBestContacts(int max)
returns a list of best contacts in terms of uptime, best firstjava.util.List<DHTRouterContact>
findClosestContacts(byte[] node_id, int num_to_return, boolean live_only)
Returns num_to_return or a few more closest contacts, unorderedDHTRouterContact
findContact(byte[] node_id)
java.util.List<DHTRouterContact>
getAllContacts()
Returns a list of DHTRouterContact objectsbyte[]
getID()
int
getK()
DHTRouterContact
getLocalContact()
DHTRouterStats
getStats()
boolean
isID(byte[] node_id)
void
print()
void
recordLookup(byte[] node_id)
void
refreshIdleLeaves(long idle_max)
byte[]
refreshRandom()
boolean
removeObserver(DHTRouterObserver rto)
Removes the observer if it is already observing.boolean
requestPing(byte[] node_id)
void
seed()
Tells the router to perform its "start of day" functions required to integrate it into the DHT (search for itself, refresh buckets)void
setAdapter(DHTRouterAdapter _adapter)
void
setSleeping(boolean sleeping)
void
setSuspended(boolean susp)
-
-
-
Method Detail
-
getK
int getK()
-
getID
byte[] getID()
-
isID
boolean isID(byte[] node_id)
-
getLocalContact
DHTRouterContact getLocalContact()
-
setAdapter
void setAdapter(DHTRouterAdapter _adapter)
-
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
void contactKnown(byte[] node_id, DHTRouterContactAttachment attachment, boolean force)
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
void contactAlive(byte[] node_id, DHTRouterContactAttachment attachment)
Adds a contact to the router and marks it as "known to be alive"- Parameters:
node_id
-attachment
-
-
contactDead
DHTRouterContact contactDead(byte[] node_id, boolean force)
Informs the router that an attempt to interact with the contact failed- Parameters:
node_id
-attachment
-- Returns:
-
findContact
DHTRouterContact findContact(byte[] node_id)
-
findClosestContacts
java.util.List<DHTRouterContact> findClosestContacts(byte[] node_id, int num_to_return, boolean live_only)
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
java.util.List<DHTRouterContact> findBestContacts(int max)
returns a list of best contacts in terms of uptime, best first- Parameters:
max
-- Returns:
-
getAllContacts
java.util.List<DHTRouterContact> getAllContacts()
Returns a list of DHTRouterContact objects- Returns:
-
getStats
DHTRouterStats getStats()
-
setSleeping
void setSleeping(boolean sleeping)
-
setSuspended
void setSuspended(boolean susp)
-
destroy
void destroy()
-
print
void print()
-
addObserver
boolean addObserver(DHTRouterObserver rto)
Adds a routing table observer if it is not already observing.- Parameters:
rto
- the observer to add- Returns:
true
if now observing,false
otherwise
-
containsObserver
boolean containsObserver(DHTRouterObserver rto)
Returns whether the given observer is already observing.- Parameters:
rto
- the observer to query as observing- Returns:
true
if observing,false
otherwise
-
removeObserver
boolean removeObserver(DHTRouterObserver rto)
Removes the observer if it is already observing.- Parameters:
rto
- the observer to remove- Returns:
true
if no longer observing,false
otherwise
-
-