From 9e62d617c6f777bc180320bad9331262dba43190 Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Fri, 19 Feb 2016 16:16:57 -0500 Subject: [PATCH] Coded getMutableItemSeq --- .../jlibtorrent/plugins/DhtStorageBase.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/frostwire/jlibtorrent/plugins/DhtStorageBase.java b/src/main/java/com/frostwire/jlibtorrent/plugins/DhtStorageBase.java index 9d9721f24..5b560d9f9 100644 --- a/src/main/java/com/frostwire/jlibtorrent/plugins/DhtStorageBase.java +++ b/src/main/java/com/frostwire/jlibtorrent/plugins/DhtStorageBase.java @@ -17,6 +17,7 @@ public class DhtStorageBase implements DhtStorage { private final HashMap torrents; private final HashMap immutables; + private final HashMap mutables; public DhtStorageBase(Sha1Hash id, DhtSettings settings) { this.id = id; @@ -25,6 +26,7 @@ public DhtStorageBase(Sha1Hash id, DhtSettings settings) { this.torrents = new HashMap(); this.immutables = new HashMap(); + this.mutables = new HashMap(); } @Override @@ -179,7 +181,8 @@ public void putImmutableItem(Sha1Hash target, byte[] buf, Address addr) { @Override public long getMutableItemSeq(Sha1Hash target) { - return -1; + DhtMutableItem i = mutables.get(target); + return i != null ? i.seq : -1; } @Override @@ -244,7 +247,7 @@ public TorrentEntry() { public TreeSet peers; } - private static final class DhtImmutableItem { + private static class DhtImmutableItem { // malloced space for the actual value public byte[] value; // this counts the number of IPs we have seen @@ -257,6 +260,13 @@ private static final class DhtImmutableItem { public int num_announcers; } + private static final class DhtMutableItem extends DhtImmutableItem { + public byte[] sig = new byte[64]; + public long seq; + public byte[] key = new byte[32]; + public byte[] salt; + } + private static final class ImmutableItemComparator implements Comparator> { private final Sha1Hash ourId;