forked from I2P_Developers/i2p.i2p
* netdb.jsp: Fix debug median calculation
This commit is contained in:
@ -39,7 +39,7 @@ import net.i2p.util.OrderedProperties;
|
|||||||
import net.i2p.util.VersionComparator;
|
import net.i2p.util.VersionComparator;
|
||||||
|
|
||||||
public class NetDbRenderer {
|
public class NetDbRenderer {
|
||||||
private RouterContext _context;
|
private final RouterContext _context;
|
||||||
|
|
||||||
public NetDbRenderer (RouterContext ctx) {
|
public NetDbRenderer (RouterContext ctx) {
|
||||||
_context = ctx;
|
_context = ctx;
|
||||||
@ -119,12 +119,19 @@ public class NetDbRenderer {
|
|||||||
fmt = null;
|
fmt = null;
|
||||||
}
|
}
|
||||||
leases.addAll(_context.netDb().getLeases());
|
leases.addAll(_context.netDb().getLeases());
|
||||||
int medianCount = leases.size() / 2;
|
int medianCount = 0;
|
||||||
BigInteger median = null;
|
BigInteger median = null;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
|
if (debug) {
|
||||||
|
// Find the center of the RAP leasesets
|
||||||
|
for (LeaseSet ls : leases) {
|
||||||
|
if (ls.getReceivedAsPublished())
|
||||||
|
medianCount++;
|
||||||
|
}
|
||||||
|
medianCount /= 2;
|
||||||
|
}
|
||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
for (Iterator iter = leases.iterator(); iter.hasNext(); ) {
|
for (LeaseSet ls : leases) {
|
||||||
LeaseSet ls = (LeaseSet)iter.next();
|
|
||||||
Destination dest = ls.getDestination();
|
Destination dest = ls.getDestination();
|
||||||
Hash key = dest.calculateHash();
|
Hash key = dest.calculateHash();
|
||||||
buf.append("<b>").append(_("LeaseSet")).append(": ").append(key.toBase64());
|
buf.append("<b>").append(_("LeaseSet")).append(": ").append(key.toBase64());
|
||||||
@ -153,13 +160,15 @@ public class NetDbRenderer {
|
|||||||
else
|
else
|
||||||
buf.append(_("Expired {0} ago", DataHelper.formatDuration2(0-exp))).append("<br>\n");
|
buf.append(_("Expired {0} ago", DataHelper.formatDuration2(0-exp))).append("<br>\n");
|
||||||
if (debug) {
|
if (debug) {
|
||||||
buf.append("RAP? " + ls.getReceivedAsPublished() + ' ');
|
buf.append("RAP? " + ls.getReceivedAsPublished());
|
||||||
buf.append("RAR? " + ls.getReceivedAsReply() + ' ');
|
buf.append(" RAR? " + ls.getReceivedAsReply());
|
||||||
BigInteger dist = HashDistance.getDistance(ourRKey, ls.getRoutingKey());
|
BigInteger dist = HashDistance.getDistance(ourRKey, ls.getRoutingKey());
|
||||||
if (c++ == medianCount)
|
if (ls.getReceivedAsPublished()) {
|
||||||
median = dist;
|
if (c++ == medianCount)
|
||||||
buf.append("Dist: <b>" + fmt.format(biLog2(dist)) + "</b> ");
|
median = dist;
|
||||||
buf.append("RKey: " + ls.getRoutingKey().toBase64() + ' ');
|
}
|
||||||
|
buf.append(" Dist: <b>").append(fmt.format(biLog2(dist))).append("</b>");
|
||||||
|
buf.append(" RKey: ").append(ls.getRoutingKey().toBase64());
|
||||||
buf.append("<br>");
|
buf.append("<br>");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < ls.getLeaseCount(); i++) {
|
for (int i = 0; i < ls.getLeaseCount(); i++) {
|
||||||
@ -174,9 +183,9 @@ public class NetDbRenderer {
|
|||||||
if (debug) {
|
if (debug) {
|
||||||
buf.append("<p><b>Total Leasesets: " + leases.size());
|
buf.append("<p><b>Total Leasesets: " + leases.size());
|
||||||
buf.append("</b></p><p><b>Published (RAP) Leasesets: " + _context.netDb().getKnownLeaseSets());
|
buf.append("</b></p><p><b>Published (RAP) Leasesets: " + _context.netDb().getKnownLeaseSets());
|
||||||
buf.append("</b></p><p><b>Mod Data: " + HexDump.dump(_context.routingKeyGenerator().getModData()));
|
//buf.append("</b></p><p><b>Mod Data: " + HexDump.dump(_context.routingKeyGenerator().getModData()));
|
||||||
buf.append("</b></p><p><b>Network data (only valid if floodfill):");
|
buf.append("</b></p><p><b>Network data (only valid if floodfill):");
|
||||||
buf.append("</b></p><p><b>Center of Key Space (router hash): " + ourRKey.toBase64());
|
//buf.append("</b></p><p><b>Center of Key Space (router hash): " + ourRKey.toBase64());
|
||||||
if (median != null) {
|
if (median != null) {
|
||||||
double log2 = biLog2(median);
|
double log2 = biLog2(median);
|
||||||
buf.append("</b></p><p><b>Median distance (bits): " + fmt.format(log2));
|
buf.append("</b></p><p><b>Median distance (bits): " + fmt.format(log2));
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
2012-02-17 zzz
|
||||||
|
* i2psnark: Escape fixes
|
||||||
|
* netdb.jsp: Fix debug median calculation
|
||||||
|
|
||||||
20112-02-17 kytv
|
20112-02-17 kytv
|
||||||
* Add Czech language from Transifex (thanks Waseihou)
|
* Add Czech language from Transifex (thanks Waseihou)
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ public class RouterVersion {
|
|||||||
/** deprecated */
|
/** deprecated */
|
||||||
public final static String ID = "Monotone";
|
public final static String ID = "Monotone";
|
||||||
public final static String VERSION = CoreVersion.VERSION;
|
public final static String VERSION = CoreVersion.VERSION;
|
||||||
public final static long BUILD = 13;
|
public final static long BUILD = 14;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "-rc";
|
||||||
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
System.out.println("I2P Router version: " + FULL_VERSION);
|
System.out.println("I2P Router version: " + FULL_VERSION);
|
||||||
|
Reference in New Issue
Block a user