mirror of
https://github.com/ChronosX88/KademliaDHT.git
synced 2024-11-22 02:02:21 +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 */
|
/* We have this content, but not the latest version, lets delete it so the new version will be added below */
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
System.out.println("Removing older content to update it");
|
||||||
this.remove(content.getContentMetadata());
|
this.remove(content.getContentMetadata());
|
||||||
}
|
}
|
||||||
catch (ContentNotFoundException ex)
|
catch (ContentNotFoundException ex)
|
||||||
|
@ -9,7 +9,7 @@ package kademlia.dht;
|
|||||||
public class StorageEntry
|
public class StorageEntry
|
||||||
{
|
{
|
||||||
|
|
||||||
private final byte[] content;
|
private final String content;
|
||||||
private final StorageEntryMetadata metadata;
|
private final StorageEntryMetadata metadata;
|
||||||
|
|
||||||
public StorageEntry(KadContent content)
|
public StorageEntry(KadContent content)
|
||||||
@ -19,11 +19,11 @@ public class StorageEntry
|
|||||||
|
|
||||||
public StorageEntry(KadContent content, StorageEntryMetadata metadata)
|
public StorageEntry(KadContent content, StorageEntryMetadata metadata)
|
||||||
{
|
{
|
||||||
this.content = content.toBytes();
|
this.content = new String(content.toBytes());
|
||||||
this.metadata = metadata;
|
this.metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getContent()
|
public String getContent()
|
||||||
{
|
{
|
||||||
return this.content;
|
return this.content;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class ContentSendingTest
|
|||||||
List<StorageEntry> conte = kad2.get(gp, 4);
|
List<StorageEntry> conte = kad2.get(gp, 4);
|
||||||
for (StorageEntry cc : conte)
|
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());
|
System.out.println("Content Metadata: " + cc.getContentMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class ContentUpdatingTest
|
|||||||
List<StorageEntry> conte = kad2.get(gp, 4);
|
List<StorageEntry> conte = kad2.get(gp, 4);
|
||||||
for (StorageEntry cc : conte)
|
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());
|
System.out.println("Content Metadata: " + cc.getContentMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ public class ContentUpdatingTest
|
|||||||
conte = kad2.get(gp, 4);
|
conte = kad2.get(gp, 4);
|
||||||
for (StorageEntry cc : conte)
|
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());
|
System.out.println("Content Metadata: " + cc.getContentMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class SaveStateTest2
|
|||||||
|
|
||||||
if (!content.isEmpty())
|
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);
|
System.out.println("Content received: " + cc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user