Beispiel #1
0
        public Synchronizer(
            ISpecProvider specProvider,
            IBlockTree blockTree,
            IReceiptStorage receiptStorage,
            IBlockValidator blockValidator,
            ISealValidator sealValidator,
            IEthSyncPeerPool peerPool,
            ISyncConfig syncConfig,
            INodeDataDownloader nodeDataDownloader,
            ISyncReport syncReport,
            ILogManager logManager)
        {
            _logger             = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
            _specProvider       = specProvider ?? throw new ArgumentNullException(nameof(specProvider));
            _blockTree          = blockTree ?? throw new ArgumentNullException(nameof(blockTree));
            _receiptStorage     = receiptStorage ?? throw new ArgumentNullException(nameof(receiptStorage));
            _syncConfig         = syncConfig ?? throw new ArgumentNullException(nameof(syncConfig));
            _syncPeerPool       = peerPool ?? throw new ArgumentNullException(nameof(peerPool));
            _nodeDataDownloader = nodeDataDownloader ?? throw new ArgumentNullException(nameof(nodeDataDownloader));
            _syncReport         = syncReport ?? throw new ArgumentNullException(nameof(syncReport));

            SyncProgressResolver syncProgressResolver = new SyncProgressResolver(_blockTree, receiptStorage, _nodeDataDownloader, syncConfig, logManager);

            _syncMode = new SyncModeSelector(syncProgressResolver, _syncPeerPool, _syncConfig, logManager);

            _blockDownloader = new BlockDownloader(_blockTree, blockValidator, sealValidator, syncReport, receiptStorage, specProvider, logManager);

            if (syncConfig.FastBlocks)
            {
                FastBlocksFeed feed = new FastBlocksFeed(_specProvider, _blockTree, _receiptStorage, _syncPeerPool, syncConfig, _syncReport, logManager);
                _fastBlockDownloader = new FastBlocksDownloader(_syncPeerPool, feed, blockValidator, sealValidator, logManager);
            }
        }
Beispiel #2
0
        public Synchronizer(IBlockTree blockTree,
                            IBlockValidator blockValidator,
                            ISealValidator sealValidator,
                            IEthSyncPeerPool peerPool,
                            ISyncConfig syncConfig,
                            INodeDataDownloader nodeDataDownloader,
                            ILogManager logManager)
        {
            _logger             = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
            _syncConfig         = syncConfig ?? throw new ArgumentNullException(nameof(syncConfig));
            _nodeDataDownloader = nodeDataDownloader ?? throw new ArgumentNullException(nameof(nodeDataDownloader));
            _syncPeerPool       = peerPool ?? throw new ArgumentNullException(nameof(peerPool));
            _blockTree          = blockTree ?? throw new ArgumentNullException(nameof(blockTree));

            _syncMode          = new SyncModeSelector(_syncPeerPool, _syncConfig, logManager);
            _syncMode.Changed += (s, e) => RequestSynchronization(SyncTriggerType.SyncModeChange);
            _syncMode.Changed += (s, e) =>
            {
                if (_blocksSyncAllocation == null && _syncMode.Current != SyncMode.StateNodes)
                {
                    AllocateBlocksSync();
                }

                if (_syncMode.Current == SyncMode.StateNodes)
                {
                    FreeBlocksSyncAllocation();
                }
            };

            // make ctor parameter?
            _blockDownloader = new BlockDownloader(_blockTree, blockValidator, sealValidator, logManager);
        }
Beispiel #3
0
        public Synchronizer(IBlockTree blockTree,
                            IBlockValidator blockValidator,
                            ISealValidator sealValidator,
                            IEthSyncPeerPool peerPool,
                            ISyncConfig syncConfig,
                            INodeDataDownloader nodeDataDownloader,
                            ILogManager logManager)
        {
            _logger             = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager));
            _syncConfig         = syncConfig ?? throw new ArgumentNullException(nameof(syncConfig));
            _nodeDataDownloader = nodeDataDownloader ?? throw new ArgumentNullException(nameof(nodeDataDownloader));
            _syncPeerPool       = peerPool ?? throw new ArgumentNullException(nameof(peerPool));
            _blockTree          = blockTree ?? throw new ArgumentNullException(nameof(blockTree));

            SyncProgressResolver syncProgressResolver = new SyncProgressResolver(_blockTree, _nodeDataDownloader, logManager);

            _syncMode = new SyncModeSelector(syncProgressResolver, _syncPeerPool, _syncConfig, logManager);

            // make ctor parameter?
            _blockDownloader = new BlockDownloader(_blockTree, blockValidator, sealValidator, logManager);
        }