mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-12-22 15:51:46 +00:00
Moved the HashCalculator to the utils package rather than have it in a package of it's own
Keep the StorageEntry content in the byte[] format it was originally in rather than constantly changing it to a string
This commit is contained in:
parent
428cab774b
commit
7b95d03d96
@ -9,7 +9,7 @@ package kademlia.dht;
|
||||
public class StorageEntry
|
||||
{
|
||||
|
||||
private final String content;
|
||||
private final byte[] content;
|
||||
private final StorageEntryMetadata metadata;
|
||||
|
||||
public StorageEntry(KadContent content)
|
||||
@ -19,15 +19,20 @@ public class StorageEntry
|
||||
|
||||
public StorageEntry(KadContent content, StorageEntryMetadata metadata)
|
||||
{
|
||||
this.content = new String(content.toBytes());
|
||||
this.content = content.toBytes();
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public String getContent()
|
||||
public byte[] getContent()
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
|
||||
public String getContentString()
|
||||
{
|
||||
return new String(this.content);
|
||||
}
|
||||
|
||||
public StorageEntryMetadata getContentMetadata()
|
||||
{
|
||||
return this.metadata;
|
||||
|
@ -41,7 +41,7 @@ public class ContentSendingTest
|
||||
gp.setOwnerId(c.getOwnerId());
|
||||
System.out.println("Get Parameter: " + gp);
|
||||
StorageEntry conte = kad2.get(gp);
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(conte.getContent().getBytes()));
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(conte.getContentString().getBytes()));
|
||||
System.out.println("Content Metadata: " + conte.getContentMetadata());
|
||||
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public class ContentUpdatingTest
|
||||
|
||||
System.out.println("Get Parameter: " + gp);
|
||||
StorageEntry conte = kad2.get(gp);
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(conte.getContent().getBytes()));
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(conte.getContentString().getBytes()));
|
||||
System.out.println("Content Metadata: " + conte.getContentMetadata());
|
||||
|
||||
/* Lets update the content and put it again */
|
||||
@ -47,7 +47,7 @@ public class ContentUpdatingTest
|
||||
/* Lets retrieve the content */
|
||||
System.out.println("Retrieving Content Again");
|
||||
conte = kad2.get(gp);
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(conte.getContent().getBytes()));
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(conte.getContentString().getBytes()));
|
||||
System.out.println("Content Metadata: " + conte.getContentMetadata());
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class SaveStateTest2
|
||||
/* Trying to get a content stored on the restored node */
|
||||
GetParameter gp = new GetParameter(c.getKey(), kad2.getOwnerId(), c.getType());
|
||||
StorageEntry content = kad2.get(gp);
|
||||
DHTContentImpl cc = new DHTContentImpl().fromBytes(content.getContent().getBytes());
|
||||
DHTContentImpl cc = new DHTContentImpl().fromBytes(content.getContentString().getBytes());
|
||||
System.out.println("Content received: " + cc);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package kademlia.util.hashing;
|
||||
package kademlia.util;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
Loading…
Reference in New Issue
Block a user