public INetworkPeer CreateNetworkPeerClient()
        {
            ConnectionManagerSettings connectionManagerSettings = null;

            if (this.runner is BitcoinCoreRunner)
            {
                var nodeSettings = new NodeSettings(this.runner.Network, args: new string[] { "-conf=bitcoin.conf", "-datadir=" + this.runner.DataFolder });
                connectionManagerSettings = new ConnectionManagerSettings(nodeSettings);
            }
            else
            {
                connectionManagerSettings = this.runner.FullNode.ConnectionManager.ConnectionSettings;
            }

            var selfEndPointTracker = new SelfEndpointTracker(this.loggerFactory, connectionManagerSettings);

            // Needs to be initialized beforehand.
            selfEndPointTracker.UpdateAndAssignMyExternalAddress(new IPEndPoint(IPAddress.Parse("0.0.0.0").MapToIPv6Ex(), this.ProtocolPort), false);

            var ibdState = new Mock <IInitialBlockDownloadState>();

            ibdState.Setup(x => x.IsInitialBlockDownload()).Returns(() => true);

            var networkPeerFactory = new NetworkPeerFactory(this.runner.Network,
                                                            DateTimeProvider.Default,
                                                            this.loggerFactory,
                                                            new PayloadProvider().DiscoverPayloads(),
                                                            selfEndPointTracker,
                                                            ibdState.Object,
                                                            connectionManagerSettings,
                                                            this.GetOrCreateAsyncProvider()
                                                            );

            return(networkPeerFactory.CreateConnectedNetworkPeerAsync("127.0.0.1:" + this.ProtocolPort).ConfigureAwait(false).GetAwaiter().GetResult());
        }
Example #2
0
        public INetworkPeer CreateNetworkPeerClient()
        {
            var loggerFactory = new ExtendedLoggerFactory();

            loggerFactory.AddConsoleWithFilters();

            var selfEndPointTracker = new SelfEndpointTracker(loggerFactory);

            // Needs to be initialized beforehand.
            selfEndPointTracker.UpdateAndAssignMyExternalAddress(new IPEndPoint(IPAddress.Parse("0.0.0.0").MapToIPv6Ex(), this.ProtocolPort), false);

            var ibdState = new Mock <IInitialBlockDownloadState>();

            ibdState.Setup(x => x.IsInitialBlockDownload()).Returns(() => true);

            var networkPeerFactory = new NetworkPeerFactory(this.runner.Network,
                                                            DateTimeProvider.Default,
                                                            loggerFactory,
                                                            new PayloadProvider().DiscoverPayloads(),
                                                            selfEndPointTracker,
                                                            ibdState.Object,
                                                            new Configuration.Settings.ConnectionManagerSettings());

            return(networkPeerFactory.CreateConnectedNetworkPeerAsync("127.0.0.1:" + this.ProtocolPort).GetAwaiter().GetResult());
        }
Example #3
0
        public INetworkPeer CreateNetworkPeerClient()
        {
            var loggerFactory = new ExtendedLoggerFactory();

            loggerFactory.AddConsoleWithFilters();

            var selfEndPointTracker = new SelfEndpointTracker(loggerFactory);

            // Needs to be initialized beforehand.
            selfEndPointTracker.UpdateAndAssignMyExternalAddress(new IPEndPoint(IPAddress.Parse("0.0.0.0").MapToIPv6Ex(), this.ProtocolPort), false);

            var networkPeerFactory = new NetworkPeerFactory(this.runner.Network, DateTimeProvider.Default, loggerFactory, new PayloadProvider().DiscoverPayloads(), selfEndPointTracker);

            return(networkPeerFactory.CreateConnectedNetworkPeerAsync("127.0.0.1:" + this.ProtocolPort).GetAwaiter().GetResult());
        }