Exemple #1
0
        public async Task DialPeerAsync_HostAlreadyInPool_ShouldReturnFalse()
        {
            var peer  = AddPeerToPool();
            var added = await _networkServer.ConnectAsync(peer.RemoteEndpoint);

            added.ShouldBeFalse();
        }
Exemple #2
0
        public async Task <bool> AddPeerAsync(string address)
        {
            if (IpEndPointHelper.TryParse(address, out IPEndPoint endpoint))
            {
                return(await _networkServer.ConnectAsync(endpoint));
            }

            return(false);
        }
Exemple #3
0
        public async Task <bool> AddPeerAsync(string address)
        {
            if (AElfPeerEndpointHelper.TryParse(address, out DnsEndPoint endpoint))
            {
                return(await _networkServer.ConnectAsync(endpoint));
            }

            Logger.LogWarning($"Could not parse endpoint {address}.");

            return(false);
        }
        private async Task <bool> TryAddPeerAsync(string endpoint, bool isTrusted)
        {
            if (!AElfPeerEndpointHelper.TryParse(endpoint, out var aelfPeerEndpoint))
            {
                Logger.LogDebug($"Could not parse endpoint {endpoint}.");
                return(false);
            }

            if (isTrusted)
            {
                _blackListedPeerProvider.RemoveHostFromBlackList(aelfPeerEndpoint.Host);
            }

            return(await _networkServer.ConnectAsync(aelfPeerEndpoint));
        }