示例#1
0
    protected override async Task ActionAsync(CancellationToken cancel)
    {
        Logger.LogInfo("Trying to reconnect to P2P...");
        if (await P2pNode.TryDisconnectAsync(cancel).ConfigureAwait(false))
        {
            await P2pNode.ConnectAsync(cancel).ConfigureAwait(false);

            Logger.LogInfo("Successfully reconnected to P2P.");
            Success.TrySetResult(true);
        }
    }
示例#2
0
        private async Task InitializeP2pAsync(Network network, EndPoint endPoint, CancellationToken cancel)
        {
            Guard.NotNull(nameof(network), network);
            Guard.NotNull(nameof(endPoint), endPoint);

            // We have to find it, because it's cloned by the node and not perfectly cloned (event handlers cannot be cloned.)
            P2pNode = new P2pNode(network, endPoint, new MempoolService(), $"/WasabiCoordinator:{Constants.BackendMajorVersion}/");
            await P2pNode.ConnectAsync(cancel).ConfigureAwait(false);

            HostedServices.Register(new BlockNotifier(TimeSpan.FromSeconds(7), RpcClient, P2pNode), "Block Notifier");
        }
        protected override async Task ActionAsync(CancellationToken cancel)
        {
            try
            {
                Logger.LogInfo("Trying to reconnect to P2P...");
                P2pNode.Disconnect();
                await P2pNode.ConnectAsync(cancel).ConfigureAwait(false);
            }
            catch
            {
                P2pNode.Disconnect();
                throw;
            }

            Logger.LogInfo("Successfully reconnected to P2P.");

            Success.TrySetResult(null);
        }