예제 #1
0
        public BlockchainUnit(string path, IIndexedStorage <long> addressStorage)
        {
            disposed = false;

            blockStorage       = new JsonDriveAccessor <Block>(path, addressStorage);
            merkleRootComputer = new MerkleTreeBuilder();
            digest             = new SHA3Managed(512);
        }
예제 #2
0
        public BinaryDriveAccessor(string path, IIndexedStorage <long> storage)
        {
            disposed = false;

            if (!File.Exists(path))
            {
                throw new ArgumentException($"File \"{path}\" doesn't exist.");
            }

            stream         = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            addressStorage = storage;
            serializer     = new BinaryFormatter();
        }
예제 #3
0
        public JsonDriveAccessor(string path, IIndexedStorage <long> storage)
        {
            disposed = false;

            if (!File.Exists(path))
            {
                throw new ArgumentException($"File \"{path}\" doesn't exist.");
            }

            stream         = File.Open(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            addressStorage = storage;

            writer           = new StreamWriter(stream);
            writer.AutoFlush = true;
            reader           = new BinaryReader(stream);
        }