public DHTFuture<QuickenEntity> quicken(QuickenConfig config) {
QuickenConfig cfg = configProvider.get(config);
TimeStamp creationTime = TimeStamp.now();
List<DHTFuture<PingEntity>> pingFutures = new ArrayList<>();
List<DHTFuture<NodeEntity>> discoveryFutures = new ArrayList<>();
synchronized (routeTable) {
int pingCount = (int)(routeTable.getK() * cfg.getPingCount());
Contact localhost = routeTable.getIdentity();
KUID localhostId = localhost.getId();
if (0 < pingCount) {
PingConfig pingConfig = cfg.getPingConfig();
long contactTimeout = cfg.getContactTimeoutInMillis();
Contact[] contacts = routeTable.select(localhostId, pingCount);
for (Contact contact : contacts) {
// Don't send PINGs to the localhost!
if (contact.equals(localhost)) {
continue;
}
if (contact.isTimeout(contactTimeout, TimeUnit.MILLISECONDS)) {
DHTFuture<PingEntity> future
= pingManager.ping(contact, pingConfig);
pingFutures.add(future);
}
}
}
NodeConfig lookupConfig = cfg.getLookupConfig();
long bucketTimeout = cfg.getBucketTimeoutInMillis();
Bucket[] buckets = routeTable.getBuckets();
IdentifierUtils.byXor(buckets, localhostId);
for (Bucket bucket : buckets) {
if (bucket.contains(localhostId)) {
continue;
}
TimeStamp timeStamp = bucket.getTimeStamp();
if (timeStamp.getAgeInMillis() < bucketTimeout) {
continue;
}
// Select a random ID with this prefix
KUID randomId = KUID.createWithPrefix(