mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-12-23 08:11:47 +00:00
Store content in string so saved file is easily readable.
This commit is contained in:
parent
1a5991404d
commit
eaeffeb0ba
@ -96,6 +96,7 @@ public class DHT
|
||||
/* We have this content, but not the latest version, lets delete it so the new version will be added below */
|
||||
try
|
||||
{
|
||||
System.out.println("Removing older content to update it");
|
||||
this.remove(content.getContentMetadata());
|
||||
}
|
||||
catch (ContentNotFoundException ex)
|
||||
|
@ -9,7 +9,7 @@ package kademlia.dht;
|
||||
public class StorageEntry
|
||||
{
|
||||
|
||||
private final byte[] content;
|
||||
private final String content;
|
||||
private final StorageEntryMetadata metadata;
|
||||
|
||||
public StorageEntry(KadContent content)
|
||||
@ -19,11 +19,11 @@ public class StorageEntry
|
||||
|
||||
public StorageEntry(KadContent content, StorageEntryMetadata metadata)
|
||||
{
|
||||
this.content = content.toBytes();
|
||||
this.content = new String(content.toBytes());
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public byte[] getContent()
|
||||
public String getContent()
|
||||
{
|
||||
return this.content;
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class ContentSendingTest
|
||||
List<StorageEntry> conte = kad2.get(gp, 4);
|
||||
for (StorageEntry cc : conte)
|
||||
{
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent()));
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes()));
|
||||
System.out.println("Content Metadata: " + cc.getContentMetadata());
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ public class ContentUpdatingTest
|
||||
List<StorageEntry> conte = kad2.get(gp, 4);
|
||||
for (StorageEntry cc : conte)
|
||||
{
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent()));
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes()));
|
||||
System.out.println("Content Metadata: " + cc.getContentMetadata());
|
||||
}
|
||||
|
||||
@ -51,7 +51,7 @@ public class ContentUpdatingTest
|
||||
conte = kad2.get(gp, 4);
|
||||
for (StorageEntry cc : conte)
|
||||
{
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent()));
|
||||
System.out.println("Content Found: " + new DHTContentImpl().fromBytes(cc.getContent().getBytes()));
|
||||
System.out.println("Content Metadata: " + cc.getContentMetadata());
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ public class SaveStateTest2
|
||||
|
||||
if (!content.isEmpty())
|
||||
{
|
||||
DHTContentImpl cc = new DHTContentImpl().fromBytes(content.get(0).getContent());
|
||||
DHTContentImpl cc = new DHTContentImpl().fromBytes(content.get(0).getContent().getBytes());
|
||||
System.out.println("Content received: " + cc);
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user