private std::error_code getGlobalIndices(Hash transactionHash, List <uint> outsGlobalIndices)
        {
            std::promise <std::error_code> prom = new std::promise <std::error_code>();
            std::future <std::error_code>  f    = prom.get_future();

            INodeOriginal.Callback cb = (std::error_code ec) =>
            {
                std::promise <std::error_code> p = new std::promise <std::error_code>(std::move(prom));
                p.set_value(ec);
            };

            outsGlobalIndices.Clear();
            m_node.getTransactionOutsGlobalIndices(transactionHash, outsGlobalIndices, cb);

            return(f.get());
        }
Example #2
0
        public override std::future removeUnconfirmedTransaction(Crypto.Hash transactionHash)
        {
            m_logger.functorMethod(INFO, BRIGHT_WHITE) << "Removing unconfirmed transaction, hash " << transactionHash;

            std::unique_lock <object> @lock = new std::unique_lock <object>(m_stateMutex);

            if (m_currentState == State.stopped || m_futureState == State.stopped)
            {
                var message = "Failed to remove unconfirmed transaction: not stopped";
                m_logger.functorMethod(ERROR, BRIGHT_RED) << message << ", hash " << transactionHash;
                throw new System.Exception(message);
            }

            std::promise promise = new std::promise();
            var          future  = promise.get_future();

            m_removeTransactionTasks.emplace_back(transactionHash, std::move(promise));
            m_hasWork.notify_one();

            return(future);
        }
Example #3
0
        public override std::future <std::error_code> addUnconfirmedTransaction(ITransactionReader transaction)
        {
            m_logger.functorMethod(INFO, BRIGHT_WHITE) << "Adding unconfirmed transaction, hash " << transaction.GetTransactionHash();

            std::unique_lock <object> @lock = new std::unique_lock <object>(m_stateMutex);

            if (m_currentState == State.stopped || m_futureState == State.stopped)
            {
                var message = "Failed to add unconfirmed transaction: not stopped";
                m_logger.functorMethod(ERROR, BRIGHT_RED) << message << ", hash " << transaction.GetTransactionHash();
                throw new System.Exception(message);
            }

            std::promise <std::error_code> promise = new std::promise <std::error_code>();
            var future = promise.get_future();

            m_addTransactionTasks.emplace_back(transaction, std::move(promise));
            m_hasWork.notify_one();

            return(future);
        }