Exemplo n.º 1
0
 protected override bool ReleaseHandle()
 {
     PInvokes.terab_disconnect(this, reason);
     return(true); // TODO: it's probably not worth crashing the process because
                   // a (client) socket instance was not properly closed, but maybe
                   // we should report the issue somewhere
 }
Exemplo n.º 2
0
        internal Connection(string connectionString)
        {
            var status = PInvokes.terab_connect(connectionString, out _connection);

            if (PInvokes.ReturnCode.SUCCESS != status)
            {
                throw new Exception("invalid connection");
            }
        }
Exemplo n.º 3
0
        public static void Init()
        {
            var err = PInvokes.terab_initialize();

            if (err != PInvokes.ReturnCode.SUCCESS)
            {
                throw new Exception("Terab initialization failed with code " + err);
            }
        }
Exemplo n.º 4
0
        public Block UtxoGetBlock(byte[] /*32*/ blockId)
        {
            if (blockId.Length != 32)
            {
                throw new ArgumentException("must have 32 bytes", nameof(blockId));
            }

            PInvokes.terab_utxo_get_block(_connection, blockId, out int blockHandle);
            return(new Block(this, blockHandle));
        }
Exemplo n.º 5
0
        public BlockHandle OpenBlock(BlockHandle parent, out BlockUcid ucid)
        {
            var returnCode = PInvokes.terab_utxo_open_block(_connection, 0, out int handleAsInt, out PInvokes.BlockUcid blockUcid);

            if (returnCode != PInvokes.ReturnCode.SUCCESS)
            {
                throw new Exception(returnCode.ToString());
            }

            var ucidBytes = blockUcid.value;
            var left      = BitConverter.ToUInt64(ucidBytes, 0);
            var right     = BitConverter.ToUInt64(ucidBytes, 8);

            ucid = new BlockUcid(left, right);
            return(new BlockHandle(handleAsInt));
        }
Exemplo n.º 6
0
 public static void Shutdown()
 {
     PInvokes.terab_shutdown();
 }