Just to clear up any confusion about what the code does, it takes an 'Object' class (a class of float and numbers), writes to a file (using binary formatting), and uses an IPFS.Net implementation to write the file to the network. Creating the file is OK, but when saving the file the code hangs indefinitely in Unity. The code is below:
public static class IPFS_IO
{
public static void AddObject(Object obs)
{
string path = Application.persistentDataPath + "/data.bytes";
if (File.Exists(path))
{
File.Delete(path);
}
FileStream stream = File.Create(path);
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, obs);
stream.Close();
Task<Ipfs.IFileSystemNode> taskA = AddObjectSaveHash(path);
taskA.Wait();
//string hashpath = Application.persistentDataPath + "/hash.txt";
//StreamWriter writer = new StreamWriter(hashpath);
//writer.Write(hash);
//writer.Close();
}
async static Task<Ipfs.IFileSystemNode> AddObjectSaveHash(string path)
{
Batteries.Init();
using (var ie = new IpfsEngine("".ToCharArray()))
{
return await ie.FileSystem.AddFileAsync(path)
.ConfigureAwait(false);
}
}
Is this a common deadlock, or is it just too much data fed into the network? Bearing in mind:
a) This is a C# implementation to be used in the Unity Game Engine
b) I am using Richard Schneiders implementation (github: https://github.com/richardschneider/net-ipfs-engine)
Thanks for any help or problems you guys can spot.