*/
RecentlyForwardedItem item = recentlyForwardedIDs.get(oldID);
if(item != null) {
if(logMINOR) Logger.minor(this, "Rejecting - same ID as previous request");
// Reject
Message reject = DMT.createFNPSwapRejected(oldID);
try {
pn.sendAsync(reject, null, this);
} catch (NotConnectedException e) {
if(logMINOR) Logger.minor(this, "Lost connection to "+pn+" rejecting SwapRequest");
}
swapsRejectedRecognizedID++;
return true;
}
if(pn.shouldRejectSwapRequest()) {
if(logMINOR) Logger.minor(this, "Advised to reject SwapRequest by PeerNode - rate limit");
// Reject
Message reject = DMT.createFNPSwapRejected(oldID);
try {
pn.sendAsync(reject, null, this);
} catch (NotConnectedException e) {
if(logMINOR) Logger.minor(this, "Lost connection rejecting SwapRequest from "+pn);
}
swapsRejectedRateLimit++;
return true;
}
if(logMINOR) Logger.minor(this, "SwapRequest from "+pn+" - uid="+oldID);
int htl = m.getInt(DMT.HTL);
if(htl > SWAP_MAX_HTL) {
Logger.error(this, "Bogus swap HTL: "+htl+" from "+pn+" uid="+oldID);
htl = SWAP_MAX_HTL;
}
htl--;
if(!node.enableSwapping || htl <= 0 && swappingDisabled()) {
// Reject
Message reject = DMT.createFNPSwapRejected(oldID);
try {
pn.sendAsync(reject, null, this);
} catch (NotConnectedException e1) {
if(logMINOR) Logger.minor(this, "Lost connection rejecting SwapRequest (locked) from "+pn);
}
return true;
}
// Either forward it or handle it
if(htl <= 0) {
if(logMINOR) Logger.minor(this, "Accepting?... "+oldID);
// Accept - handle locally
lockOrQueue(m, oldID, newID, pn);
return true;
} else {
m.set(DMT.HTL, htl);
m.set(DMT.UID, newID);
if(logMINOR) Logger.minor(this, "Forwarding... "+oldID);
while(true) {
// Forward
PeerNode randomPeer = node.peers.getRandomPeer(pn);
if(randomPeer == null) {
if(logMINOR) Logger.minor(this, "Late reject "+oldID);
Message reject = DMT.createFNPSwapRejected(oldID);
try {
pn.sendAsync(reject, null, this);
} catch (NotConnectedException e1) {
Logger.normal(this, "Late reject but disconnected from sender: "+pn);
}