public Block GetCachedBlock(string path, Func <string> getBlockJson)
        {
            var file = new FileInfo(path);

            if (file.Exists)
            {
                rwl.EnterReadLock();
                try
                {
                    using (var reader = new StreamReader(file.FullName, Encoding.UTF8))
                    {
                        return(BlockJson.GetBlockFromJson(reader.ReadToEnd()));
                    }
                }
                finally
                {
                    rwl.ExitReadLock();
                }
            }
            else
            {
                var blockJson = getBlockJson();

                file.Directory.Create();

                lock (staticLock)
                {
                    rwl.EnterWriteLock();
                    try
                    {
                        using (var writer = new StreamWriter(file.FullName, false, Encoding.UTF8))
                        {
                            writer.Write(blockJson);
                        }
                    }
                    finally
                    {
                        rwl.ExitWriteLock();
                    }
                }

                return(BlockJson.GetBlockFromJson(blockJson));
            }
        }
 public override Block GetBlock(string hash)
 {
     return(BlockJson.GetBlockFromJson(GetBlockJson(hash)));
 }
 public override Block GetBlock(int index)
 {
     return(BlockJson.GetBlockFromJson(GetBlockJson(index)));
 }