Example #1
0
        public void CommitBlock(BlockHandle handle, CommittedBlockId blockId)
        {
            var returnCode = PInvokes.cashdb_utxo_commit_block(_connection, handle, ref blockId);

            if (returnCode != ReturnCode.SUCCESS)
            {
                throw new CashDBException("CommitBlock failed.", returnCode);
            }
        }
Example #2
0
        public BlockHandle GetUncommittedBlock(UncommittedBlockId blockUcid)
        {
            var returnCode = PInvokes.cashdb_utxo_get_uncommitted_block(
                _connection, ref blockUcid, out BlockHandle handle);

            if (returnCode != ReturnCode.SUCCESS)
            {
                throw new CashDBException("GetUncommittedBlock failed.", returnCode);
            }

            return(handle);
        }
Example #3
0
        public void Dispose()
        {
            _connection.Dispose();

            lock (InitializationRoot)
            {
                if (--_clientCount == 0)
                {
                    PInvokes.cashdb_shutdown();
                }
            }
        }
Example #4
0
        public BlockInfo GetBlockInfo(BlockHandle handle)
        {
            var info       = new BlockInfo();
            var returnCode = PInvokes.cashdb_utxo_get_blockinfo(
                _connection, handle, ref info);

            if (returnCode != ReturnCode.SUCCESS)
            {
                throw new CashDBException("GetBlockInfo failed.", returnCode);
            }

            return(info);
        }
Example #5
0
        public BlockHandle OpenBlock(CommittedBlockId parent, out UncommittedBlockId ucid)
        {
            ucid = default;

            var returnCode = PInvokes.cashdb_utxo_open_block(
                _connection,
                ref parent,
                out BlockHandle handle,
                ref ucid);

            if (returnCode != ReturnCode.SUCCESS)
            {
                throw new CashDBException("OpenBlock failed.", returnCode);
            }

            return(handle);
        }
Example #6
0
        public CashDBClient(string connectionString)
        {
            lock (InitializationRoot)
            {
                if (++_clientCount == 1)
                {
                    var err = PInvokes.cashdb_initialize();
                    if (err != ReturnCode.SUCCESS)
                    {
                        throw new CashDBException("CashDB initialization failed.", err);
                    }
                }
            }

            var status = PInvokes.cashdb_connect(connectionString, out _connection);

            if (ReturnCode.SUCCESS != status)
            {
                throw new CashDBException("Invalid connection to a CashDB instance.", status);
            }
        }
Example #7
0
        protected override bool ReleaseHandle()
        {
            var returnCode = PInvokes.cashdb_disconnect(this, _reason);

            return(returnCode == ReturnCode.SUCCESS);
        }