コード例 #1
0
        /// <summary>
        /// Initializes instance of a network peer server.
        /// </summary>
        /// <param name="network">Specification of the network the node runs on - regtest/testnet/mainnet.</param>
        /// <param name="localEndPoint">IP address and port to listen on.</param>
        /// <param name="externalEndPoint">IP address and port that the server is reachable from the Internet on.</param>
        /// <param name="version">Version of the network protocol that the server should run.</param>
        /// <param name="loggerFactory">Factory for creating loggers.</param>
        /// <param name="networkPeerFactory">Factory for creating P2P network peers.</param>
        /// <param name="initialBlockDownloadState">Provider of IBD state.</param>
        /// <param name="connectionManagerSettings">Configuration related to incoming and outgoing connections.</param>
        public NetworkPeerServer(Network network,
                                 IPEndPoint localEndPoint,
                                 IPEndPoint externalEndPoint,
                                 ProtocolVersion version,
                                 ILoggerFactory loggerFactory,
                                 INetworkPeerFactory networkPeerFactory,
                                 IInitialBlockDownloadState initialBlockDownloadState,
                                 ConnectionManagerSettings connectionManagerSettings,
                                 IAsyncProvider asyncProvider)
        {
            this.logger                    = loggerFactory.CreateLogger(this.GetType().FullName, $"[{localEndPoint}] ");
            this.signals                   = asyncProvider.Signals;
            this.networkPeerFactory        = networkPeerFactory;
            this.networkPeerDisposer       = new NetworkPeerDisposer(loggerFactory, asyncProvider);
            this.initialBlockDownloadState = initialBlockDownloadState;
            this.connectionManagerSettings = connectionManagerSettings;

            this.InboundNetworkPeerConnectionParameters = new NetworkPeerConnectionParameters();

            this.LocalEndpoint    = Utils.EnsureIPv6(localEndPoint);
            this.ExternalEndpoint = Utils.EnsureIPv6(externalEndPoint);

            this.Network = network;
            this.Version = version;

            this.serverCancel = new CancellationTokenSource();

            this.tcpListener = new TcpListener(this.LocalEndpoint);
            this.tcpListener.Server.LingerState = new LingerOption(true, 0);
            this.tcpListener.Server.NoDelay     = true;
            this.tcpListener.Server.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, false);

            this.acceptTask = Task.CompletedTask;

            this.logger.LogDebug("Network peer server ready to listen on '{0}'.", this.LocalEndpoint);
        }
コード例 #2
0
 public KubernetesProbesController(IInitialBlockDownloadState idbStateAccessor)
 {
     _idbStateAccessor = idbStateAccessor;
 }
コード例 #3
0
        /// <summary>
        /// Initializes the cross-chain transfer tests.
        /// </summary>
        /// <param name="network">The network to run the tests for.</param>
        public CrossChainTestBase(Network network = null, Network counterChainNetwork = null)
        {
            this.network                    = network ?? CirrusNetwork.NetworksSelector.Regtest();
            this.counterChainNetwork        = counterChainNetwork ?? Networks.Stratis.Regtest();
            this.counterChainNetworkWrapper = new CounterChainNetworkWrapper(counterChainNetwork);

            NetworkRegistration.Register(this.network);

            this.loggerFactory = Substitute.For <ILoggerFactory>();
            this.nodeLifetime  = new NodeLifetime();
            this.logger        = Substitute.For <ILogger>();
            this.signals       = Substitute.For <ISignals>();
            this.asyncProvider = new AsyncProvider(this.loggerFactory, this.signals, this.nodeLifetime);
            this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger);
            this.dateTimeProvider                   = DateTimeProvider.Default;
            this.opReturnDataReader                 = new OpReturnDataReader(this.loggerFactory, this.counterChainNetworkWrapper);
            this.blockRepository                    = Substitute.For <IBlockRepository>();
            this.fullNode                           = Substitute.For <IFullNode>();
            this.withdrawalTransactionBuilder       = Substitute.For <IWithdrawalTransactionBuilder>();
            this.federationWalletManager            = Substitute.For <IFederationWalletManager>();
            this.federationWalletSyncManager        = Substitute.For <IFederationWalletSyncManager>();
            this.FederationWalletTransactionHandler = Substitute.For <IFederationWalletTransactionHandler>();
            this.walletFeePolicy                    = Substitute.For <IWalletFeePolicy>();
            this.connectionManager                  = Substitute.For <IConnectionManager>();
            this.federatedPegBroadcaster            = Substitute.For <IFederatedPegBroadcaster>();
            this.inputConsolidator                  = Substitute.For <IInputConsolidator>();
            this.dBreezeSerializer                  = new DBreezeSerializer(this.network.Consensus.ConsensusFactory);
            this.ibdState                           = Substitute.For <IInitialBlockDownloadState>();
            this.wallet = null;
            this.federatedPegSettings = Substitute.For <IFederatedPegSettings>();
            this.ChainIndexer         = new ChainIndexer(this.network);
            this.federatedPegSettings.GetWithdrawalTransactionFee(Arg.Any <int>()).ReturnsForAnyArgs((x) =>
            {
                int numInputs = x.ArgAt <int>(0);

                return(FederatedPegSettings.BaseTransactionFee + FederatedPegSettings.InputTransactionFee * numInputs);
            });

            // Generate the keys used by the federation members for our tests.
            this.federationKeys = new[]
            {
                "ensure feel swift crucial bridge charge cloud tell hobby twenty people mandate",
                "quiz sunset vote alley draw turkey hill scrap lumber game differ fiction",
                "exchange rent bronze pole post hurry oppose drama eternal voice client state"
            }.Select(m => HdOperations.GetExtendedKey(m)).ToArray();

            SetExtendedKey(0);

            this.fundingTransactions = new List <Transaction>();

            this.blockDict = new Dictionary <uint256, Block>();
            this.blockDict[this.network.GenesisHash] = this.network.GetGenesis();

            this.blockRepository.GetBlocks(Arg.Any <List <uint256> >()).ReturnsForAnyArgs((x) =>
            {
                List <uint256> hashes = x.ArgAt <List <uint256> >(0);
                var blocks            = new List <Block>();
                for (int i = 0; i < hashes.Count; i++)
                {
                    blocks.Add(this.blockDict.TryGetValue(hashes[i], out Block block) ? block : null);
                }

                return(blocks);
            });

            this.blockRepository.GetBlock(Arg.Any <uint256>()).ReturnsForAnyArgs((x) =>
            {
                uint256 hash = x.ArgAt <uint256>(0);
                this.blockDict.TryGetValue(hash, out Block block);

                return(block);
            });

            this.blockRepository.TipHashAndHeight.Returns((x) => {
                return(new HashHeightPair(this.blockDict.Last().Value.GetHash(), this.blockDict.Count - 1));
            });
        }
コード例 #4
0
        public RewardClaimer(IBroadcasterManager broadcasterManager, ChainIndexer chainIndexer, IConsensusManager consensusManager, ILoggerFactory loggerFactory, Network network, ISignals signals, IInitialBlockDownloadState initialBlockDownloadState)
        {
            this.broadcasterManager        = broadcasterManager;
            this.chainIndexer              = chainIndexer;
            this.consensusManager          = consensusManager;
            this.logger                    = loggerFactory.CreateLogger(this.GetType().FullName);
            this.network                   = network;
            this.signals                   = signals;
            this.initialBlockDownloadState = initialBlockDownloadState;

            this.blockConnectedSubscription = this.signals.Subscribe <BlockConnected>(this.OnBlockConnected);
        }
コード例 #5
0
 public PoAConsensusManagerBehavior(ChainIndexer chainIndexer, IInitialBlockDownloadState initialBlockDownloadState,
                                    IConsensusManager consensusManager, IPeerBanning peerBanning, ILoggerFactory loggerFactory)
     : base(chainIndexer, initialBlockDownloadState, consensusManager, peerBanning, loggerFactory)
 {
     this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $"[{this.GetHashCode():x}] ");
 }
コード例 #6
0
 public BlockStoreQueueFlushCondition(IChainState chainState, IInitialBlockDownloadState blockDownloadState)
 {
     this.chainState         = chainState;
     this.blockDownloadState = blockDownloadState;
 }
コード例 #7
0
 public FlushUtxosetRule(IInitialBlockDownloadState initialBlockDownloadState)
 {
     this.initialBlockDownloadState = initialBlockDownloadState;
 }
コード例 #8
0
 public CheckCollateralFullValidationRule(IInitialBlockDownloadState ibdState, ICollateralChecker collateralChecker, ISlotsManager slotsManager)
 {
     this.ibdState          = ibdState;
     this.collateralChecker = collateralChecker;
     this.slotsManager      = slotsManager;
 }
コード例 #9
0
 public FlushCoinviewRule(IInitialBlockDownloadState initialBlockDownloadState)
 {
     this.initialBlockDownloadState = initialBlockDownloadState;
 }
コード例 #10
0
 public JoinFederationRequestService(ICounterChainSettings counterChainSettings, IFederationManager federationManager, IFullNode fullNode, IInitialBlockDownloadState initialBlockDownloadState, IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory, Network network, NodeSettings nodeSettings, VotingManager votingManager)
 {
     this.counterChainSettings      = counterChainSettings;
     this.federationManager         = federationManager;
     this.fullNode                  = fullNode;
     this.initialBlockDownloadState = initialBlockDownloadState;
     this.httpClientFactory         = httpClientFactory;
     this.loggerFactory             = loggerFactory;
     this.network       = network as PoANetwork;
     this.nodeSettings  = nodeSettings;
     this.votingManager = votingManager;
 }