Example #1
0
    public static async Task <string> AddObject(List <Object> obs, IpfsGenesis gen, string addhash)
    {
        string hashpath     = Application.persistentDataPath + "/hash.txt";
        string hashdatapath = Application.persistentDataPath + "/data.txt";

        if (File.Exists(hashdatapath))
        {
            File.Delete(hashdatapath);
        }

        StreamWriter txtobjectwriter = new StreamWriter(hashdatapath);

        txtobjectwriter.WriteLine("Hash:" + addhash);

        foreach (Object ob in obs)
        {
            MemoryStream    memoryStream    = new MemoryStream();
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            binaryFormatter.Serialize(memoryStream, ob);
            string str = System.Convert.ToBase64String(memoryStream.ToArray());

            txtobjectwriter.WriteLine(str);
        }
        txtobjectwriter.Close();

        Ipfs.Cid taskA = await AddObjectSaveHash(hashdatapath);

        string hash = taskA.Hash.ToString();

        Debug.Log(hash);

        StreamWriter txtwriter = new StreamWriter(hashpath);

        txtwriter.Write(hash);
        txtwriter.Close();

        return(hash);
    }
Example #2
0
        public void Decode_V1_Invalid_MultiBase_Code()
        {
            var id = "?";

            Assert.ThrowsException <FormatException>(() => Cid.Decode(id));
        }
Example #3
0
        public void Decode_V1_Invalid_MultiBase_String()
        {
            var id = "zb2rhj7crUKTQYRGCRATFaQ6YFLTde2YzdqbbhAASkL9uRDX?";

            Assert.ThrowsException <FormatException>(() => Cid.Decode(id));
        }
Example #4
0
        public void Decode_V0_Invalid()
        {
            var hash = "QmXg9Pp2ytZ14xgmQjYEiHjVjMFXzCVVEcRTWJBmLgR39?";

            Assert.ThrowsException <FormatException>(() => Cid.Decode(hash));
        }
Example #5
0
            /// <inheritdoc />
            public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
            {
                var s = reader.Value as string;

                return(s == null ? null : Cid.Decode(s));
            }
 /// <summary>
 ///   Create a new instance of <see cref="DagLink"/> class.
 /// </summary>
 /// <param name="name">The name associated with the linked node.</param>
 /// <param name="id">The <see cref="Cid"/> of the linked node.</param>
 /// <param name="size">The serialised size (in bytes) of the linked node.</param>
 public DagLink(string name, Cid id, long size)
 {
     this.Name = name;
     this.Id   = id;
     this.Size = size;
 }