use of net.i2p.data.i2np.DatabaseStoreMessage in project i2p.i2p by i2p.
the class SearchJob method resend.
/**
* Resend the leaseSet to the peer who had previously failed to
* provide us with the data when we asked them.
*/
private boolean resend(RouterInfo toPeer, LeaseSet ls) {
Hash to = toPeer.getIdentity().getHash();
DatabaseStoreMessage msg = new DatabaseStoreMessage(getContext());
msg.setEntry(ls);
msg.setMessageExpiration(getContext().clock().now() + RESEND_TIMEOUT);
TunnelInfo outTunnel = getContext().tunnelManager().selectOutboundExploratoryTunnel(to);
if (outTunnel != null) {
if (_log.shouldLog(Log.DEBUG))
_log.debug("resending leaseSet out to " + to + " through " + outTunnel + ": " + msg);
// TODO pass a priority to the dispatcher
getContext().tunnelDispatcher().dispatchOutbound(msg, outTunnel.getSendTunnelId(0), null, to);
return true;
} else {
if (_log.shouldLog(Log.WARN))
_log.warn("unable to resend a leaseSet - no outbound exploratory tunnels!");
return false;
}
}
use of net.i2p.data.i2np.DatabaseStoreMessage in project i2p.i2p by i2p.
the class PeerTestJob method buildMessage.
/**
* Build a message to test the peer with.
* The message is a store of the peer's RI to itself,
* with a reply token.
*/
private DatabaseStoreMessage buildMessage(RouterInfo peer, TunnelId replyTunnel, Hash replyGateway, long nonce, long expiration) {
DatabaseStoreMessage msg = new DatabaseStoreMessage(getContext());
msg.setEntry(peer);
msg.setReplyGateway(replyGateway);
msg.setReplyTunnel(replyTunnel);
msg.setReplyToken(nonce);
msg.setMessageExpiration(expiration);
return msg;
}
use of net.i2p.data.i2np.DatabaseStoreMessage in project i2p.i2p by i2p.
the class HandleDatabaseLookupMessageJob method sendData.
private void sendData(Hash key, DatabaseEntry data, Hash toPeer, TunnelId replyTunnel) {
if (!key.equals(data.getHash())) {
_log.error("Hash mismatch HDLMJ");
return;
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("Sending data matching key " + key + " to peer " + toPeer + " tunnel " + replyTunnel);
DatabaseStoreMessage msg = new DatabaseStoreMessage(getContext());
if (data.getType() == DatabaseEntry.KEY_TYPE_LEASESET) {
getContext().statManager().addRateData("netDb.lookupsMatchedLeaseSet", 1);
}
msg.setEntry(data);
getContext().statManager().addRateData("netDb.lookupsMatched", 1);
getContext().statManager().addRateData("netDb.lookupsHandled", 1);
sendMessage(msg, toPeer, replyTunnel);
}
use of net.i2p.data.i2np.DatabaseStoreMessage in project i2p.i2p by i2p.
the class FloodfillRouterInfoFloodJob method runJob.
public void runJob() {
FloodfillPeerSelector sel = (FloodfillPeerSelector) _facade.getPeerSelector();
DatabaseStoreMessage dsm;
OutNetMessage outMsg;
RouterInfo nextPeerInfo;
List<Hash> peers = sel.selectFloodfillParticipants(getContext().routerHash(), FLOOD_PEERS, null);
for (Hash ri : peers) {
// Iterate through list of nearby (ff) peers
dsm = new DatabaseStoreMessage(getContext());
dsm.setMessageExpiration(getContext().clock().now() + 10 * 1000);
dsm.setEntry(getContext().router().getRouterInfo());
nextPeerInfo = getContext().netDb().lookupRouterInfoLocally(ri);
if (nextPeerInfo == null) {
continue;
}
outMsg = new OutNetMessage(getContext(), dsm, getContext().clock().now() + 10 * 1000, OutNetMessage.PRIORITY_MY_NETDB_STORE, nextPeerInfo);
// Whoosh!
getContext().outNetMessagePool().add(outMsg);
if (_log.shouldLog(Log.DEBUG)) {
_log.logAlways(Log.DEBUG, "Sending our RI to: " + nextPeerInfo.getHash());
}
}
}
use of net.i2p.data.i2np.DatabaseStoreMessage in project i2p.i2p by i2p.
the class HandleFloodfillDatabaseLookupMessageJob method sendClosest.
/**
* We extend this here to send our routerInfo back as well, if we are not floodfill.
* This gets the word out to routers that we are no longer floodfill, so they
* will stop bugging us.
*/
@Override
protected void sendClosest(Hash key, Set<Hash> routerInfoSet, Hash toPeer, TunnelId replyTunnel) {
super.sendClosest(key, routerInfoSet, toPeer, replyTunnel);
// go away, you got the wrong guy, send our RI back unsolicited
if (!getContext().netDb().floodfillEnabled()) {
// We could just call sendData(myhash, myri, toPeer, replyTunnel) but
// that would increment the netDb.lookupsHandled and netDb.lookupsMatched stats
DatabaseStoreMessage msg = new DatabaseStoreMessage(getContext());
RouterInfo me = getContext().router().getRouterInfo();
msg.setEntry(me);
sendMessage(msg, toPeer, replyTunnel);
}
}
Aggregations