コード例 #1
0
        public override bool getBlocks(List <Hash> blockHashes, List <BlockDetails> blocks)
        {
            if (state.load() != State.INITIALIZED)
            {
                throw std::system_error(GlobalMembers.make_error_code(CryptoNote.error.BlockchainExplorerErrorCodes.NOT_INITIALIZED));
            }

            if (blockHashes.Count == 0)
            {
                return(true);
            }

            logger.functorMethod(DEBUGGING) << "Get blocks by hash request came.";
            NodeRequest new request((INodeOriginal.Callback cb) =>
            {
                node.getBlocks(blockHashes, blocks, cb);
            });
            std::error_code ec = request.performBlocking();

            if (ec != null)
            {
                logger.functorMethod(ERROR) << "Can't get blocks by hash: " << ec.message();
                throw std::system_error(ec);
            }

            Debug.Assert(blocks.Count == blockHashes.Count);
            return(true);
        }
コード例 #2
0
        public override bool getPoolState(List <Hash> knownPoolTransactionHashes, Hash knownBlockchainTopHash, ref bool isBlockchainActual, List <TransactionDetails> newTransactions, List <Hash> removedTransactions)
        {
            if (state.load() != State.INITIALIZED)
            {
                throw std::system_error(GlobalMembers.make_error_code(CryptoNote.error.BlockchainExplorerErrorCodes.NOT_INITIALIZED));
            }

            logger.functorMethod(DEBUGGING) << "Get pool state request came.";
            List <std::unique_ptr <ITransactionReader> > rawNewTransactions = new List <std::unique_ptr <ITransactionReader> >();

            NodeRequest new request((INodeOriginal.Callback callback) =>
            {
                List <Hash> hashes = new List <Hash>();
                foreach (Hash hash in knownPoolTransactionHashes)
                {
                    hashes.Add(std::move(hash));
                }

                node.getPoolSymmetricDifference(std::move(hashes), reinterpret_cast <Hash&>(knownBlockchainTopHash), ref isBlockchainActual, rawNewTransactions, removedTransactions, callback);
            });
            std::error_code ec = request.performBlocking();

            if (ec != null)
            {
                logger.functorMethod(ERROR) << "Can't get pool state: " << ec.message();
                throw std::system_error(ec);
            }

            List <Hash> newTransactionsHashes = new List <Hash>();

            foreach (var rawTransaction in rawNewTransactions)
            {
                Hash transactionHash = rawTransaction.getTransactionHash();
                newTransactionsHashes.Add(std::move(transactionHash));
            }

            return(getTransactions(newTransactionsHashes, newTransactions));
        }
コード例 #3
0
        protected static void makeErrorResponse(std::error_code ec, Common.JsonValue resp)
        {
            JsonValue error = new JsonValue(JsonValue.OBJECT);

            JsonValue code = new JsonValue();

            code = (long)CryptoNote.JsonRpc.errParseError; //Application specific error code

            JsonValue message = new JsonValue();

            message = ec.message();

            JsonValue data    = new JsonValue(JsonValue.OBJECT);
            JsonValue appCode = new JsonValue();

            appCode = (long)ec.value();
            data.insert("application_code", appCode);

            error.insert("code", code);
            error.insert("message", message);
            error.insert("data", data);

            resp.insert.functorMethod("error", error);
        }
コード例 #4
0
        public override bool isSynchronized()
        {
            if (state.load() != State.INITIALIZED)
            {
                throw std::system_error(GlobalMembers.make_error_code(CryptoNote.error.BlockchainExplorerErrorCodes.NOT_INITIALIZED));
            }

            logger.functorMethod(DEBUGGING) << "Synchronization status request came.";
            bool syncStatus = false;

            NodeRequest new request((INodeOriginal.Callback cb) =>
            {
                node.isSynchronized(ref syncStatus, cb);
            });
            std::error_code ec = request.performBlocking();

            if (ec != null)
            {
                logger.functorMethod(ERROR) << "Can't get synchronization status: " << ec.message();
                throw std::system_error(ec);
            }

            synchronized.store(syncStatus);
            return(syncStatus);
        }