private void StopNode()
        {
            BlockchainNode node = Client.Session.ManagedNodes.GetNode(ClientAction.FullNodeName);

            if (node == null)
            {
                logger.Error($"Cannot find node {ClientAction.FullNodeName}");
                return;
            }

            BlockchainNodeConfig config = BlockchainConfig.GetNodeConfig(node.NodeConfig.NodeConfigFullName);
            int apiPort = config.GetApiPort();

            BufferedRequestCaller.GetApiResult <string>(RequestType.ApiNodeShutdown, ClientAction.FullNodeName, apiPort);
        }
        private void GetNodeStatus(BlockchainNode node)
        {
            BlockchainNodeConfig config = BlockchainConfig.GetNodeConfig(node.NodeConfig.NodeConfigFullName);
            int apiPort = config.GetApiPort();

            NodeStatus nodeStatus = BufferedRequestCaller.GetApiResult <NodeStatus>(RequestType.ApiNodeStatus, node.NodeEndpoint.FullNodeName, apiPort);

            if (nodeStatus == null)
            {
                node.NodeState.NodeOperationState.State = ProcessState.Stopped;
                return;
            }

            node.NodeState.NodeOperationState.State = ProcessState.Running;

            node.NodeState.NodeOperationState.AgentName       = nodeStatus.Agent;
            node.NodeState.NodeOperationState.Version         = nodeStatus.Version;
            node.NodeState.NodeOperationState.Network         = nodeStatus.Network;
            node.NodeState.NodeOperationState.ConsensusHeight = nodeStatus.ConsensusHeight;

            node.NodeState.NodeOperationState.Peers.Clear();
            foreach (Peer inboundPeer in nodeStatus.InboundPeers)
            {
                ConnectionPeer peer = new ConnectionPeer();
                peer.PeerType             = PeerType.Inbound;
                peer.RemoteSocketEndpoint = inboundPeer.RemoteSocketEndpoint;
                peer.TipHeight            = inboundPeer.TipHeight;
                peer.Version = inboundPeer.Version;
                node.NodeState.NodeOperationState.Peers.Add(peer);
            }
            foreach (Peer outboundPeer in nodeStatus.OutboundPeers)
            {
                ConnectionPeer peer = new ConnectionPeer();
                peer.PeerType             = PeerType.Inbound;
                peer.RemoteSocketEndpoint = outboundPeer.RemoteSocketEndpoint;
                peer.TipHeight            = outboundPeer.TipHeight;
                peer.Version = outboundPeer.Version;
                node.NodeState.NodeOperationState.Peers.Add(peer);
            }

            node.NodeState.NodeOperationState.DataDirectory = nodeStatus.DataDirectoryPath;
            node.NodeState.NodeOperationState.Uptime        = nodeStatus.RunningTime;

            int maxInboundTipHeight  = nodeStatus.InboundPeers.Any() ? nodeStatus.InboundPeers.Max(p => p.TipHeight) : 0;
            int maxOutboundTipHeight = nodeStatus.OutboundPeers.Any() ? nodeStatus.OutboundPeers.Max(p => p.TipHeight) : 0;

            node.NodeState.NodeOperationState.NetworkHeight = Math.Max(maxInboundTipHeight, maxOutboundTipHeight);
        }