Esempio n. 1
0
        public JsonResponse onStatus(Dictionary <string, object> parameters)
        {
            JsonError error = null;

            Dictionary <string, object> networkArray = new Dictionary <string, object>();

            networkArray.Add("Core Version", CoreConfig.version);
            networkArray.Add("Node Version", CoreConfig.productVersion);
            networkArray.Add("Network type", IxianHandler.networkType.ToString());
            networkArray.Add("My time", Clock.getTimestamp());
            networkArray.Add("Network time difference", Clock.networkTimeDifference);
            networkArray.Add("Real network time difference", Clock.realNetworkTimeDifference);
            networkArray.Add("My External IP", IxianHandler.publicIP);
            networkArray.Add("My Listening Port", IxianHandler.publicPort);
            //networkArray.Add("Listening interface", context.Request.RemoteEndPoint.Address.ToString());
            networkArray.Add("Node Deprecation Block Limit", Config.nodeDeprecationBlock);

            string dltStatus = "Active";

            if (Node.blockSync.synchronizing)
            {
                dltStatus = "Synchronizing";
            }

            if (Node.blockChain.getTimeSinceLastBLock() > 1800) // if no block for over 1800 seconds
            {
                dltStatus = "ErrorLongTimeNoBlock";
            }

            if (Node.blockProcessor.networkUpgraded)
            {
                dltStatus = "ErrorForkedViaUpgrade";
            }

            networkArray.Add("Update", checkUpdate());

            networkArray.Add("DLT Status", dltStatus);

            networkArray.Add("Core Status", IxianHandler.status);

            string bpStatus = "Stopped";

            if (Node.blockProcessor.operating)
            {
                bpStatus = "Running";
            }
            networkArray.Add("Block Processor Status", bpStatus);

            Block last_block = Node.blockChain.getLastBlock();

            if (last_block != null)
            {
                networkArray.Add("Block Height", last_block.blockNum);
                networkArray.Add("Block Version", last_block.version);
                networkArray.Add("Block Signature Count", last_block.getFrozenSignatureCount());
            }
            else
            {
                networkArray.Add("Block Height", 0);
                networkArray.Add("Block Version", 0);
                networkArray.Add("Block Signature Count", 1);
            }

            networkArray.Add("Network Block Height", IxianHandler.getHighestKnownNetworkBlockHeight());
            networkArray.Add("Node Type", PresenceList.myPresenceType);
            networkArray.Add("Connectable", NetworkServer.isConnectable());

            if (parameters.ContainsKey("vv") || parameters.ContainsKey("verbose"))
            {
                networkArray.Add("Required Consensus", Node.blockChain.getRequiredConsensus());

                networkArray.Add("Wallets", Node.walletState.numWallets);
                networkArray.Add("Presences", PresenceList.getTotalPresences());
                networkArray.Add("Supply", Node.walletState.calculateTotalSupply().ToString());
                networkArray.Add("Applied TX Count", TransactionPool.getAppliedTransactionCount());
                networkArray.Add("Unapplied TX Count", TransactionPool.getUnappliedTransactionCount());

                networkArray.Add("Masters", PresenceList.countPresences('M'));
                networkArray.Add("Relays", PresenceList.countPresences('R'));
                networkArray.Add("Clients", PresenceList.countPresences('C'));
            }

            if (parameters.ContainsKey("vv"))
            {
                Dictionary <string, object> queues = new Dictionary <string, object>();
                queues.Add("RcvLow", NetworkQueue.getLowPriorityMessageCount());
                queues.Add("RcvMedium", NetworkQueue.getMediumPriorityMessageCount());
                queues.Add("RcvHigh", NetworkQueue.getHighPriorityMessageCount());
                queues.Add("SendClients", NetworkServer.getQueuedMessageCount());
                queues.Add("SendServers", NetworkClientManager.getQueuedMessageCount());
                queues.Add("Logging", Logging.getRemainingStatementsCount());
                queues.Add("Pending Transactions", PendingTransactions.pendingTransactionCount());
                queues.Add("Storage", Node.storage.getQueuedQueryCount());
                queues.Add("Inventory", Node.inventoryCache.getItemCount());
                queues.Add("Inventory Processed", Node.inventoryCache.getProcessedItemCount());
                queues.Add("Activity", ActivityStorage.getQueuedQueryCount());

                networkArray.Add("Queues", queues);

                networkArray.Add("WS Checksum", Crypto.hashToString(Node.walletState.calculateWalletStateChecksum()));
            }

            networkArray.Add("Network Clients", NetworkServer.getConnectedClients());
            networkArray.Add("Network Servers", NetworkClientManager.getConnectedClients(true));

            return(new JsonResponse {
                result = networkArray, error = error
            });
        }