private async Task ProcessNodeAsync(NodeInfo node)
        {
            try
            {
                if (!await ValidateNodeAsync(node))
                {
                    return;
                }

                if (await _nodeManager.AddNodeAsync(node))
                {
                    _discoveredNodeCacheProvider.Add(node.Endpoint);
                    Logger.LogDebug($"Discover and add node: {node.Endpoint} successfully.");
                }
                else
                {
                    var endpointLocal = await TakeEndpointFromDiscoveredNodeCacheAsync();

                    if (endpointLocal.IsNullOrWhiteSpace())
                    {
                        return;
                    }

                    if (await _networkServer.CheckEndpointAvailableAsync(endpointLocal))
                    {
                        _discoveredNodeCacheProvider.Add(endpointLocal);
                        Logger.LogDebug($"Only refresh node: {endpointLocal}.");
                    }
                    else
                    {
                        await _nodeManager.RemoveNodeAsync(endpointLocal);

                        if (await _nodeManager.AddNodeAsync(node))
                        {
                            _discoveredNodeCacheProvider.Add(node.Endpoint);
                        }

                        Logger.LogDebug(
                            $"Remove unavailable node: {endpointLocal}, and add node: {node.Endpoint} successfully.");
                    }
                }
            }
            catch (Exception e)
            {
                Logger.LogWarning(e, "Process node failed.");
            }
        }
        public static async Task <bool> CheckEndpointAvailableAsync(this IAElfNetworkServer networkServer,
                                                                    string endpoint)
        {
            if (!AElfPeerEndpointHelper.TryParse(endpoint, out var aelfPeerEndpoint))
            {
                return(false);
            }

            return(await networkServer.CheckEndpointAvailableAsync(aelfPeerEndpoint));
        }
        public async Task RefreshNodeAsync()
        {
            var endpoint = await TakeEndpointFromDiscoveredNodeCacheAsync();

            if (endpoint != null)
            {
                if (await _aelfNetworkServer.CheckEndpointAvailableAsync(endpoint))
                {
                    _discoveredNodeCacheProvider.Add(endpoint);
                    Logger.LogDebug($"Refresh node successfully: {endpoint}");
                }
                else
                {
                    await _nodeManager.RemoveNodeAsync(endpoint);

                    Logger.LogDebug($"Clean unavailable node: {endpoint}");
                }
            }
        }