mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 02:02:21 +00:00
Had some issues with saving node state since saving configuration had a problem. We do not need to save configuration! Fixed the bug by making the configuration transient
This commit is contained in:
parent
b1ab1be760
commit
1995682992
@ -39,8 +39,8 @@ javac.compilerargs=
|
|||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
javac.processorpath=\
|
javac.processorpath=\
|
||||||
${javac.classpath}
|
${javac.classpath}
|
||||||
javac.source=1.7
|
javac.source=1.8
|
||||||
javac.target=1.7
|
javac.target=1.8
|
||||||
javac.test.classpath=\
|
javac.test.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
${build.classes.dir}
|
${build.classes.dir}
|
||||||
|
@ -61,7 +61,7 @@ public class Kademlia
|
|||||||
private final transient DHT dht;
|
private final transient DHT dht;
|
||||||
private final transient Timer timer;
|
private final transient Timer timer;
|
||||||
private final int udpPort;
|
private final int udpPort;
|
||||||
private KadConfiguration config;
|
private transient KadConfiguration config;
|
||||||
|
|
||||||
/* Factories */
|
/* Factories */
|
||||||
private final transient MessageFactory messageFactory;
|
private final transient MessageFactory messageFactory;
|
||||||
@ -123,7 +123,8 @@ public class Kademlia
|
|||||||
|
|
||||||
public Kademlia(String ownerId, NodeId defaultId, int udpPort) throws IOException
|
public Kademlia(String ownerId, NodeId defaultId, int udpPort) throws IOException
|
||||||
{
|
{
|
||||||
this(ownerId, new Node(defaultId, InetAddress.getLocalHost(), udpPort), udpPort, new DHT(ownerId, new DefaultConfiguration()), new DefaultConfiguration());
|
this(ownerId, new Node(defaultId, InetAddress.getLocalHost(), udpPort), udpPort,
|
||||||
|
new DHT(ownerId, new DefaultConfiguration()), new DefaultConfiguration());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -185,7 +186,7 @@ public class Kademlia
|
|||||||
din = new DataInputStream(new FileInputStream(getStateStorageFolderName(ownerId, iconfig) + File.separator + "dht.kns"));
|
din = new DataInputStream(new FileInputStream(getStateStorageFolderName(ownerId, iconfig) + File.separator + "dht.kns"));
|
||||||
DHT idht = new JsonDHTSerializer().read(din);
|
DHT idht = new JsonDHTSerializer().read(din);
|
||||||
|
|
||||||
return new Kademlia(ownerId, inode, ikad.getPort(), idht, ikad.getCurrentConfiguration());
|
return new Kademlia(ownerId, inode, ikad.getPort(), idht, iconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,6 +19,14 @@ public class DefaultConfiguration implements KadConfiguration
|
|||||||
private final static int STALE = 1;
|
private final static int STALE = 1;
|
||||||
private final static String LOCAL_FOLDER = "kademlia";
|
private final static String LOCAL_FOLDER = "kademlia";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor to support Gson Serialization
|
||||||
|
*/
|
||||||
|
public DefaultConfiguration()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long restoreInterval()
|
public long restoreInterval()
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ package kademlia.core;
|
|||||||
*/
|
*/
|
||||||
public interface KadConfiguration
|
public interface KadConfiguration
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Interval in milliseconds between execution of RestoreOperations.
|
* @return Interval in milliseconds between execution of RestoreOperations.
|
||||||
*/
|
*/
|
||||||
|
@ -31,7 +31,7 @@ public class KadServer
|
|||||||
private static final int DATAGRAM_BUFFER_SIZE = 64 * 1024; // 64KB
|
private static final int DATAGRAM_BUFFER_SIZE = 64 * 1024; // 64KB
|
||||||
|
|
||||||
/* Basic Kad Objects */
|
/* Basic Kad Objects */
|
||||||
private final KadConfiguration config;
|
private final transient KadConfiguration config;
|
||||||
|
|
||||||
/* Server Objects */
|
/* Server Objects */
|
||||||
private final int udpPort;
|
private final int udpPort;
|
||||||
|
@ -9,7 +9,6 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import kademlia.core.DefaultConfiguration;
|
|
||||||
import kademlia.core.GetParameter;
|
import kademlia.core.GetParameter;
|
||||||
import kademlia.core.KadConfiguration;
|
import kademlia.core.KadConfiguration;
|
||||||
import kademlia.exceptions.ContentExistException;
|
import kademlia.exceptions.ContentExistException;
|
||||||
@ -27,8 +26,8 @@ public class DHT
|
|||||||
{
|
{
|
||||||
|
|
||||||
private transient StorageEntryManager entriesManager;
|
private transient StorageEntryManager entriesManager;
|
||||||
private transient final JsonSerializer<KadContent> contentSerializer;
|
private final transient JsonSerializer<KadContent> contentSerializer;
|
||||||
private final KadConfiguration config;
|
private final transient KadConfiguration config;
|
||||||
|
|
||||||
private final String ownerId;
|
private final String ownerId;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user