Exemple #1
0
            public TestContext(Network network)
            {
                this.dnsServer        = new Mock <IDnsServer>();
                this.whitelistManager = new Mock <IWhitelistManager>();

                var logger = new Mock <ILogger>(MockBehavior.Loose);

                this.loggerFactory = new Mock <ILoggerFactory>();
                this.loggerFactory.Setup <ILogger>(f => f.CreateLogger(It.IsAny <string>())).Returns(logger.Object);

                this.nodeLifetime           = new Mock <INodeLifetime>();
                this.nodeSettings           = new NodeSettings(network, args: new string[] { $"-datadir={Directory.GetCurrentDirectory()}" });
                this.dnsSettings            = new DnsSettings(this.nodeSettings);
                this.dataFolder             = CreateDataFolder(this);
                this.asyncLoopFactory       = new Mock <IAsyncLoopFactory>().Object;
                this.connectionManager      = this.BuildConnectionManager();
                this.unreliablePeerBehavior = this.BuildUnreliablePeerBehavior();
            }
        public PeerDiscoveryLoop(
            IAsyncLoopFactory asyncLoopFactory,
            Network network,
            NetworkPeerConnectionParameters connectionParameters,
            INodeLifetime nodeLifetime,
            IPeerAddressManager peerAddressManager,
            INetworkPeerFactory networkPeerFactory)
        {
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));

            this.asyncLoopFactory   = asyncLoopFactory;
            this.parameters         = connectionParameters;
            this.peerAddressManager = peerAddressManager;
            this.peersToFind        = this.parameters.PeerAddressManagerBehaviour().PeersToDiscover;
            this.network            = network;
            this.nodeLifetime       = nodeLifetime;
            this.networkPeerFactory = networkPeerFactory;
        }
Exemple #3
0
 public PeerDiscovery(
     IAsyncLoopFactory asyncLoopFactory,
     ILoggerFactory loggerFactory,
     Network network,
     INetworkPeerFactory networkPeerFactory,
     INodeLifetime nodeLifetime,
     NodeSettings nodeSettings,
     IPeerAddressManager peerAddressManager)
 {
     this.asyncLoopFactory   = asyncLoopFactory;
     this.loggerFactory      = loggerFactory;
     this.logger             = this.loggerFactory.CreateLogger(this.GetType().FullName);
     this.peerAddressManager = peerAddressManager;
     this.network            = network;
     this.networkPeerFactory = networkPeerFactory;
     this.nodeLifetime       = nodeLifetime;
     this.nodeSettings       = nodeSettings;
 }
Exemple #4
0
 /// <summary>Parameterless constructor for dependency injection.</summary>
 protected PeerConnector(
     IAsyncLoopFactory asyncLoopFactory,
     ILoggerFactory loggerFactory,
     Network network,
     INetworkPeerFactory networkPeerFactory,
     INodeLifetime nodeLifetime,
     NodeSettings nodeSettings,
     IPeerAddressManager peerAddressManager)
 {
     this.asyncLoopFactory   = asyncLoopFactory;
     this.ConnectedPeers     = new NetworkPeerCollection();
     this.loggerFactory      = loggerFactory;
     this.network            = network;
     this.networkPeerFactory = networkPeerFactory;
     this.nodeLifetime       = nodeLifetime;
     this.NodeSettings       = nodeSettings;
     this.peerAddressManager = peerAddressManager;
 }
Exemple #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DnsFeature"/> class.
        /// </summary>
        /// <param name="dnsServer">The DNS server.</param>
        /// <param name="whitelistManager">The whitelist manager.</param>
        /// <param name="loggerFactory">The factory to create the logger.</param>
        /// <param name="nodeLifetime">The node lifetime object used for graceful shutdown.</param>
        /// <param name="nodeSettings">The node settings object containing node configuration.</param>
        /// <param name="dataFolders">The data folders of the system.</param>
        /// <param name="asyncLoopFactory">The asynchronous loop factory.</param>
        public DnsFeature(IDnsServer dnsServer, IWhitelistManager whitelistManager, ILoggerFactory loggerFactory, INodeLifetime nodeLifetime, DnsSettings dnsSettings, NodeSettings nodeSettings, DataFolder dataFolders, IAsyncLoopFactory asyncLoopFactory)
        {
            Guard.NotNull(dnsServer, nameof(dnsServer));
            Guard.NotNull(whitelistManager, nameof(whitelistManager));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(nodeSettings, nameof(nodeSettings));
            Guard.NotNull(dataFolders, nameof(dataFolders));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));

            this.dnsServer        = dnsServer;
            this.whitelistManager = whitelistManager;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.asyncLoopFactory = asyncLoopFactory;
            this.nodeLifetime     = nodeLifetime;
            this.dnsSettings      = DnsSettings.Load(nodeSettings, dnsSettings);
            this.dataFolders      = dataFolders;
        }
        public ConsensusFeature(
            IAsyncLoopFactory asyncLoopFactory,
            DBreezeCoinView dBreezeCoinView,
            Network network,
            PowConsensusValidator consensusValidator,
            ConcurrentChain chain,
            LookaheadBlockPuller blockPuller,
            CoinView coinView,
            ChainState chainState,
            IConnectionManager connectionManager,
            INodeLifetime nodeLifetime,
            Signals.Signals signals,
            ConsensusLoop consensusLoop,
            NodeSettings nodeSettings,
            NodeDeployments nodeDeployments,
            ILoggerFactory loggerFactory,
            IDateTimeProvider dateTimeProvider,
            ConsensusManager consensusManager,
            ConsensusStats consensusStats,
            StakeChainStore stakeChain = null)
        {
            this.dBreezeCoinView    = dBreezeCoinView;
            this.consensusValidator = consensusValidator;
            this.chain             = chain;
            this.blockPuller       = blockPuller;
            this.coinView          = coinView;
            this.chainState        = chainState;
            this.connectionManager = connectionManager;
            this.nodeLifetime      = nodeLifetime;
            this.signals           = signals;
            this.network           = network;
            this.consensusLoop     = consensusLoop;
            this.nodeSettings      = nodeSettings;
            this.nodeDeployments   = nodeDeployments;
            this.stakeChain        = stakeChain;
            this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory     = loggerFactory;
            this.dateTimeProvider  = dateTimeProvider;
            this.consensusManager  = consensusManager;
            this.consensusStats    = consensusStats;

            this.chainState.MaxReorgLength = this.network.Consensus.Option <PowConsensusOptions>().MaxReorgLength;
        }
        public BaseFeature(ServerSettings serverSettings,
                           DataFolder dataFolder,
                           IX42ServerLifetime serverLifetime,
                           IDateTimeProvider dateTimeProvider,
                           IAsyncLoopFactory asyncLoopFactory,
                           ILoggerFactory loggerFactory,
                           X42Server network)
        {
            this.serverSettings = Guard.NotNull(serverSettings, nameof(serverSettings));
            this.dataFolder     = Guard.NotNull(dataFolder, nameof(dataFolder));
            this.serverLifetime = Guard.NotNull(serverLifetime, nameof(serverLifetime));
            this.network        = network;


            this.dateTimeProvider = dateTimeProvider;
            this.asyncLoopFactory = asyncLoopFactory;
            this.loggerFactory    = loggerFactory;
            logger = loggerFactory.CreateLogger(GetType().FullName);
        }
Exemple #8
0
 public PowMining(
     ConsensusLoop consensusLoop,
     ConcurrentChain chain,
     Network network,
     MinerSettings minerSettings,
     AssemblerFactory blockAssemblerFactory,
     INodeLifetime nodeLifetime,
     IAsyncLoopFactory asyncLoopFactory,
     ILoggerFactory loggerFactory)
 {
     this.consensusLoop         = consensusLoop;
     this.minerSettings         = minerSettings;
     this.chain                 = chain;
     this.network               = network;
     this.blockAssemblerFactory = blockAssemblerFactory;
     this.nodeLifetime          = nodeLifetime;
     this.asyncLoopFactory      = asyncLoopFactory;
     this.logger                = loggerFactory.CreateLogger(this.GetType().FullName);
 }
Exemple #9
0
 public LightWalletSyncManager(
     ILoggerFactory loggerFactory,
     IWalletManager walletManager,
     ConcurrentChain chain,
     Network network,
     BlockNotification blockNotification,
     Signals signals,
     INodeLifetime nodeLifetime,
     IAsyncLoopFactory asyncLoopFactory)
 {
     this.walletManager     = walletManager as WalletManager;
     this.chain             = chain;
     this.signals           = signals;
     this.blockNotification = blockNotification;
     this.coinType          = (CoinType)network.Consensus.CoinType;
     this.logger            = loggerFactory.CreateLogger(this.GetType().FullName);
     this.nodeLifetime      = nodeLifetime;
     this.asyncLoopFactory  = asyncLoopFactory;
 }
Exemple #10
0
        /// <summary>Peer connector initialization as called by the <see cref="Connection.ConnectionManager"/>.</summary>
        public void Initialize(
            IAsyncLoopFactory asyncLoopFactory,
            ILogger logger,
            Network network,
            INetworkPeerFactory networkPeerFactory,
            INodeLifetime nodeLifeTime,
            NodeSettings nodeSettings,
            IPeerAddressManager peerAddressManager)
        {
            this.asyncLoopFactory   = asyncLoopFactory;
            this.ConnectedPeers     = new NetworkPeerCollection();
            this.network            = network;
            this.networkPeerFactory = networkPeerFactory;
            this.nodeLifetime       = nodeLifeTime;
            this.NodeSettings       = nodeSettings;
            this.peerAddressManager = peerAddressManager;

            OnInitialize();
        }
Exemple #11
0
        public FederationWalletManager(
            ILoggerFactory loggerFactory,
            Network network,
            ConcurrentChain chain,
            NodeSettings settings, DataFolder dataFolder,
            IWalletFeePolicy walletFeePolicy,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime,
            IDateTimeProvider dateTimeProvider,
            FederationGatewaySettings federationGatewaySettings,
            IBroadcasterManager broadcasterManager = null) // no need to know about transactions the node broadcasted
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(network, nameof(network));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(settings, nameof(settings));
            Guard.NotNull(dataFolder, nameof(dataFolder));
            Guard.NotNull(walletFeePolicy, nameof(walletFeePolicy));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.lockObject = new object();

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);

            this.network                   = network;
            this.coinType                  = (CoinType)network.Consensus.CoinType;
            this.chain                     = chain;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.nodeLifetime              = nodeLifetime;
            this.fileStorage               = new FileStorage <FederationWallet>(dataFolder.WalletPath);
            this.broadcasterManager        = broadcasterManager;
            this.dateTimeProvider          = dateTimeProvider;
            this.federationGatewaySettings = federationGatewaySettings;
            this.outpointLookup            = new Dictionary <OutPoint, TransactionData>();

            // register events
            if (this.broadcasterManager != null)
            {
                this.broadcasterManager.TransactionStateChanged += this.BroadcasterManager_TransactionStateChanged;
            }
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the object.
        /// </summary>
        /// <param name="nodeSettings">User defined node settings.</param>
        /// <param name="dataFolder">Locations of important folders and files on disk.</param>
        /// <param name="nodeLifetime">Global application life cycle control - triggers when application shuts down.</param>
        /// <param name="chain">Thread safe access to the best chain of block headers (that the node is aware of) from genesis.</param>
        /// <param name="chainState">Information about node's chain.</param>
        /// <param name="connectionManager">Manager of node's network connections.</param>
        /// <param name="finalizedBlockHeight"><inheritdoc cref="IFinalizedBlockHeight"/></param>
        /// <param name="chainRepository">Access to the database of blocks.</param>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="asyncLoopFactory">Factory for creating background async loop tasks.</param>
        /// <param name="timeSyncBehaviorState">State of time synchronization feature that stores collected data samples.</param>
        /// <param name="dbreezeSerializer">Provider of binary (de)serialization for data stored in the database.</param>
        /// <param name="loggerFactory">Factory to be used to create logger for the node.</param>
        /// <param name="initialBlockDownloadState">Provider of IBD state.</param>
        /// <param name="bestChainSelector">Selects the best available chain based on tips provided by the peers and switches to it.</param>
        public BaseFeature(
            NodeSettings nodeSettings,
            DataFolder dataFolder,
            INodeLifetime nodeLifetime,
            ConcurrentChain chain,
            IChainState chainState,
            IConnectionManager connectionManager,
            IChainRepository chainRepository,
            IFinalizedBlockHeight finalizedBlockHeight,
            IDateTimeProvider dateTimeProvider,
            IAsyncLoopFactory asyncLoopFactory,
            ITimeSyncBehaviorState timeSyncBehaviorState,
            DBreezeSerializer dbreezeSerializer,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState initialBlockDownloadState,
            IPeerBanning peerBanning,
            IPeerAddressManager peerAddressManager,
            BestChainSelector bestChainSelector)
        {
            this.chainState           = Guard.NotNull(chainState, nameof(chainState));
            this.chainRepository      = Guard.NotNull(chainRepository, nameof(chainRepository));
            this.finalizedBlockHeight = Guard.NotNull(finalizedBlockHeight, nameof(finalizedBlockHeight));
            this.nodeSettings         = Guard.NotNull(nodeSettings, nameof(nodeSettings));
            this.dataFolder           = Guard.NotNull(dataFolder, nameof(dataFolder));
            this.nodeLifetime         = Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            this.chain             = Guard.NotNull(chain, nameof(chain));
            this.connectionManager = Guard.NotNull(connectionManager, nameof(connectionManager));
            this.bestChainSelector = bestChainSelector;
            this.peerBanning       = Guard.NotNull(peerBanning, nameof(peerBanning));

            this.peerAddressManager = Guard.NotNull(peerAddressManager, nameof(peerAddressManager));
            this.peerAddressManager.PeerFilePath = this.dataFolder;

            this.initialBlockDownloadState = initialBlockDownloadState;
            this.dateTimeProvider          = dateTimeProvider;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.timeSyncBehaviorState     = timeSyncBehaviorState;
            this.loggerFactory             = loggerFactory;
            this.dbreezeSerializer         = dbreezeSerializer;
            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.disposableResources = new List <IDisposable>();
        }
Exemple #13
0
 public PriceFeature(
     ServerNodeBase network,
     ILoggerFactory loggerFactory,
     DatabaseSettings databaseSettings,
     IxServerLifetime serverLifetime,
     IAsyncLoopFactory asyncLoopFactory,
     DatabaseFeatures database,
     NetworkFeatures networkFeatures,
     XServer xServer
     )
 {
     this.network          = network;
     logger                = loggerFactory.CreateLogger(GetType().FullName);
     this.databaseSettings = databaseSettings;
     this.serverLifetime   = serverLifetime;
     this.asyncLoopFactory = asyncLoopFactory;
     this.database         = database;
     this.networkFeatures  = networkFeatures;
     this.xServer          = xServer;
 }
Exemple #14
0
 /// <summary>Constructor used by <see cref="Connection.ConnectionManager"/>.</summary>
 public PeerConnectorDiscovery(
     IAsyncLoopFactory asyncLoopFactory,
     ILogger logger,
     Network network,
     INetworkPeerFactory networkPeerFactory,
     INodeLifetime nodeLifeTime,
     NodeSettings nodeSettings,
     NetworkPeerConnectionParameters parameters,
     IPeerAddressManager peerAddressManager)
     :
     base(asyncLoopFactory, logger, network, networkPeerFactory, nodeLifeTime, nodeSettings, parameters, peerAddressManager)
 {
     this.GroupSelector          = WellKnownPeerConnectorSelectors.ByNetwork;
     this.MaximumNodeConnections = 8;
     this.Requirements           = new NetworkPeerRequirement
     {
         MinVersion       = nodeSettings.ProtocolVersion,
         RequiredServices = NetworkPeerServices.Network
     };
 }
Exemple #15
0
        public NetworkMonitor(
            ILogger mainLogger,
            IxServerLifetime serverLifetime,
            IAsyncLoopFactory asyncLoopFactory,
            DatabaseSettings databaseSettings,
            NetworkFeatures networkFeatures,
            ServerNodeBase network,
            NetworkSettings networkSettings
            )
        {
            logger = mainLogger;
            this.serverLifetime   = serverLifetime;
            this.asyncLoopFactory = asyncLoopFactory;
            this.databaseSettings = databaseSettings;
            this.networkFeatures  = networkFeatures;
            this.network          = network;
            this.networkSettings  = networkSettings;

            NetworkStartupStatus = StartupStatus.NotStarted;
        }
Exemple #16
0
        public SignedMultisigTransactionBroadcaster(
            IAsyncLoopFactory asyncLoopFactory,
            ILoggerFactory loggerFactory,
            ICrossChainTransferStore store,
            INodeLifetime nodeLifetime,
            MempoolManager mempoolManager, IBroadcasterManager broadcasterManager)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(store, nameof(store));
            Guard.NotNull(mempoolManager, nameof(mempoolManager));
            Guard.NotNull(broadcasterManager, nameof(broadcasterManager));


            this.asyncLoopFactory   = asyncLoopFactory;
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.store              = store;
            this.nodeLifetime       = nodeLifetime;
            this.mempoolManager     = mempoolManager;
            this.broadcasterManager = broadcasterManager;
        }
        public PosMinting(
            ConsensusLoop consensusLoop,
            ConcurrentChain chain,
            Network network,
            IConnectionManager connection,
            IDateTimeProvider dateTimeProvider,
            AssemblerFactory blockAssemblerFactory,
            BlockRepository blockRepository,
            ChainState chainState,
            Signals.Signals signals, INodeLifetime nodeLifetime,
            NodeSettings settings,
            CoinView coinView,
            StakeChain stakeChain,
            IWalletManager wallet,
            IAsyncLoopFactory asyncLoopFactory,
            ILoggerFactory loggerFactory)
        {
            this.consensusLoop         = consensusLoop;
            this.chain                 = chain;
            this.network               = network;
            this.connection            = connection;
            this.dateTimeProvider      = dateTimeProvider;
            this.blockAssemblerFactory = blockAssemblerFactory;
            this.blockRepository       = blockRepository;
            this.chainState            = chainState;
            this.signals               = signals;
            this.nodeLifetime          = nodeLifetime;
            this.settings              = settings;
            this.coinView              = coinView;
            this.stakeChain            = stakeChain;
            this.asyncLoopFactory      = asyncLoopFactory;
            this.wallet                = wallet as WalletManager;
            this.logger                = loggerFactory.CreateLogger(this.GetType().FullName);

            this.minerSleep = 500;                                                                          // GetArg("-minersleep", 500);
            this.lastCoinStakeSearchTime = Utils.DateTimeToUnixTime(this.dateTimeProvider.GetTimeOffset()); // startup timestamp
            this.reserveBalance          = 0;                                                               // TOOD:settings.ReserveBalance
            this.minimumInputValue       = 0;

            this.posConsensusValidator = consensusLoop.Validator as PosConsensusValidator;
        }
        internal void Create(ConcurrentChain chain)
        {
            this.blockPuller = new StoreBlockPuller(chain, this.connectionManager.Object, this.loggerFactory.Object);

            if (this.asyncLoopFactory == null)
            {
                this.asyncLoopFactory = new Mock <IAsyncLoopFactory>().Object;
            }

            this.Loop = new BlockStoreLoop(
                this.asyncLoopFactory,
                this.blockPuller,
                this.BlockRepository,
                null,
                chain,
                this.chainState.Object,
                new StoreSettings(NodeSettings.FromArguments(new string[] { $"-datadir={this.dataFolder.WalletPath}" })),
                this.nodeLifeTime.Object,
                this.loggerFactory.Object,
                DateTimeProvider.Default);
        }
        public BlockNotification(
            ILoggerFactory loggerFactory,
            ConcurrentChain chain,
            ILookaheadBlockPuller puller,
            ISignals signals,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(puller, nameof(puller));
            Guard.NotNull(signals, nameof(signals));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));

            this.Chain            = chain;
            this.Puller           = puller;
            this.signals          = signals;
            this.asyncLoopFactory = asyncLoopFactory;
            this.nodeLifetime     = nodeLifetime;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
        }
        public PartialTransactionRequester(
            ILoggerFactory loggerFactory,
            ICrossChainTransferStore crossChainTransferStore,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime,
            IConnectionManager connectionManager,
            IFederationGatewaySettings federationGatewaySettings)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(crossChainTransferStore, nameof(crossChainTransferStore));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(federationGatewaySettings, nameof(federationGatewaySettings));

            this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
            this.crossChainTransferStore   = crossChainTransferStore;
            this.asyncLoopFactory          = asyncLoopFactory;
            this.nodeLifetime              = nodeLifetime;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
        }
        public WalletManager(ILoggerFactory loggerFactory, IConnectionManager connectionManager, Network network, ConcurrentChain chain,
                             NodeSettings settings, DataFolder dataFolder, IWalletFeePolicy walletFeePolicy, IAsyncLoopFactory asyncLoopFactory,
                             INodeLifetime nodeLifetime, MempoolValidator mempoolValidator = null) // mempool does not exist in a light wallet
        {
            this.logger  = loggerFactory.CreateLogger(this.GetType().FullName);
            this.Wallets = new ConcurrentBag <Wallet>();

            this.connectionManager = connectionManager;
            this.network           = network;
            this.coinType          = (CoinType)network.Consensus.CoinType;
            this.chain             = chain;
            this.settings          = settings;
            this.dataFolder        = dataFolder;
            this.walletFeePolicy   = walletFeePolicy;
            this.mempoolValidator  = mempoolValidator;
            this.asyncLoopFactory  = asyncLoopFactory;
            this.nodeLifetime      = nodeLifetime;

            // register events
            this.TransactionFound += this.OnTransactionFound;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DnsSeedServer"/> class with the port to listen on.
        /// </summary>
        /// <param name="client">The UDP client to use to receive DNS requests and send DNS responses.</param>
        /// <param name="masterFile">The initial DNS masterfile.</param>
        /// <param name="asyncLoopFactory">The async loop factory.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="dateTimeProvider">The <see cref="DateTime"/> provider.</param>
        /// <param name="nodeSettings">The node settings object containing node configuration.</param>
        /// <param name="dataFolders">The data folders of the system.</param>
        public DnsSeedServer(IUdpClient client, IMasterFile masterFile, IAsyncLoopFactory asyncLoopFactory, INodeLifetime nodeLifetime, ILoggerFactory loggerFactory, IDateTimeProvider dateTimeProvider, DnsSettings dnsSettings, DataFolder dataFolders)
        {
            Guard.NotNull(client, nameof(client));
            Guard.NotNull(masterFile, nameof(masterFile));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(dateTimeProvider, nameof(dateTimeProvider));
            Guard.NotNull(dnsSettings, nameof(dnsSettings));
            Guard.NotNull(dataFolders, nameof(dataFolders));

            this.udpClient        = client;
            this.masterFile       = masterFile;
            this.asyncLoopFactory = asyncLoopFactory;
            this.nodeLifetime     = nodeLifetime;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
            this.dateTimeProvider = dateTimeProvider;
            this.dnsSettings      = dnsSettings;
            this.dataFolders      = dataFolders;
            this.metrics          = new DnsMetric();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LightWalletFeature"/> class.
 /// </summary>
 /// <param name="walletSyncManager">The synchronization manager for the wallet, tasked with keeping the wallet synced with the network.</param>
 /// <param name="walletManager">The wallet manager.</param>
 /// <param name="connectionManager">The connection manager.</param>
 /// <param name="chain">The chain of blocks.</param>
 /// <param name="nodeDeployments">The node deployments.</param>
 /// <param name="asyncLoopFactory">The asynchronous loop factory.</param>
 /// <param name="nodeLifetime">The node lifetime.</param>
 /// <param name="walletFeePolicy">The wallet fee policy.</param>
 public LightWalletFeature(
     IWalletSyncManager walletSyncManager,
     IWalletManager walletManager,
     IConnectionManager connectionManager,
     ConcurrentChain chain,
     NodeDeployments nodeDeployments,
     IAsyncLoopFactory asyncLoopFactory,
     INodeLifetime nodeLifetime,
     IWalletFeePolicy walletFeePolicy,
     BroadcasterBehavior broadcasterBehavior)
 {
     this.walletSyncManager   = walletSyncManager;
     this.walletManager       = walletManager;
     this.connectionManager   = connectionManager;
     this.chain               = chain;
     this.nodeDeployments     = nodeDeployments;
     this.asyncLoopFactory    = asyncLoopFactory;
     this.nodeLifetime        = nodeLifetime;
     this.walletFeePolicy     = walletFeePolicy;
     this.broadcasterBehavior = broadcasterBehavior;
 }
 /// <summary>
 /// Constructs an instance of a MempoolSignaled object.
 /// Starts the block notification loop to memory pool behaviors for connected nodes.
 /// </summary>
 /// <param name="manager">Memory pool manager injected dependency.</param>
 /// <param name="chain">Concurrent chain injected dependency.</param>
 /// <param name="connection">Connection manager injected dependency.</param>
 /// <param name="nodeLifetime">Node lifetime injected dependency.</param>
 /// <param name="asyncLoopFactory">Asynchronous loop factory injected dependency.</param>
 /// <param name="mempoolLock">The mempool lock.</param>
 /// <param name="memPool">the mempool.</param>
 /// <param name="validator">The mempool validator.</param>
 /// <param name="mempoolOrphans">The mempool orphan list.</param>
 public MempoolSignaled(
     MempoolManager manager,
     ConcurrentChain chain,
     IConnectionManager connection,
     INodeLifetime nodeLifetime,
     IAsyncLoopFactory asyncLoopFactory,
     MempoolSchedulerLock mempoolLock,
     ITxMempool memPool,
     IMempoolValidator validator,
     MempoolOrphans mempoolOrphans)
 {
     this.manager          = manager;
     this.chain            = chain;
     this.connection       = connection;
     this.nodeLifetime     = nodeLifetime;
     this.asyncLoopFactory = asyncLoopFactory;
     this.mempoolLock      = mempoolLock;
     this.memPool          = memPool;
     this.validator        = validator;
     this.mempoolOrphans   = mempoolOrphans;
 }
Exemple #25
0
        public BlockStoreLoop(ConcurrentChain chain,
                              BlockRepository blockRepository,
                              NodeSettings nodeArgs,
                              BlockStore.ChainBehavior.ChainState chainState,
                              StoreBlockPuller blockPuller,
                              BlockStoreCache cache,
                              INodeLifetime nodeLifetime,
                              IAsyncLoopFactory asyncLoopFactory)
        {
            this.chain            = chain;
            this.BlockRepository  = blockRepository;
            this.nodeArgs         = nodeArgs;
            this.blockPuller      = blockPuller;
            this.ChainState       = chainState;
            this.blockStoreCache  = cache;
            this.nodeLifetime     = nodeLifetime;
            this.asyncLoopFactory = asyncLoopFactory;

            this.PendingStorage  = new ConcurrentDictionary <uint256, BlockPair>();
            this.blockStoreStats = new BlockStoreStats(this.BlockRepository, this.blockStoreCache);
        }
 /// <summary>Parameterless constructor for dependency injection.</summary>
 protected PeerConnector(
     IAsyncLoopFactory asyncLoopFactory,
     IDateTimeProvider dateTimeProvider,
     ILoggerFactory loggerFactory,
     Network network,
     INetworkPeerFactory networkPeerFactory,
     INodeLifetime nodeLifetime,
     NodeSettings nodeSettings,
     IPeerAddressManager peerAddressManager)
 {
     this.asyncLoopFactory   = asyncLoopFactory;
     this.ConnectedPeers     = new NetworkPeerCollection();
     this.dateTimeProvider   = dateTimeProvider;
     this.loggerFactory      = loggerFactory;
     this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
     this.network            = network;
     this.networkPeerFactory = networkPeerFactory;
     this.nodeLifetime       = nodeLifetime;
     this.NodeSettings       = nodeSettings;
     this.peerAddressManager = peerAddressManager;
 }
Exemple #27
0
        public BlockNotification(
            ILoggerFactory loggerFactory,
            ChainIndexer chainIndexer,
            IConsensusManager consensusManager,
            ISignals signals,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(chainIndexer, nameof(chainIndexer));
            Guard.NotNull(consensusManager, nameof(consensusManager));
            Guard.NotNull(signals, nameof(signals));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));

            this.ChainIndexer     = chainIndexer;
            this.consensusManager = consensusManager;
            this.signals          = signals;
            this.asyncLoopFactory = asyncLoopFactory;
            this.nodeLifetime     = nodeLifetime;
            this.logger           = loggerFactory.CreateLogger(this.GetType().FullName);
        }
        public BlockStoreLoop(ConcurrentChain chain,
                              BlockRepository blockRepository,
                              NodeSettings nodeArgs,
                              ChainState chainState,
                              StoreBlockPuller blockPuller,
                              BlockStoreCache cache,
                              INodeLifetime nodeLifetime,
                              IAsyncLoopFactory asyncLoopFactory,
                              ILoggerFactory loggerFactory)
        {
            this.chain            = chain;
            this.BlockRepository  = blockRepository;
            this.nodeArgs         = nodeArgs;
            this.blockPuller      = blockPuller;
            this.ChainState       = chainState;
            this.blockStoreCache  = cache;
            this.nodeLifetime     = nodeLifetime;
            this.asyncLoopFactory = asyncLoopFactory;
            this.storeLogger      = loggerFactory.CreateLogger(this.GetType().FullName);

            this.PendingStorage  = new ConcurrentDictionary <uint256, BlockPair>();
            this.blockStoreStats = new BlockStoreStats(this.BlockRepository, this.blockStoreCache, this.storeLogger);
        }
Exemple #29
0
        /// <summary>Constructor used by <see cref="Connection.ConnectionManager"/>.</summary>
        protected PeerConnector(
            IAsyncLoopFactory asyncLoopFactory,
            ILogger logger,
            Network network,
            INetworkPeerFactory networkPeerFactory,
            INodeLifetime nodeLifeTime,
            NodeSettings nodeSettings,
            NetworkPeerConnectionParameters parameters,
            IPeerAddressManager peerAddressManager)
        {
            this.asyncLoopFactory   = asyncLoopFactory;
            this.ConnectedPeers     = new NetworkPeerCollection();
            this.network            = network;
            this.networkPeerFactory = networkPeerFactory;
            this.nodeLifetime       = nodeLifeTime;
            this.NodeSettings       = nodeSettings;
            this.parentParameters   = parameters;
            this.peerAddressManager = peerAddressManager;

            this.CurrentParameters = this.parentParameters.Clone();
            this.CurrentParameters.TemplateBehaviors.Add(new PeerConnectorBehaviour(this));
            this.CurrentParameters.ConnectCancellation = this.nodeLifetime.ApplicationStopping;
        }
Exemple #30
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DnsFeature"/> class.
        /// </summary>
        /// <param name="dnsServer">The DNS server.</param>
        /// <param name="whitelistManager">The whitelist manager.</param>
        /// <param name="loggerFactory">The factory to create the logger.</param>
        /// <param name="nodeLifetime">The node lifetime object used for graceful shutdown.</param>
        /// <param name="nodeSettings">The node settings object containing node configuration.</param>
        /// <param name="dnsSettings">Defines the DNS settings for the node</param>
        /// <param name="dataFolders">The data folders of the system.</param>
        /// <param name="asyncLoopFactory">The asynchronous loop factory.</param>
        /// <param name="connectionManager">Manager of node's network connections.</param>
        /// <param name="unreliablePeerBehavior">Instance of the UnreliablePeerBehavior that will be added to the connectionManager Template.</param>
        public DnsFeature(IDnsServer dnsServer, IWhitelistManager whitelistManager, ILoggerFactory loggerFactory, INodeLifetime nodeLifetime, DnsSettings dnsSettings, NodeSettings nodeSettings, DataFolder dataFolders, IAsyncLoopFactory asyncLoopFactory, IConnectionManager connectionManager, UnreliablePeerBehavior unreliablePeerBehavior)
        {
            Guard.NotNull(dnsServer, nameof(dnsServer));
            Guard.NotNull(whitelistManager, nameof(whitelistManager));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(nodeSettings, nameof(nodeSettings));
            Guard.NotNull(dataFolders, nameof(dataFolders));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));
            Guard.NotNull(connectionManager, nameof(connectionManager));
            Guard.NotNull(unreliablePeerBehavior, nameof(unreliablePeerBehavior));

            this.dnsServer              = dnsServer;
            this.whitelistManager       = whitelistManager;
            this.logger                 = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
            this.asyncLoopFactory       = asyncLoopFactory;
            this.nodeLifetime           = nodeLifetime;
            this.nodeSettings           = nodeSettings;
            this.dnsSettings            = dnsSettings;
            this.dataFolders            = dataFolders;
            this.connectionManager      = connectionManager;
            this.unreliablePeerBehavior = unreliablePeerBehavior;
        }