use of net.i2p.data.i2np.DatabaseStoreMessage in project i2p.i2p by i2p.
the class FloodOnlyLookupSelector method isMatch.
public boolean isMatch(I2NPMessage message) {
if (message == null)
return false;
if (message instanceof DatabaseStoreMessage) {
DatabaseStoreMessage dsm = (DatabaseStoreMessage) message;
// is it worth making sure the reply came in on the right tunnel?
if (_search.getKey().equals(dsm.getKey())) {
_search.decrementRemaining();
_matchFound = true;
return true;
}
} else if (message instanceof DatabaseSearchReplyMessage) {
DatabaseSearchReplyMessage dsrm = (DatabaseSearchReplyMessage) message;
if (_search.getKey().equals(dsrm.getSearchKey())) {
// TODO - dsrm.getFromHash() can't be trusted - check against the list of
// those we sent the search to in _search ?
// assume 0 new, all old, 0 invalid, 0 dup
_context.profileManager().dbLookupReply(dsrm.getFromHash(), 0, dsrm.getNumReplies(), 0, 0, System.currentTimeMillis() - _search.getCreated());
// Only process if we don't know enough floodfills or are starting up
if (_search.shouldProcessDSRM()) {
if (_log.shouldLog(Log.INFO))
_log.info(_search.getJobId() + ": Processing DSRM via SingleLookupJob, apparently from " + dsrm.getFromHash());
// Chase the hashes from the reply
_context.jobQueue().addJob(new SingleLookupJob(_context, dsrm));
} else if (_log.shouldLog(Log.INFO)) {
int remaining = _search.getLookupsRemaining();
_log.info(_search.getJobId() + ": got a DSRM apparently from " + dsrm.getFromHash() + " when we were looking for " + _search.getKey() + ", with " + remaining + " outstanding searches");
}
// if no more left, time to fail
int remaining = _search.decrementRemaining(dsrm.getFromHash());
return remaining <= 0;
}
}
return false;
}
Aggregations