Search in sources :

Example 16 with DatabaseEntry

use of net.i2p.data.DatabaseEntry in project i2p.i2p by i2p.

the class SearchJob method resend.

/**
 * After we get the data we were searching for, rebroadcast it to the peers
 * we would query first if we were to search for it again (healing the network).
 */
private void resend() {
    DatabaseEntry ds = _facade.lookupLeaseSetLocally(_state.getTarget());
    if (ds == null) {
        if (SHOULD_RESEND_ROUTERINFO) {
            ds = _facade.lookupRouterInfoLocally(_state.getTarget());
            if (ds != null)
                _facade.sendStore(_state.getTarget(), ds, null, null, RESEND_TIMEOUT, _state.getSuccessful());
        }
    } else {
        // _state.getFailed();
        Set<Hash> sendTo = _state.getRepliedPeers();
        sendTo.addAll(_state.getPending());
        int numSent = 0;
        for (Hash peer : sendTo) {
            RouterInfo peerInfo = _facade.lookupRouterInfoLocally(peer);
            if (peerInfo == null)
                continue;
            if (resend(peerInfo, (LeaseSet) ds))
                numSent++;
            if (numSent >= MAX_LEASE_RESEND)
                break;
        }
        getContext().statManager().addRateData("netDb.republishQuantity", numSent, numSent);
    }
}
Also used : RouterInfo(net.i2p.data.router.RouterInfo) DatabaseEntry(net.i2p.data.DatabaseEntry) Hash(net.i2p.data.Hash)

Aggregations

DatabaseEntry (net.i2p.data.DatabaseEntry)16 Hash (net.i2p.data.Hash)11 RouterInfo (net.i2p.data.router.RouterInfo)9 LeaseSet (net.i2p.data.LeaseSet)4 Date (java.util.Date)2 HashSet (java.util.HashSet)2 DatabaseStoreMessage (net.i2p.data.i2np.DatabaseStoreMessage)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Map (java.util.Map)1 NoSuchElementException (java.util.NoSuchElementException)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 DatabaseLookupMessage (net.i2p.data.i2np.DatabaseLookupMessage)1 DatabaseSearchReplyMessage (net.i2p.data.i2np.DatabaseSearchReplyMessage)1 I2NPMessage (net.i2p.data.i2np.I2NPMessage)1