From eeb1852d9568a2f88cf86b0de1ea9dc0de7aed7e Mon Sep 17 00:00:00 2001 From: jrandom Date: Wed, 11 Aug 2004 22:51:00 +0000 Subject: [PATCH] take note of the reason each peer is shitlisted and display that on the console (good idea oOo) cleaned up the shitlisting process within the TCPTransport so that we don't shitlist twice (clobbering the detailed cause with a general "uh, couldn't contact 'em" cause) --- router/java/src/net/i2p/router/Shitlist.java | 33 ++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/router/java/src/net/i2p/router/Shitlist.java b/router/java/src/net/i2p/router/Shitlist.java index 52af0504b..745d29975 100644 --- a/router/java/src/net/i2p/router/Shitlist.java +++ b/router/java/src/net/i2p/router/Shitlist.java @@ -28,13 +28,15 @@ public class Shitlist { private Log _log; private RouterContext _context; private Map _shitlist; // H(routerIdent) --> Date + private Map _shitlistCause; // H(routerIdent) --> String public final static long SHITLIST_DURATION_MS = 4*60*1000; // 4 minute shitlist public Shitlist(RouterContext context) { _context = context; _log = context.logManager().getLog(Shitlist.class); - _shitlist = new HashMap(100); + _shitlist = new HashMap(5); + _shitlistCause = new HashMap(5); } public int getRouterCount() { @@ -44,6 +46,9 @@ public class Shitlist { } public boolean shitlistRouter(Hash peer) { + return shitlistRouter(peer, null); + } + public boolean shitlistRouter(Hash peer, String reason) { if (peer == null) return false; if (_context.routerHash().equals(peer)) { _log.error("wtf, why did we try to shitlist ourselves?", new Exception("shitfaced")); @@ -56,6 +61,11 @@ public class Shitlist { synchronized (_shitlist) { Date oldDate = (Date)_shitlist.put(peer, new Date(_context.clock().now())); wasAlready = (null == oldDate); + if (reason != null) { + _shitlistCause.put(peer, reason); + } else { + _shitlistCause.remove(peer); + } } //_context.netDb().fail(peer); @@ -68,6 +78,7 @@ public class Shitlist { _log.info("Unshitlisting router " + peer.toBase64()); synchronized (_shitlist) { _shitlist.remove(peer); + _shitlistCause.remove(peer); } } @@ -90,9 +101,11 @@ public class Shitlist { public void renderStatusHTML(OutputStream out) throws IOException { StringBuffer buf = new StringBuffer(1024); buf.append("

Shitlist

"); - Map shitlist = new HashMap(); + Map shitlist = null; + Map causes = null; synchronized (_shitlist) { - shitlist.putAll(_shitlist); + shitlist = new HashMap(_shitlist); + causes = new HashMap(_shitlistCause); } buf.append("\n"); out.write(buf.toString().getBytes());