Ejemplo n.º 1
0
        private static int InternalTransactionHandler(IntPtr executor, IntPtr chain, IntPtr context, ErrorCode error, IntPtr transaction)
        {
            var handlerHandle    = (GCHandle)context;
            var closed           = false;
            var keepSubscription = false;

            try
            {
                if (ExecutorNative.executor_stopped(executor) != 0 || error == ErrorCode.ServiceStopped)
                {
                    handlerHandle.Free();
                    closed = true;
                    return(0);
                }

                var newTransaction = transaction != IntPtr.Zero? new Transaction(transaction) : null;
                var handler        = (handlerHandle.Target as TransactionHandler);

                keepSubscription = handler(error, newTransaction);

                if (!keepSubscription)
                {
                    handlerHandle.Free();
                    closed = true;
                }
                return(keepSubscription ? 1 : 0);
            }
            finally
            {
                if (!keepSubscription && !closed)
                {
                    handlerHandle.Free();
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                //Release managed resources and call Dispose for member variables
            }
            //Release unmanaged resources
            if (running_ && ExecutorNative.executor_stopped(nativeInstance_) != 0)
            {
                ExecutorNative.executor_stop(nativeInstance_);
            }
            ExecutorNative.executor_destruct(nativeInstance_);

#if KEOKEN
            keokenManager_?.Dispose();
#endif
        }
Ejemplo n.º 3
0
        private static int InternalBlockHandler(IntPtr executor, IntPtr chain, IntPtr context, ErrorCode error, UInt64 u, IntPtr incoming, IntPtr outgoing)
        {
            var handlerHandle    = (GCHandle)context;
            var closed           = false;
            var keepSubscription = false;

            try
            {
                if (ExecutorNative.executor_stopped(executor) != 0 || error == ErrorCode.ServiceStopped)
                {
                    handlerHandle.Free();
                    closed = true;
                    return(0);
                }

                var incomingBlocks = incoming != IntPtr.Zero? new BlockList(incoming) : null;
                var outgoingBlocks = outgoing != IntPtr.Zero? new BlockList(outgoing) : null;
                var handler        = (handlerHandle.Target as BlockHandler);

                keepSubscription = handler(error, u, incomingBlocks, outgoingBlocks);

                incomingBlocks?.Dispose();
                outgoingBlocks?.Dispose();

                if (!keepSubscription)
                {
                    handlerHandle.Free();
                    closed = true;
                }
                return(keepSubscription ? 1 : 0);
            }
            finally
            {
                if (!keepSubscription && !closed)
                {
                    handlerHandle.Free();
                }
            }
        }