Esempio n. 1
0
        private async Task <string> GetRootHashAsyncUnderLock()
        {
            var tryReadResult = await objectStore.TryReadAsync(TreeNamespace, "root").ConfigureAwait(false);

            var rootExists = tryReadResult.Item1;

            return(rootExists
            ? CampfireNetHash.ConvertBase64BufferToSha256Base64String(tryReadResult.Item2)
            : null);
        }
Esempio n. 2
0
        public static async Task <MerkleNode> ReadMerkleNodeAsync(this ICampfireNetObjectStore store, string ns, string hash)
        {
            var tryReadResult = await store.TryReadAsync(ns, hash).ConfigureAwait(false);

            var tryReadSucceeded = tryReadResult.Item1;

            if (!tryReadSucceeded)
            {
                return(null);
            }

            var objectData = tryReadResult.Item2;

            using (var ms = new MemoryStream(objectData))
                using (var reader = new BinaryReader(ms)) {
                    return(reader.ReadMerkleNode());
                }
        }