public LightWalletFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IConnectionManager connectionManager,
            ChainIndexer chainIndexer,
            NodeDeployments nodeDeployments,
            IAsyncLoopFactory asyncLoopFactory,
            INodeLifetime nodeLifetime,
            IWalletFeePolicy walletFeePolicy,
            BroadcasterBehavior broadcasterBehavior,
            ILoggerFactory loggerFactory,
            StoreSettings storeSettings,
            WalletSettings walletSettings,
            INodeStats nodeStats,
            IPruneBlockStoreService lightWalletBlockStoreService)
        {
            this.walletSyncManager   = walletSyncManager;
            this.walletManager       = walletManager;
            this.connectionManager   = connectionManager;
            this.chainIndexer        = chainIndexer;
            this.nodeDeployments     = nodeDeployments;
            this.asyncLoopFactory    = asyncLoopFactory;
            this.nodeLifetime        = nodeLifetime;
            this.walletFeePolicy     = walletFeePolicy;
            this.broadcasterBehavior = broadcasterBehavior;
            this.logger         = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory  = loggerFactory;
            this.storeSettings  = storeSettings;
            this.walletSettings = walletSettings;

            this.lightWalletBlockStoreService = lightWalletBlockStoreService;

            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline);
            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WalletFeature"/> 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="addressBookManager">The address book manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="chain">The chain of blocks.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        /// <param name="nodeSettings">The settings for the node.</param>
        /// <param name="walletSettings">The settings for the wallet.</param>
        public WalletFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            Signals.Signals signals,
            ConcurrentChain chain,
            IConnectionManager connectionManager,
            BroadcasterBehavior broadcasterBehavior,
            NodeSettings nodeSettings,
            WalletSettings walletSettings,
            INodeStats nodeStats)
        {
            this.walletSyncManager  = walletSyncManager;
            this.walletManager      = walletManager;
            this.addressBookManager = addressBookManager;
            this.signals            = signals;
            this.chain               = chain;
            this.connectionManager   = connectionManager;
            this.broadcasterBehavior = broadcasterBehavior;
            this.nodeSettings        = nodeSettings;
            this.walletSettings      = walletSettings;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
        public ProvenBlockHeaderStore(
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            IProvenBlockHeaderRepository provenBlockHeaderRepository,
            INodeStats nodeStats,
            IInitialBlockDownloadState initialBlockDownloadState)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(provenBlockHeaderRepository, nameof(provenBlockHeaderRepository));
            Guard.NotNull(nodeStats, nameof(nodeStats));

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

            this.lockObject   = new object();
            this.pendingBatch = new SortedDictionary <int, ProvenBlockHeader>();
            this.Cache        = new MemorySizeCache <int, ProvenBlockHeader>(this.MemoryCacheSizeLimitInBytes);

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);

            if (nodeStats.DisplayBenchStats)
            {
                nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name);
            }

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColdStakingFeature"/> 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="addressBookManager">The address book manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="chain">The chain of blocks.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        /// <param name="nodeSettings">The settings for the node.</param>
        /// <param name="walletSettings">The settings for the wallet.</param>
        /// <param name="loggerFactory">The factory used to create instance loggers.</param>
        /// <param name="nodeStats">The node stats object used to register node stats.</param>
        public ColdStakingFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            IConnectionManager connectionManager,
            BroadcasterBehavior broadcasterBehavior,
            NodeSettings nodeSettings,
            WalletSettings walletSettings,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats)
        {
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.coldStakingManager = walletManager as ColdStakingManager;
            Guard.NotNull(this.coldStakingManager, nameof(this.coldStakingManager));

            this.logger        = loggerFactory.CreateLogger("Impleum.Bitcoin.FullNode");
            this.loggerFactory = loggerFactory;

            this.walletSyncManager   = walletSyncManager;
            this.addressBookManager  = addressBookManager;
            this.connectionManager   = connectionManager;
            this.broadcasterBehavior = broadcasterBehavior;
            this.nodeSettings        = nodeSettings;
            this.walletSettings      = walletSettings;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColdStakingFeature"/> 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="addressBookManager">The address book manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="chain">The chain of blocks.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="nodeSettings">The settings for the node.</param>
        /// <param name="walletSettings">The settings for the wallet.</param>
        /// <param name="loggerFactory">The factory used to create instance loggers.</param>
        /// <param name="nodeStats">The node stats object used to register node stats.</param>
        public ColdStakingFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            IConnectionManager connectionManager,
            NodeSettings nodeSettings,
            WalletSettings walletSettings,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats)
        {
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.coldStakingManager = walletManager as ColdStakingManager;
            Guard.NotNull(this.coldStakingManager, nameof(this.coldStakingManager));

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

            this.walletSyncManager  = walletSyncManager;
            this.addressBookManager = addressBookManager;
            this.connectionManager  = connectionManager;
            this.nodeSettings       = nodeSettings;
            this.walletSettings     = walletSettings;

            nodeStats.RemoveStats(StatsType.Component, typeof(WalletFeature).Name);
            nodeStats.RemoveStats(StatsType.Inline, typeof(WalletFeature).Name);

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ColdStakingFeature"/> 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="addressBookManager">The address book manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="chain">The chain of blocks.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        /// <param name="nodeSettings">The settings for the node.</param>
        /// <param name="walletSettings">The settings for the wallet.</param>
        /// <param name="loggerFactory">The factory used to create instance loggers.</param>
        /// <param name="nodeStats">The node stats object used to register node stats.</param>
        public ColdStakingFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            Signals.Signals signals,
            ConcurrentChain chain,
            IConnectionManager connectionManager,
            BroadcasterBehavior broadcasterBehavior,
            NodeSettings nodeSettings,
            WalletSettings walletSettings,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats)
        {
            Guard.NotNull(walletManager, nameof(walletManager));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.coldStakingManager = walletManager as ColdStakingManager;
            Guard.NotNull(this.coldStakingManager, nameof(this.coldStakingManager));

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

            this.walletSyncManager  = walletSyncManager;
            this.addressBookManager = addressBookManager;
            this.signals            = signals;
            this.chain               = chain;
            this.connectionManager   = connectionManager;
            this.broadcasterBehavior = broadcasterBehavior;
            this.nodeSettings        = nodeSettings;
            this.walletSettings      = walletSettings;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
        /// <summary>
        /// Initializes a new instance of the object.
        /// </summary>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="loggerFactory">Factory to create a logger for this type.</param>
        /// <param name="provenBlockHeaderRepository">Persistent interface of the <see cref="ProvenBlockHeader"/> DBreeze repository.</param>
        /// <param name="nodeLifetime">Allows consumers to perform clean-up during a graceful shutdown.</param>
        /// <param name="nodeStats">Registers an action used to append node stats when collected.</param>
        /// <param name="asyncLoopFactory">Factory for creating and also possibly starting application defined tasks inside async loop.</param>
        public ProvenBlockHeaderStore(
            IDateTimeProvider dateTimeProvider,
            ILoggerFactory loggerFactory,
            IProvenBlockHeaderRepository provenBlockHeaderRepository,
            INodeLifetime nodeLifetime,
            INodeStats nodeStats,
            IAsyncLoopFactory asyncLoopFactory)
        {
            Guard.NotNull(loggerFactory, nameof(loggerFactory));
            Guard.NotNull(provenBlockHeaderRepository, nameof(provenBlockHeaderRepository));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(nodeStats, nameof(nodeStats));
            Guard.NotNull(asyncLoopFactory, nameof(asyncLoopFactory));

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

            this.lockObject   = new object();
            this.PendingBatch = new Dictionary <int, ProvenBlockHeader>();
            this.Cache        = new MemorySizeCache <int, ProvenBlockHeader>(this.MemoryCacheSizeLimitInBytes);

            this.asyncLoopFactory = asyncLoopFactory;

            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);
            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark);
            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
        public MessagingHostFeature(IConnectionManager connectionManager, ILoggerFactory loggerFactory, TcpAsyncServer tcpAsyncServer, INodeStats nodeStats, IMessageNodeRepository messageNodeRepository)
        {
            this.connectionManager     = connectionManager;
            this.tcpAsyncServer        = tcpAsyncServer;
            this.logger                = loggerFactory.CreateLogger(this.GetType().FullName);
            this.messageNodeRepository = messageNodeRepository;

            nodeStats.RegisterStats(AddComponentStatsAsync, StatsType.Component, GetType().Name);
            nodeStats.RegisterStats(AddInlineStats, StatsType.Inline, GetType().Name, 800);
        }
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            IMaturedBlockReceiver maturedBlockReceiver,
            IMaturedBlockSender maturedBlockSender,
            IMaturedBlocksRequester maturedBlocksRequester,
            IMaturedBlocksProvider maturedBlocksProvider,
            IBlockTipSender blockTipSender,
            Signals signals,
            IDepositExtractor depositExtractor,
            IWithdrawalExtractor withdrawalExtractor,
            IWithdrawalReceiver withdrawalReceiver,
            ILeaderProvider leaderProvider,
            IConnectionManager connectionManager,
            IFederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ConcurrentChain chain,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester)
        {
            this.loggerFactory         = loggerFactory;
            this.maturedBlockReceiver  = maturedBlockReceiver;
            this.maturedBlockSender    = maturedBlockSender;
            this.maturedBlockRequester = maturedBlocksRequester;
            this.maturedBlocksProvider = maturedBlocksProvider;
            this.blockTipSender        = blockTipSender;
            this.signals                   = signals;
            this.depositExtractor          = depositExtractor;
            this.withdrawalExtractor       = withdrawalExtractor;
            this.withdrawalReceiver        = withdrawalReceiver;
            this.leaderProvider            = leaderProvider;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
            this.fullNode                  = fullNode;
            this.chain = chain;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.partialTransactionRequester = partialTransactionRequester;

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WalletFeature"/> 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="addressBookManager">The address book manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        public WalletFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            INodeStats nodeStats)
        {
            this.walletSyncManager  = walletSyncManager;
            this.walletManager      = walletManager;
            this.addressBookManager = addressBookManager;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800);
        }
예제 #11
0
        public ServiceNodeFeature(ILoggerFactory loggerFactory,
                                  NodeSettings nodeSettings,
                                  IServiceNodeManager serviceNodeManager,
                                  IServiceNodeRegistrationChecker serviceNodeRegistrationChecker,
                                  IServiceNodeCollateralChecker serviceNodeCollateralChecker,
                                  INodeStats nodeStats)
        {
            this.logger                         = loggerFactory.CreateLogger(this.GetType().FullName);
            this.serviceNodeManager             = serviceNodeManager;
            this.serviceNodeRegistrationChecker = serviceNodeRegistrationChecker;
            this.serviceNodeCollateralChecker   = serviceNodeCollateralChecker;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
예제 #12
0
        public X1WalletFeature(
            WalletManagerFactory walletManagerFactory,
            IConnectionManager connectionManager,
            BroadcasterBehavior broadcasterBehavior,
            INodeStats nodeStats, Network network, WalletController walletController)
        {
            this.walletManagerFactory = walletManagerFactory;
            this.connectionManager    = connectionManager;
            this.broadcasterBehavior  = broadcasterBehavior;
            this.network          = network;
            this.walletController = walletController;

            nodeStats.RegisterStats(AddComponentStats, StatsType.Component, GetType().Name);
            nodeStats.RegisterStats(AddInlineStats, StatsType.Inline, GetType().Name, 800);
        }
        public BlockStoreQueue(
            ConcurrentChain chain,
            IChainState chainState,
            StoreSettings storeSettings,
            INodeLifetime nodeLifetime,
            IBlockRepository blockRepository,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats)
        {
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(chainState, nameof(chainState));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(nodeLifetime, nameof(nodeLifetime));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.chainState      = chainState;
            this.nodeLifetime    = nodeLifetime;
            this.storeSettings   = storeSettings;
            this.chain           = chain;
            this.blockRepository = blockRepository;
            this.batch           = new List <ChainedHeaderBlock>();
            this.getBlockLock    = new object();
            this.blocksQueue     = new AsyncQueue <ChainedHeaderBlock>();
            this.pendingBlocks   = new Dictionary <uint256, ChainedHeaderBlock>();
            this.logger          = loggerFactory.CreateLogger(this.GetType().FullName);

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
예제 #14
0
        public PoAMiner(
            IConsensusManager consensusManager,
            IDateTimeProvider dateTimeProvider,
            Network network,
            INodeLifetime nodeLifetime,
            ILoggerFactory loggerFactory,
            IInitialBlockDownloadState ibdState,
            BlockDefinition blockDefinition,
            SlotsManager slotsManager,
            IConnectionManager connectionManager,
            PoABlockHeaderValidator poaHeaderValidator,
            FederationManager federationManager,
            IIntegrityValidator integrityValidator,
            IWalletManager walletManager,
            INodeStats nodeStats)
        {
            this.consensusManager   = consensusManager;
            this.dateTimeProvider   = dateTimeProvider;
            this.network            = network as PoANetwork;
            this.ibdState           = ibdState;
            this.blockDefinition    = blockDefinition;
            this.slotsManager       = slotsManager;
            this.connectionManager  = connectionManager;
            this.poaHeaderValidator = poaHeaderValidator;
            this.federationManager  = federationManager;
            this.integrityValidator = integrityValidator;
            this.walletManager      = walletManager;

            this.logger       = loggerFactory.CreateLogger(this.GetType().FullName);
            this.cancellation = CancellationTokenSource.CreateLinkedTokenSource(new[] { nodeLifetime.ApplicationStopping });

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
예제 #15
0
        public BlockStoreFeature(
            Network network,
            ConcurrentChain chain,
            IConnectionManager connectionManager,
            Signals.Signals signals,
            BlockStoreSignaled blockStoreSignaled,
            ILoggerFactory loggerFactory,
            StoreSettings storeSettings,
            IChainState chainState,
            IBlockStoreQueue blockStoreQueue,
            INodeStats nodeStats,
            IConsensusManager consensusManager,
            ICheckpoints checkpoints)
        {
            this.network            = network;
            this.chain              = chain;
            this.blockStoreQueue    = blockStoreQueue;
            this.signals            = signals;
            this.blockStoreSignaled = blockStoreSignaled;
            this.connectionManager  = connectionManager;
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory      = loggerFactory;
            this.storeSettings      = storeSettings;
            this.chainState         = chainState;
            this.consensusManager   = consensusManager;
            this.checkpoints        = checkpoints;

            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 900);
        }
        public BlockStoreFeature(
            Network network,
            ChainIndexer chainIndexer,
            IConnectionManager connectionManager,
            BlockStoreSignaled blockStoreSignaled,
            ILoggerFactory loggerFactory,
            StoreSettings storeSettings,
            IChainState chainState,
            IBlockStoreQueue blockStoreQueue,
            INodeStats nodeStats,
            IConsensusManager consensusManager,
            ICheckpoints checkpoints,
            IPrunedBlockRepository prunedBlockRepository,
            AddressIndexer addressIndexer)
        {
            this.network               = network;
            this.chainIndexer          = chainIndexer;
            this.blockStoreQueue       = blockStoreQueue;
            this.blockStoreSignaled    = blockStoreSignaled;
            this.connectionManager     = connectionManager;
            this.logger                = loggerFactory.CreateLogger(this.GetType().FullName);
            this.loggerFactory         = loggerFactory;
            this.storeSettings         = storeSettings;
            this.chainState            = chainState;
            this.consensusManager      = consensusManager;
            this.checkpoints           = checkpoints;
            this.prunedBlockRepository = prunedBlockRepository;
            this.addressIndexer        = addressIndexer;

            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 900);
        }
예제 #17
0
        public CachedCoinView(Network network, ICheckpoints checkpoints, ICoindb coindb, IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, INodeStats nodeStats, ConsensusSettings consensusSettings, StakeChainStore stakeChainStore = null, IRewindDataIndexCache rewindDataIndexCache = null)
        {
            Guard.NotNull(coindb, nameof(CachedCoinView.coindb));

            this.coindb               = coindb;
            this.logger               = loggerFactory.CreateLogger(this.GetType().FullName);
            this.network              = network;
            this.checkpoints          = checkpoints;
            this.dateTimeProvider     = dateTimeProvider;
            this.consensusSettings    = consensusSettings;
            this.stakeChainStore      = stakeChainStore;
            this.rewindDataIndexCache = rewindDataIndexCache;
            this.lockobj              = new object();
            this.cachedUtxoItems      = new Dictionary <OutPoint, CacheItem>();
            this.performanceCounter   = new CachePerformanceCounter(this.dateTimeProvider);
            this.lastCacheFlushTime   = this.dateTimeProvider.GetUtcNow();
            this.cachedRewindData     = new Dictionary <int, RewindData>();
            this.random               = new Random();

            this.lastCheckpointHeight = this.checkpoints.GetLastCheckpointHeight();

            this.MaxCacheSizeBytes             = consensusSettings.MaxCoindbCacheInMB * 1024 * 1024;
            this.CacheFlushTimeIntervalSeconds = consensusSettings.CoindbIbdFlushMin * 60;

            if (nodeStats.DisplayBenchStats)
            {
                nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name, 300);
            }
        }
예제 #18
0
        public LevelDbCoindb(Network network, string folder, IDateTimeProvider dateTimeProvider,
                             ILoggerFactory loggerFactory, INodeStats nodeStats, DBreezeSerializer dBreezeSerializer)
        {
            Guard.NotNull(network, nameof(network));
            Guard.NotEmpty(folder, nameof(folder));

            this.dBreezeSerializer = dBreezeSerializer;

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

            // Open a connection to a new DB and create if not found
            var options = new Options {
                CreateIfMissing = true
            };

            this.leveldb = new DB(options, folder);

            this.network            = network;
            this.performanceCounter = new BackendPerformanceCounter(dateTimeProvider);

            if (nodeStats.DisplayBenchStats)
            {
                nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, this.GetType().Name, 400);
            }
        }
        public BlockStoreQueue(
            ConcurrentChain chain,
            IChainState chainState,
            IBlockStoreQueueFlushCondition blockStoreQueueFlushCondition,
            StoreSettings storeSettings,
            IBlockRepository blockRepository,
            ILoggerFactory loggerFactory,
            INodeStats nodeStats)
        {
            Guard.NotNull(blockStoreQueueFlushCondition, nameof(blockStoreQueueFlushCondition));
            Guard.NotNull(chain, nameof(chain));
            Guard.NotNull(chainState, nameof(chainState));
            Guard.NotNull(storeSettings, nameof(storeSettings));
            Guard.NotNull(loggerFactory, nameof(loggerFactory));

            this.blockStoreQueueFlushCondition = blockStoreQueueFlushCondition;
            this.chain              = chain;
            this.chainState         = chainState;
            this.storeSettings      = storeSettings;
            this.blockRepository    = blockRepository;
            this.batch              = new List <ChainedHeaderBlock>();
            this.blocksCacheLock    = new object();
            this.blocksQueue        = new AsyncQueue <ChainedHeaderBlock>();
            this.pendingBlocksCache = new Dictionary <uint256, ChainedHeaderBlock>();
            this.logger             = loggerFactory.CreateLogger(this.GetType().FullName);
            this.cancellation       = new CancellationTokenSource();

            this.BatchThresholdSizeBytes = storeSettings.MaxCacheSize * 1024 * 1024;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
        }
예제 #20
0
        public FederatedPegFeature(
            ILoggerFactory loggerFactory,
            IConnectionManager connectionManager,
            IFederatedPegSettings federatedPegSettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ChainIndexer chainIndexer,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            MempoolCleaner mempoolCleaner,
            ISignedMultisigTransactionBroadcaster signedBroadcaster,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IWithdrawalHistoryProvider withdrawalHistoryProvider,
            IInputConsolidator inputConsolidator,
            ICollateralChecker collateralChecker = null)
        {
            this.loggerFactory           = loggerFactory;
            this.connectionManager       = connectionManager;
            this.federatedPegSettings    = federatedPegSettings;
            this.fullNode                = fullNode;
            this.chainIndexer            = chainIndexer;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.partialTransactionRequester = partialTransactionRequester;
            this.mempoolCleaner            = mempoolCleaner;
            this.maturedBlocksSyncManager  = maturedBlocksSyncManager;
            this.withdrawalHistoryProvider = withdrawalHistoryProvider;
            this.signedBroadcaster         = signedBroadcaster;
            this.inputConsolidator         = inputConsolidator;

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

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800);
        }
예제 #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WalletFeature"/> 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="addressBookManager">The address book manager.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        public WalletFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            IConnectionManager connectionManager,
            BroadcasterBehavior broadcasterBehavior,
            INodeStats nodeStats,
            IWalletRepository walletRepository)
        {
            this.walletSyncManager   = walletSyncManager;
            this.walletManager       = walletManager;
            this.addressBookManager  = addressBookManager;
            this.connectionManager   = connectionManager;
            this.broadcasterBehavior = broadcasterBehavior;
            this.walletRepository    = walletRepository;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name, 800);
        }
예제 #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="WalletFeature"/> class.
        /// </summary>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        /// <param name="chainIndexer">The chain of blocks.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="walletManager">The wallet manager.</param>
        /// <param name="walletSyncManager">The synchronization manager for the wallet, tasked with keeping the wallet synced with the network.</param>
        public SmartContractWalletFeature(
            BroadcasterBehavior broadcasterBehavior,
            ChainIndexer chainIndexer,
            IConnectionManager connectionManager,
            ILoggerFactory loggerFactory,
            IWalletManager walletManager,
            IWalletSyncManager walletSyncManager,
            INodeStats nodeStats)
        {
            this.broadcasterBehavior = broadcasterBehavior;
            this.chainIndexer        = chainIndexer;
            this.connectionManager   = connectionManager;
            this.logger            = loggerFactory.CreateLogger(this.GetType().Name);
            this.walletManager     = walletManager;
            this.walletSyncManager = walletSyncManager;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, this.GetType().Name);
        }
        public ConversionRequestCoordinationService(INodeStats nodeStats)
        {
            this.lockObject = new object();
            this.logger     = LogManager.GetCurrentClassLogger();

            this.receivedVotes      = new Dictionary <string, HashSet <PubKey> >();
            this.transactionIdVotes = new Dictionary <string, Dictionary <BigInteger, int> >();

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component, this.GetType().Name, 252);
        }
예제 #24
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="WalletFeature" /> 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="addressBookManager">The address book manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        public WalletFeature(
            IWalletSyncManager walletSyncManager,
            IWalletManager walletManager,
            IAddressBookManager addressBookManager,
            ISignals signals,
            IConnectionManager connectionManager,
            BroadcasterBehavior broadcasterBehavior,
            INodeStats nodeStats)
        {
            this.walletSyncManager   = walletSyncManager;
            this.walletManager       = walletManager;
            this.addressBookManager  = addressBookManager;
            this.signals             = signals;
            this.connectionManager   = connectionManager;
            this.broadcasterBehavior = broadcasterBehavior;

            nodeStats.RegisterStats(AddComponentStats, StatsType.Component, GetType().Name);
            nodeStats.RegisterStats(AddInlineStats, StatsType.Inline, GetType().Name, 800);
        }
예제 #25
0
        /// <summary>
        /// Initializes a new instance of the <see cref="xServerFeature"/> class with the xServers.
        /// </summary>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="nodeStats">The node stats.</param>
        /// <param name="xServerManager">The wallet manager.</param>
        public xServerFeature(
            ILoggerFactory loggerFactory,
            INodeStats nodeStats,
            IxServerManager xServerManager)
        {
            Guard.NotNull(xServerManager, nameof(IxServerManager));

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

            nodeStats.RegisterStats(AddInlineStats, StatsType.Component, this.GetType().Name);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="WalletFeature"/> class.
        /// </summary>
        /// <param name="broadcasterBehavior">The broadcaster behavior.</param>
        /// <param name="chain">The chain of blocks.</param>
        /// <param name="connectionManager">The connection manager.</param>
        /// <param name="signals">The signals responsible for receiving blocks and transactions from the network.</param>
        /// <param name="walletManager">The wallet manager.</param>
        /// <param name="walletSyncManager">The synchronization manager for the wallet, tasked with keeping the wallet synced with the network.</param>
        public SmartContractWalletFeature(
            BroadcasterBehavior broadcasterBehavior,
            ConcurrentChain chain,
            IConnectionManager connectionManager,
            ILoggerFactory loggerFactory,
            Signals.Signals signals,
            IWalletManager walletManager,
            IWalletSyncManager walletSyncManager,
            INodeStats nodeStats)
        {
            this.broadcasterBehavior = broadcasterBehavior;
            this.chain             = chain;
            this.connectionManager = connectionManager;
            this.signals           = signals;
            this.logger            = loggerFactory.CreateLogger(this.GetType().Name);
            this.walletManager     = walletManager;
            this.walletSyncManager = walletSyncManager;

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline);
        }
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            IConnectionManager connectionManager,
            IFederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ConcurrentChain chain,
            INodeStats nodeStats,
            ICrossChainTransferStore crossChainTransferStore,
            IPartialTransactionRequester partialTransactionRequester,
            ISignedMultisigTransactionBroadcaster signedBroadcaster,
            IMaturedBlocksSyncManager maturedBlocksSyncManager,
            IWithdrawalHistoryProvider withdrawalHistoryProvider)
        {
            this.loggerFactory             = loggerFactory;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
            this.fullNode = fullNode;
            this.chain    = chain;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;
            this.crossChainTransferStore     = crossChainTransferStore;
            this.partialTransactionRequester = partialTransactionRequester;
            this.maturedBlocksSyncManager    = maturedBlocksSyncManager;
            this.withdrawalHistoryProvider   = withdrawalHistoryProvider;
            this.signedBroadcaster           = signedBroadcaster;

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

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
        /// <summary>
        /// Initializes instance of the object based.
        /// </summary>
        /// <param name="dateTimeProvider">Provider of time functions.</param>
        /// <param name="loggerFactory">Factory to be used to create logger for the puller.</param>
        /// <param name="stakeChainStore">Storage of POS block information.</param>
        private CachedCoinView(IDateTimeProvider dateTimeProvider, ILoggerFactory loggerFactory, INodeStats nodeStats, StakeChainStore stakeChainStore = null)
        {
            this.logger               = loggerFactory.CreateLogger(this.GetType().FullName);
            this.dateTimeProvider     = dateTimeProvider;
            this.stakeChainStore      = stakeChainStore;
            this.MaxItems             = CacheMaxItemsDefault;
            this.lockobj              = new AsyncLock();
            this.cachedUtxoItems      = new Dictionary <uint256, CacheItem>();
            this.performanceCounter   = new CachePerformanceCounter(this.dateTimeProvider);
            this.lastCacheFlushTime   = this.dateTimeProvider.GetUtcNow();
            this.cachedRewindDataList = new List <RewindData>();

            nodeStats.RegisterStats(this.AddBenchStats, StatsType.Benchmark, 300);
        }
예제 #29
0
        public FederationGatewayFeature(
            ILoggerFactory loggerFactory,
            ICrossChainTransactionMonitor crossChainTransactionMonitor,
            Signals signals,
            IConnectionManager connectionManager,
            FederationGatewaySettings federationGatewaySettings,
            IFullNode fullNode,
            IFederationWalletManager federationWalletManager,
            IFederationWalletSyncManager walletSyncManager,
            Network network,
            ConcurrentChain chain,
            IMonitorChainSessionManager monitorChainSessionManager,
            ICounterChainSessionManager counterChainSessionManager,
            INodeStats nodeStats)
        {
            this.loggerFactory = loggerFactory;
            this.crossChainTransactionMonitor = crossChainTransactionMonitor;
            this.signals                   = signals;
            this.connectionManager         = connectionManager;
            this.federationGatewaySettings = federationGatewaySettings;
            this.fullNode                  = fullNode;
            this.chain = chain;
            this.federationWalletManager = federationWalletManager;
            this.walletSyncManager       = walletSyncManager;
            this.network = network;

            this.counterChainSessionManager = counterChainSessionManager;
            this.monitorChainSessionManager = monitorChainSessionManager;

            // add our payload
            var payloadProvider = (PayloadProvider)this.fullNode.Services.ServiceProvider.GetService(typeof(PayloadProvider));

            payloadProvider.AddPayload(typeof(RequestPartialTransactionPayload));

            nodeStats.RegisterStats(this.AddComponentStats, StatsType.Component);
            nodeStats.RegisterStats(this.AddInlineStats, StatsType.Inline, 800);
        }
예제 #30
0
        public ConnectionManager(IDateTimeProvider dateTimeProvider,
                                 ILoggerFactory loggerFactory,
                                 Network network,
                                 INetworkPeerFactory networkPeerFactory,
                                 NodeSettings nodeSettings,
                                 INodeLifetime nodeLifetime,
                                 NetworkPeerConnectionParameters parameters,
                                 IPeerAddressManager peerAddressManager,
                                 IEnumerable <IPeerConnector> peerConnectors,
                                 IPeerDiscovery peerDiscovery,
                                 ISelfEndpointTracker selfEndpointTracker,
                                 ConnectionManagerSettings connectionSettings,
                                 IVersionProvider versionProvider,
                                 INodeStats nodeStats,
                                 IAsyncProvider asyncProvider)
        {
            this.connectedPeers      = new NetworkPeerCollection();
            this.dateTimeProvider    = dateTimeProvider;
            this.loggerFactory       = loggerFactory;
            this.logger              = loggerFactory.CreateLogger(GetType().FullName);
            this.Network             = network;
            this.NetworkPeerFactory  = networkPeerFactory;
            this.NodeSettings        = nodeSettings;
            this.nodeLifetime        = nodeLifetime;
            this.asyncProvider       = asyncProvider;
            this.peerAddressManager  = peerAddressManager;
            this.PeerConnectors      = peerConnectors;
            this.peerDiscovery       = peerDiscovery;
            this.ConnectionSettings  = connectionSettings;
            this.networkPeerDisposer = new NetworkPeerDisposer(this.loggerFactory, this.asyncProvider);
            this.Servers             = new List <NetworkPeerServer>();

            this.Parameters = parameters;
            this.Parameters.ConnectCancellation = this.nodeLifetime.ApplicationStopping;
            this.selfEndpointTracker            = selfEndpointTracker;
            this.versionProvider = versionProvider;
            this.ipRangeFilteringEndpointExclusions = new List <IPEndPoint>();
            this.connectedPeersQueue =
                asyncProvider.CreateAndRunAsyncDelegateDequeuer <INetworkPeer>(
                    $"{nameof(ConnectionManager)}-{nameof(this.connectedPeersQueue)}", OnPeerAdded);
            this.disconnectedPerfCounter = new PerformanceCounter();

            this.Parameters.UserAgent =
                $"{this.ConnectionSettings.Agent}:{versionProvider.GetVersion()} ({(int) this.NodeSettings.ProtocolVersion})";

            this.Parameters.Version = this.NodeSettings.ProtocolVersion;

            nodeStats.RegisterStats(AddComponentStats, StatsType.Component, GetType().Name, 1100);
        }