public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacade
| Modifier and Type | Field and Description |
|---|---|
(package private) static ConcurrentHashMap<Hash,Long> | _recentlyQueriedFloodfillsTracks recently-queried floodfill peers across all concurrent searches
to avoid hammering the same floodfill. |
static char | CAPABILITY_BW_UNLIMITEDUnlimited bandwidth capability flag. |
static char | CAPABILITY_BW12Bandwidth 12 Kbps capability flag. |
static char | CAPABILITY_BW128Bandwidth 128 Kbps capability flag. |
static char | CAPABILITY_BW256Bandwidth 256 Kbps capability flag. |
static char | CAPABILITY_BW32Bandwidth 32 Kbps capability flag. |
static char | CAPABILITY_BW512Bandwidth 512 Kbps capability flag. |
static char | CAPABILITY_BW64Bandwidth 64 Kbps capability flag. |
static char | CAPABILITY_CONGESTION_MODERATEModerate congestion capability flag. |
static char | CAPABILITY_CONGESTION_SEVERESevere congestion capability flag. |
static char | CAPABILITY_FLOODFILLFloodfill capability flag. |
static char | CAPABILITY_NO_TUNNELSNo tunnels capability flag. |
static char | CAPABILITY_UNREACHABLEUnreachable capability flag. |
(package private) static long | MAX_RI_AGE_BEFORE_REFRESH_MSMax age (ms) for a RouterInfo stored in our NetDB before we consider
refreshing it. |
static int | MAX_TO_FLOODThis is the flood redundancy. |
protected static int | MIN_ACTIVE_PEERSMinimum number of active peers before dropping router info lookups. |
(package private) static long | NEXT_RKEY_RI_ADVANCE_TIMEAdvance time before midnight to flood to next routing key for RouterInfo. |
static String | PROP_FLOODFILL_AT_RESTARTConfig property recording floodfill status at previous restart. |
static String | PROP_FLOODFILL_PARTICIPANTConfig property for floodfill participation. |
(package private) static long | PUBLISH_TIMEOUTThis maybe could be shorter than RepublishLeaseSetJob.REPUBLISH_LEASESET_TIMEOUT,
because we are sending direct, but unresponsive floodfills may take a while due to timeouts. |
(package private) static long | RECENTLY_QUERIED_COOLDOWNR e c e n t l y q u e r i e d c o o l d o w n |
_context, _log, _networkID, _peerSelector, CURRENT_VERSION, DEFAULT_DB_DIR, DONT_FAIL_PERIOD, MAX_EXPLORE_QUEUE, MIN_REMAINING_ROUTERS, MIN_RESEED, MIN_ROUTER_VERSION, MIN_VERSION, PROP_BLOCK_MY_COUNTRY, PROP_BUCKET_SIZE, PROP_DB_DIR, PROP_EXPLORE_QUEUE, PROP_IP_COUNTRY, PROP_KAD_B, PROP_MIN_ROUTER_VERSION, PROP_ROUTER_INFO_EXPIRATION_ADJUSTED, PROP_VALIDATE_ROUTERS_AFTER| Constructor and Description |
|---|
FloodfillNetworkDatabaseFacade(RouterContext context)Main DB |
FloodfillNetworkDatabaseFacade(RouterContext context,
Hash dbid)Sub DBs |
| Modifier and Type | Method and Description |
|---|---|
(package private) void | complete(Hash key)Must be called by the search job queued by search() on success or failure |
void | contactHeardFrom(Hash peer)Notify that we heard from or about a peer (e.g. |
protected void | createHandlers()Register message handlers for DatabaseLookup and DatabaseStore. |
(package private) static void | decrementActiveFloodfillQuery(Hash floodfill)Decrement the active outbound query count for a floodfill peer. |
void | flood(DatabaseEntry ds)Send to a subset of all floodfill peers. |
boolean | floodConditional(DatabaseEntry ds)If we are floodfill AND the key is not throttled,
flood it, otherwise don't. |
boolean | floodfillEnabled()For convenience, so users don't have to cast to FNDF, and unit tests using
Dummy NDF will work. |
List<Hash> | getFloodfillPeers()List of the hashes of currently known floodfill peers. |
List<RouterInfo> | getKnownRouterData()Return all RouterInfo entries from the local data store. |
String | getTunnelName(Destination d)Look up the tunnel pool nickname for a destination. |
(package private) static int | incrementActiveFloodfillQuery(Hash floodfill)Increment the active outbound query count for a floodfill peer. |
static boolean | isFloodfill(RouterInfo peer)Checks if a RouterInfo has floodfill capability. |
(package private) static boolean | isFloodfillOverloaded(Hash floodfill)Check if a floodfill peer already has too many active outbound queries
from this router. |
(package private) static boolean | isRecentlyQueried(Hash peer)Check if a floodfill peer was queried recently (within cooldown period). |
(package private) boolean | isVerifyInProgress(Hash h)Checks if verification is in progress for the specified hash. |
protected void | lookupBeforeDropping(Hash peer,
RouterInfo info)Search for a newer router info, drop it from the db if the search fails,
unless just started up or have bigger problems. |
(package private) static void | markQueried(Hash peer)Mark a floodfill peer as recently queried. |
(package private) void | probeStalePeer(Hash peer,
RouterInfo ri)Fire a DirectLookupJob for a stale peer, deduplicated via _activeFloodQueries. |
void | processElapsedTimeouts()Process all elapsed search timeouts. |
void | publish(RouterInfo localRouterInfo)Send our RI to the closest floodfill. |
void | registerSearchTimeout(Hash peer,
IterativeSearchJob search,
long timeoutMs)Register a search timeout to be processed in batches. |
(package private) SearchJob | search(Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
boolean isLease)Lookup using exploratory tunnels. |
(package private) SearchJob | search(Hash key,
Job onFindJob,
Job onFailedLookupJob,
long timeoutMs,
boolean isLease,
Hash fromLocalDest)Lookup using the client's tunnels. |
(package private) void | sendStore(Hash key,
DatabaseEntry ds,
Job onSuccess,
Job onFailure,
long sendTimeout,
Set<Hash> toIgnore)Send out a store. |
void | setFloodfillEnabled(boolean yes)Public, called from console. |
(package private) void | setFloodfillEnabledFromMonitor(boolean yes)Package private, called from FloodfillMonitorJob. |
(package private) boolean | shouldBanLookup(Hash from,
TunnelId id)Check if lookup from a peer should be banned. |
(package private) boolean | shouldThrottleFlood(Hash key)Increments and tests. |
(package private) boolean | shouldThrottleLookup(Hash from,
TunnelId id)Increments and tests. |
void | shutdown()If we are floodfill, turn it off and tell everybody. |
void | startTimeoutProcessor()Start the batched timeout processor. |
void | startup()Start monitor jobs, throttle, and optional router refresh. |
(package private) void | verifyFinished(Hash h)Marks verification as finished for the specified hash. |
(package private) void | verifyStarted(Hash h)Marks verification as started for the specified hash. |
accessLeaseSet, blindCache, cleanupLURouters, createPeerSelector, dropAfterLookupFailed, fail, failPermanently, findNearestRouters, getAllRouters, getBlindData, getBlindData, getClientLeases, getDataStore, getDbDir, getExploreKeys, getFloodfillLeases, getKBuckets, getKBucketSetSize, getKnownLeaseSets, getKnownRouters, getLastExploreNewDate, getLastRouterInfoPublishTime, getLeases, getPeerSelector, getPeerTimeout, getPublishedLeases, getRouterIPPort, getRouters, getStoredRouterInfoCount, getUnpublishedLeases, hasActiveRepublishJob, isClientDb, isInitialized, isNegativeCached, isNegativeCachedForever, isNewer, lookupDestination, lookupDestinationLocally, lookupFailed, lookupLeaseSet, lookupLeaseSet, lookupLeaseSetLocally, lookupLeaseSetRemotely, lookupLeaseSetRemotely, lookupLocally, lookupLocallyWithoutValidation, lookupRouterInfo, lookupRouterInfoLocally, lookupRouterInfoRemote, markHostCheckerLeaseSet, negativeCacheNow, publish, purgeMatchingRouters, queueForExploration, registerPublishingJob, removeBlindData, removeFromCache, removeFromExploreKeys, removeLeaseSetFromTracking, removePublishingJob, removeRouterInfo, renderStatusHTML, rescan, reseedChecker, routerInfoPublishSuccessful, routingKeyChanged, searchComplete, setBlindData, setLastExploreNewDate, stopPublishing, store, store, store, store, toString, unpublish, validate, validatestorestatic final ConcurrentHashMap<Hash,Long> _recentlyQueriedFloodfills
public static final char CAPABILITY_BW_UNLIMITED
public static final char CAPABILITY_BW12
public static final char CAPABILITY_BW128
public static final char CAPABILITY_BW256
public static final char CAPABILITY_BW32
public static final char CAPABILITY_BW512
public static final char CAPABILITY_BW64
public static final char CAPABILITY_CONGESTION_MODERATE
public static final char CAPABILITY_CONGESTION_SEVERE
public static final char CAPABILITY_FLOODFILL
public static final char CAPABILITY_NO_TUNNELS
public static final char CAPABILITY_UNREACHABLE
static final long MAX_RI_AGE_BEFORE_REFRESH_MS
public static final int MAX_TO_FLOOD
protected static final int MIN_ACTIVE_PEERS
static final long NEXT_RKEY_RI_ADVANCE_TIME
public static final String PROP_FLOODFILL_AT_RESTART
public static final String PROP_FLOODFILL_PARTICIPANT
static final long PUBLISH_TIMEOUT
static final long RECENTLY_QUERIED_COOLDOWN
public FloodfillNetworkDatabaseFacade(RouterContext context)
public FloodfillNetworkDatabaseFacade(RouterContext context, Hash dbid)
dbid - null for main DBvoid complete(Hash key)
public void contactHeardFrom(Hash peer)
peer - the peerprotected void createHandlers()
createHandlers in class KademliaNetworkDatabaseFacadestatic void decrementActiveFloodfillQuery(Hash floodfill)
public void flood(DatabaseEntry ds)
public boolean floodConditional(DatabaseEntry ds)
public boolean floodfillEnabled()
NetworkDatabaseFacadefloodfillEnabled in class NetworkDatabaseFacadepublic List<Hash> getFloodfillPeers()
public List<RouterInfo> getKnownRouterData()
public String getTunnelName(Destination d)
static int incrementActiveFloodfillQuery(Hash floodfill)
public static boolean isFloodfill(RouterInfo peer)
peer - may be null, returns false if nullstatic boolean isFloodfillOverloaded(Hash floodfill)
static boolean isRecentlyQueried(Hash peer)
boolean isVerifyInProgress(Hash h)
protected void lookupBeforeDropping(Hash peer, RouterInfo info)
lookupBeforeDropping in class KademliaNetworkDatabaseFacadepeer - the peerinfo - the router infostatic void markQueried(Hash peer)
void probeStalePeer(Hash peer, RouterInfo ri)
public void processElapsedTimeouts()
public void publish(RouterInfo localRouterInfo) throws IllegalArgumentException
publish in class KademliaNetworkDatabaseFacadelocalRouterInfo - the RouterInfo to publishIllegalArgumentException - if the local router info is invalidpublic void registerSearchTimeout(Hash peer, IterativeSearchJob search, long timeoutMs)
peer - the peersearch - the search termtimeoutMs - the absolute time when the timeout expiresSearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease)
search in class KademliaNetworkDatabaseFacadekey - the hash to search foronFindJob - job on findonFailedLookupJob - job on failuretimeoutMs - timeout in msisLease - whether searching for leaseSearchJob search(Hash key, Job onFindJob, Job onFailedLookupJob, long timeoutMs, boolean isLease, Hash fromLocalDest)
search in class KademliaNetworkDatabaseFacadefromLocalDest - use these tunnels for the lookup, or null for exploratorykey - the hash to search foronFindJob - job on findonFailedLookupJob - job on failuretimeoutMs - timeout in msisLease - whether searching for leasevoid sendStore(Hash key, DatabaseEntry ds, Job onSuccess, Job onFailure, long sendTimeout, Set<Hash> toIgnore)
sendStore in class KademliaNetworkDatabaseFacadekey - the DatabaseEntry hashonSuccess - may be null, always called if we are ff and ds is an RIonFailure - may be null, ignored if we are ff and ds is an RIsendTimeout - timeout in ms for send operations if we are ff and ds is an RItoIgnore - may be null, if non-null, all attempted and skipped targets will be added as of 0.9.53,
unused if we are ff and ds is an RIds - the database entrypublic void setFloodfillEnabled(boolean yes)
void setFloodfillEnabledFromMonitor(boolean yes)
boolean shouldBanLookup(Hash from, TunnelId id)
from - the peer hashid - the tunnel IDboolean shouldThrottleFlood(Hash key)
boolean shouldThrottleLookup(Hash from, TunnelId id)
public void shutdown()
shutdown in interface Serviceshutdown in class KademliaNetworkDatabaseFacadepublic void startTimeoutProcessor()
public void startup()
startup in interface Servicestartup in class KademliaNetworkDatabaseFacadevoid verifyFinished(Hash h)
void verifyStarted(Hash h)