mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 10:12:19 +00:00
Some comments and fixes
This commit is contained in:
parent
3e236f4d17
commit
cc1d03ba81
@ -1,13 +1,11 @@
|
|||||||
package kademlia.dht;
|
package kademlia.dht;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import kademlia.node.NodeId;
|
import kademlia.node.NodeId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Any piece of content that needs to be stored on the DHT
|
* Any piece of content that needs to be stored on the DHT
|
||||||
*
|
*
|
||||||
* @author Joshua Kissoon
|
* @author Joshua Kissoon
|
||||||
* @param <T>
|
|
||||||
*
|
*
|
||||||
* @since 20140224
|
* @since 20140224
|
||||||
*/
|
*/
|
||||||
@ -45,7 +43,23 @@ public interface KadContent
|
|||||||
*/
|
*/
|
||||||
public String getOwnerId();
|
public String getOwnerId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Each content needs to be in byte format for transporting and storage,
|
||||||
|
* this method takes care of that.
|
||||||
|
*
|
||||||
|
* Each object is responsible for transforming itself to byte format since the
|
||||||
|
* structure of methods may differ.
|
||||||
|
*
|
||||||
|
* @return byte[] The content in byte format
|
||||||
|
*/
|
||||||
public byte[] toBytes();
|
public byte[] toBytes();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given the Content in byte format, read it
|
||||||
|
*
|
||||||
|
* @param data The object in byte format
|
||||||
|
*
|
||||||
|
* @return A new object from the given byte[]
|
||||||
|
*/
|
||||||
public KadContent fromBytes(byte[] data);
|
public KadContent fromBytes(byte[] data);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ public class ContentSendingTest
|
|||||||
*/
|
*/
|
||||||
System.out.println("Retrieving Content");
|
System.out.println("Retrieving Content");
|
||||||
GetParameter gp = new GetParameter(c.getKey(), DHTContentImpl.TYPE);
|
GetParameter gp = new GetParameter(c.getKey(), DHTContentImpl.TYPE);
|
||||||
gp.setType(DHTContentImpl.TYPE);
|
|
||||||
gp.setOwnerId(c.getOwnerId());
|
gp.setOwnerId(c.getOwnerId());
|
||||||
System.out.println("Get Parameter: " + gp);
|
System.out.println("Get Parameter: " + gp);
|
||||||
List<StorageEntry> conte = kad2.get(gp, 4);
|
List<StorageEntry> conte = kad2.get(gp, 4);
|
||||||
|
@ -13,6 +13,8 @@ import kademlia.node.NodeId;
|
|||||||
public class DHTContentImpl implements KadContent
|
public class DHTContentImpl implements KadContent
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public static final transient String TYPE = "DHTContentImpl";
|
||||||
|
|
||||||
private NodeId key;
|
private NodeId key;
|
||||||
private String data;
|
private String data;
|
||||||
private String ownerId;
|
private String ownerId;
|
||||||
@ -76,7 +78,6 @@ public class DHTContentImpl implements KadContent
|
|||||||
return this.updateTs;
|
return this.updateTs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] toBytes()
|
public byte[] toBytes()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user