NetDb: Track flood success

This commit is contained in:
zzz
2015-03-15 13:37:22 +00:00
parent 5b555855ef
commit a9f6839a04

View File

@ -221,10 +221,12 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
DatabaseStoreMessage msg = new DatabaseStoreMessage(_context);
msg.setEntry(ds);
OutNetMessage m = new OutNetMessage(_context, msg, _context.clock().now()+FLOOD_TIMEOUT, FLOOD_PRIORITY, target);
// note send failure but don't give credit on success
// might need to change this
Job floodFail = new FloodFailedJob(_context, peer);
m.setOnFailedSendJob(floodFail);
// we want to give credit on success, even if we aren't sure,
// because otherwise no use noting failure
Job floodGood = new FloodSuccessJob(_context, peer);
m.setOnSendJob(floodGood);
_context.commSystem().processMessage(m);
flooded++;
if (_log.shouldLog(Log.INFO))
@ -249,6 +251,23 @@ public class FloodfillNetworkDatabaseFacade extends KademliaNetworkDatabaseFacad
}
}
/**
* Note in the profile that the store succeeded
* @since 0.9.19
*/
private static class FloodSuccessJob extends JobImpl {
private final Hash _peer;
public FloodSuccessJob(RouterContext ctx, Hash peer) {
super(ctx);
_peer = peer;
}
public String getName() { return "Flood succeeded"; }
public void runJob() {
getContext().profileManager().dbStoreSuccessful(_peer);
}
}
@Override
protected PeerSelector createPeerSelector() { return new FloodfillPeerSelector(_context); }