public Eth63ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager sync, ILogManager logManager, IPerfService perfService) : base(p2PSession, serializer, sync, logManager, perfService) { }
private async Task InitializeNetwork( IReceiptStorage receiptStorage, IHeaderValidator headerValidator, TransactionValidator txValidator) { if (!_initConfig.NetworkEnabled) { if (_logger.IsWarn) _logger.Warn($"Skipping network init due to ({nameof(IInitConfig.NetworkEnabled)} set to false)"); return; } _syncManager = new QueueBasedSyncManager( _dbProvider.StateDb, _blockTree, _blockValidator, headerValidator, txValidator, _logManager, _configProvider.GetConfig<IBlockchainConfig>(), _perfService, receiptStorage); InitDiscovery(); await InitPeer().ContinueWith(initPeerTask => { if (initPeerTask.IsFaulted) { _logger.Error("Unable to init peer manager.", initPeerTask.Exception); } });; await StartSync().ContinueWith(initNetTask => { if (initNetTask.IsFaulted) { _logger.Error("Unable to start sync.", initNetTask.Exception); } }); await StartDiscovery().ContinueWith(initDiscoveryTask => { if (initDiscoveryTask.IsFaulted) { _logger.Error("Unable to start discovery protocol.", initDiscoveryTask.Exception); } }); await StartPeer().ContinueWith(initPeerManagerTask => { if (initPeerManagerTask.IsFaulted) { _logger.Error("Unable to start peer manager.", initPeerManagerTask.Exception); } }); if (_logger.IsInfo) _logger.Info($"Node is up and listening on {_enode.IpAddress}:{_enode.P2PPort}"); if (_logger.IsInfo) _logger.Info($"{ClientVersion.Description}"); if (_logger.IsInfo) _logger.Info(_enode.Info); if (_logger.IsInfo) _logger.Info($"enode address for test purposes: {_enode.Address}"); }
public DebugPage() { this.InitializeComponent(); this.SetRequestedTheme(); this.workbook = Ioc.Resolve <IWorkbook>(); this.synchronizationManager = Ioc.Resolve <ISynchronizationManager>(); this.persistence = Ioc.Resolve <IPersistenceLayer>(); this.messageBoxService = Ioc.Resolve <IMessageBoxService>(); this.DataContext = Ioc.Build <DebugPageViewModel>(); this.Loaded += this.OnLoaded; var descriptors = new List <BrushDescriptor>(); foreach (var key in ApplicationBrushes.GetKeys()) { descriptors.Add(new BrushDescriptor { Key = key, Brush = this.FindResource <SolidColorBrush>(key) }); } this.ItemsControlBrushes.ItemsSource = descriptors; }
public async Task ShouldRequestBlocksFromAheadFinalizedCheckpoint() { // Arrange IServiceCollection testServiceCollection = TestSystem.BuildTestServiceCollection(useStore: true); INetworkPeering mockNetworkPeering = Substitute.For <INetworkPeering>(); testServiceCollection.AddSingleton <INetworkPeering>(mockNetworkPeering); ServiceProvider testServiceProvider = testServiceCollection.BuildServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); IForkChoice forkChoice = testServiceProvider.GetService <IForkChoice>(); // Get genesis store initialise MemoryStoreProvider with the state IStore store = testServiceProvider.GetService <IStore>(); await forkChoice.InitializeForkChoiceStoreAsync(store, state); // Act PeeringStatus peeringStatus = new PeeringStatus( new ForkVersion(new byte[4] { 0, 0, 0, 0 }), new Root(Enumerable.Repeat((byte)0x34, 32).ToArray()), Epoch.One, new Root(Enumerable.Repeat((byte)0x56, 32).ToArray()), new Slot(2)); ISynchronizationManager synchronizationManager = testServiceProvider.GetService <ISynchronizationManager>(); await synchronizationManager.OnStatusResponseReceived("peer", peeringStatus); // Assert await mockNetworkPeering.Received(1) .RequestBlocksAsync("peer", Arg.Any <Root>(), Arg.Any <Slot>(), Arg.Any <Slot>()); await mockNetworkPeering.DidNotReceive().DisconnectPeerAsync("peer"); }
//TODO Timer to periodically check active peers and move new to active based on max size and compatibility - stats and capabilities + update peers in synchronization manager //TODO Remove active and synch on disconnect //TODO Update Stats on disconnect, other events //TODO update runner to run discovery public PeerManager(IRlpxPeer localPeer, IDiscoveryManager discoveryManager, ISynchronizationManager synchronizationManager, INodeStatsProvider nodeStatsProvider, IPeerStorage peerStorage, INodeFactory nodeFactory, IConfigProvider configurationProvider, IPerfService perfService, ILogManager logManager) { _logger = logManager?.GetClassLogger() ?? throw new ArgumentNullException(nameof(logManager)); _localPeer = localPeer; _configurationProvider = configurationProvider.GetConfig <NetworkConfig>(); _synchronizationManager = synchronizationManager; _nodeStatsProvider = nodeStatsProvider; _discoveryManager = discoveryManager; _perfService = perfService; _nodeFactory = nodeFactory; _isDiscoveryEnabled = _discoveryManager != null; if (_isDiscoveryEnabled) { discoveryManager.NodeDiscovered += async(s, e) => await OnNodeDiscovered(s, e); } localPeer.ConnectionInitialized += OnRemoteConnectionInitialized; synchronizationManager.SyncFailed += async(s, e) => await OnSyncFailed(s, e); _peerStorage = peerStorage; _peerStorage.StartBatch(); }
public void Initialize() { _logManager = new OneLoggerLogManager(new SimpleConsoleLogger()); _configurationProvider = new JsonConfigProvider(); ((NetworkConfig)_configurationProvider.GetConfig <NetworkConfig>()).DbBasePath = Path.Combine(Path.GetTempPath(), "PeerManagerTests"); if (!Directory.Exists(_configurationProvider.GetConfig <NetworkConfig>().DbBasePath)) { Directory.CreateDirectory(_configurationProvider.GetConfig <NetworkConfig>().DbBasePath); } _nodeFactory = new NodeFactory(); _localPeer = new TestRlpxPeer(); var keyProvider = new PrivateKeyProvider(new CryptoRandom()); var key = keyProvider.PrivateKey.PublicKey; _synchronizationManager = Substitute.For <ISynchronizationManager>(); var nodeTable = new NodeTable(_nodeFactory, Substitute.For <IKeyStore>(), new NodeDistanceCalculator(_configurationProvider), _configurationProvider, _logManager); nodeTable.Initialize(new NodeId(key)); _discoveryManager = new DiscoveryManager(new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, new DiscoveryMessageFactory(_configurationProvider), Substitute.For <IEvictionManager>(), new NodeStatsProvider(_configurationProvider), _configurationProvider, _logManager), _nodeFactory, nodeTable, new DiscoveryStorage(_configurationProvider, _nodeFactory, _logManager, new PerfService(_logManager)), _configurationProvider, _logManager); _discoveryManager.MessageSender = Substitute.For <IMessageSender>(); _peerManager = new PeerManager(_localPeer, _discoveryManager, _synchronizationManager, new NodeStatsProvider(_configurationProvider), new PeerStorage(_configurationProvider, _nodeFactory, _logManager, new PerfService(_logManager)), _nodeFactory, _configurationProvider, new PerfService(_logManager), _logManager); }
public ProtocolsManager( ISynchronizationManager synchronizationManager, ITransactionPool transactionPool, IDiscoveryApp discoveryApp, IMessageSerializationService serializationService, IRlpxPeer localPeer, INodeStatsManager nodeStatsManager, IProtocolValidator protocolValidator, INetworkStorage peerStorage, IPerfService perfService, ILogManager logManager) { _syncManager = synchronizationManager ?? throw new ArgumentNullException(nameof(synchronizationManager)); _transactionPool = transactionPool ?? throw new ArgumentNullException(nameof(transactionPool)); _discoveryApp = discoveryApp ?? throw new ArgumentNullException(nameof(discoveryApp)); _serializer = serializationService ?? throw new ArgumentNullException(nameof(serializationService)); _localPeer = localPeer ?? throw new ArgumentNullException(nameof(localPeer)); _stats = nodeStatsManager ?? throw new ArgumentNullException(nameof(nodeStatsManager)); _protocolValidator = protocolValidator ?? throw new ArgumentNullException(nameof(protocolValidator)); _perfService = perfService ?? throw new ArgumentNullException(nameof(perfService)); _peerStorage = peerStorage ?? throw new ArgumentNullException(nameof(peerStorage)); _logManager = logManager ?? throw new ArgumentNullException(nameof(logManager)); _logger = _logManager.GetClassLogger(); _syncManager.SyncEvent += OnSyncEvent; localPeer.SessionCreated += SessionCreated; }
public override void Init(SubsystemConfig config) { _config = (ElectionManagerConfig)config; _votingResultManager = Application.GetSubsystemOrThrow <IVotingResultManager>(); _recognitionManager = Application.GetSubsystemOrThrow <IRecognitionManager>(); _fileSystemManager = Application.GetSubsystemOrThrow <IFileSystemManager>(); _syncManager = Application.GetSubsystemOrThrow <ISynchronizationManager>(); }
public Eth63ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager syncManager, ILogManager logManager, IPerfService perfService, IBlockTree blockTree, ITransactionPool transactionPool, ITimestamp timestamp) : base(p2PSession, serializer, syncManager, logManager, perfService, blockTree, transactionPool, timestamp) { }
public Eth63ProtocolHandler( ISession session, IMessageSerializationService serializer, INodeStatsManager nodeStatsManager, ISynchronizationManager syncManager, ILogManager logManager, IPerfService perfService, ITransactionPool transactionPool) : base(session, serializer, nodeStatsManager, syncManager, logManager, perfService, transactionPool) { }
public RpcPeeringStatusProcessor(ILogger <RpcPeeringStatusProcessor> logger, ISynchronizationManager synchronizationManager, PeerManager peerManager) : base(logger, MaximumQueue) { _logger = logger; _synchronizationManager = synchronizationManager; _peerManager = peerManager; }
public Eth62ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager sync, ILogManager logManager) : base(p2PSession, serializer, logManager) { _sync = sync; }
public PeerDiscoveredProcessor(ILogger <PeerDiscoveredProcessor> logger, ISynchronizationManager synchronizationManager, PeerManager peerManager) : base(logger, MaximumQueue) { _logger = logger; _synchronizationManager = synchronizationManager; _peerManager = peerManager; }
public ToodleDoSynchronizationProvider(ISynchronizationManager synchronizationManager, ICryptoService cryptoService) : base(synchronizationManager, cryptoService) { this.service = new ToodleDoService(() => this.key, AppId); this.service.OnWebException += (s, e) => this.OnSynchronizationFailed(string.Format(ToodleDoResources.ToodleDo_SyncErrorFormat, e.Item.Message)); this.email = this.Workbook.Settings.GetValue <string>(ToodleDoSettings.ToodleDoLogin); this.password = this.Workbook.Settings.GetValue <byte[]>(ToodleDoSettings.ToodleDoPassword); }
protected ActiveSyncSynchronizationProviderBase(ISynchronizationManager synchronizationManager, ICryptoService crypto, string deviceId) : base(synchronizationManager, new ActiveSyncService(), crypto) { if (string.IsNullOrEmpty(deviceId)) { throw new ArgumentNullException("deviceId"); } this.deviceId = deviceId; }
public VercorsSynchronizationProvider(ISynchronizationManager synchronizationManager, ICryptoService cryptoService, IVercorsService vercorsService) : base(synchronizationManager, cryptoService) { if (vercorsService == null) { throw new ArgumentNullException("vercorsService"); } this.service = vercorsService; }
protected ExchangeSynchronizationProviderBase(ISynchronizationManager synchronizationManager, TSyncService syncService, ICryptoService crypto) : base(synchronizationManager, crypto) { if (syncService == null) { throw new ArgumentNullException(nameof(syncService)); } this.syncService = syncService; }
public static async Task InitializeAsync(IWorkbook workbook, ISynchronizationManager synchronizationManager, ICryptoService cryptoService, IVercorsService vercorsService, bool awaitPrepareProvider) { if (synchronizationManager == null) { throw new ArgumentNullException("synchronizationManager"); } if (cryptoService == null) { throw new ArgumentNullException("cryptoService"); } if (vercorsService == null) { throw new ArgumentNullException("vercorsService"); } await synchronizationManager.InitializeAsync(); synchronizationManager.RegisterProvider( SynchronizationService.ToodleDo, () => new ToodleDoSynchronizationProvider(synchronizationManager, cryptoService)); synchronizationManager.RegisterProvider( SynchronizationService.Exchange, () => new ExchangeSynchronizationProvider(synchronizationManager, cryptoService)); synchronizationManager.RegisterProvider( SynchronizationService.ExchangeEws, () => new ExchangeEwsSynchronizationProvider(synchronizationManager, cryptoService)); synchronizationManager.RegisterProvider( SynchronizationService.OutlookActiveSync, () => new OutlookActiveSyncSynchronizationProvider(synchronizationManager, cryptoService, workbook.Settings.GetValue <string>(CoreSettings.DeviceId))); synchronizationManager.RegisterProvider( SynchronizationService.Vercors, () => new VercorsSynchronizationProvider(synchronizationManager, cryptoService, vercorsService)); synchronizationManager.RegisterProvider( SynchronizationService.ActiveSync, () => new ActiveSyncSynchronizationProvider(synchronizationManager, cryptoService, workbook.Settings.GetValue <string>(CoreSettings.DeviceId))); synchronizationManager.AttachWorkbook(workbook); if (awaitPrepareProvider) { await synchronizationManager.PrepareProviderAsync(); } else #pragma warning disable 4014 { synchronizationManager.PrepareProviderAsync(); } #pragma warning restore 4014 }
public AdvancedSyncSettingsPageViewModel(IWorkbook workbook, ISynchronizationManager synchronizationManager, IPlatformService platformService, IMessageBoxService messageBoxService, INavigationService navigationService, INotificationService notificationService) : base(workbook, navigationService) { if (synchronizationManager == null) { throw new ArgumentNullException(nameof(synchronizationManager)); } if (platformService == null) { throw new ArgumentNullException(nameof(platformService)); } if (messageBoxService == null) { throw new ArgumentNullException(nameof(messageBoxService)); } if (notificationService == null) { throw new ArgumentNullException(nameof(notificationService)); } this.synchronizationManager = synchronizationManager; this.platformService = platformService; this.messageBoxService = messageBoxService; this.navigationService = navigationService; this.notificationService = notificationService; this.items = new ObservableCollection <AdvancedSyncModeItem> { new AdvancedSyncModeItem( StringResources.SyncAdvanced_ReplaceTitle, StringResources.SyncAdvanced_ReplaceDescription, ResourcesLocator.SyncAdvancedModeReplace, () => this.ReplaceAsync()), new AdvancedSyncModeItem( StringResources.About_Help, StringResources.Sync_FixProblems, ResourcesLocator.SyncAdvancedModeDiag, () => this.OpenSyncHelp()), new AdvancedSyncModeItem( StringResources.SyncAdvanced_DiagnosticsTitle, StringResources.SyncAdvanced_DiagnosticsDescription, ResourcesLocator.SyncAdvancedModeDiag, () => this.Diag()), }; if (this.SynchronizationManager.ActiveProvider != null && this.SynchronizationManager.ActiveProvider.CanDeleteAccount) { this.items.Add(new AdvancedSyncModeItem( StringResources.SyncAdvanced_DeleteAccountTitle, StringResources.SyncAdvanced_DeleteAccountDescription, ResourcesLocator.SyncAdvancedModeDelete, () => this.Delete())); } }
internal AppJobScheduler(IWorkbook workbook, ISynchronizationManager synchronizationManager, Func <IEnumerable <FolderItemViewModel> > getFolderItems) { if (workbook == null) { throw new ArgumentNullException(nameof(workbook)); } if (synchronizationManager == null) { throw new ArgumentNullException(nameof(synchronizationManager)); } if (getFolderItems == null) { throw new ArgumentNullException(nameof(getFolderItems)); } this.workbook = workbook; this.workbook.FolderAdded += (s, e) => this.HandleChange(); this.workbook.FolderChanged += (s, e) => this.HandleChange(); this.workbook.FolderRemoved += (s, e) => this.HandleChange(); this.workbook.ContextAdded += (s, e) => this.HandleChange(); this.workbook.ContextChanged += (s, e) => this.HandleChange(); this.workbook.ContextRemoved += (s, e) => this.HandleChange(); foreach (var view in workbook.Views) { view.PropertyChanged += (s, e) => this.HandleChange(); } this.synchronizationManager = synchronizationManager; this.getFolderItems = getFolderItems; var dispatcher = Window.Current.Dispatcher; // use timer created through ThreadPoolTimer so that timer runs even when the app is minimized - this is not the case of a DispatcherTimer // because of this, we need to switch back to the dispatcher context when the timer tick so that it's safe to call UI related stuff (from binding updates // for example) this.updateTasksTimer = ThreadPoolTimer.CreatePeriodicTimer( (d) => dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => this.OnUpdateTasksTimerTick()), TimeSpan.FromSeconds(UpdateTaskIntervalSeconds)); this.syncTimer = ThreadPoolTimer.CreatePeriodicTimer( (d) => dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => this.OnSyncTimerTick()), TimeSpan.FromSeconds(SyncIntervalSeconds)); this.afterChangeTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(TimerIntervalMs) }; this.afterChangeTimer.Tick += this.OnAfterChangeTimerTick; this.lastCheck = DateTime.MinValue; }
public void Initialize() { NetworkNodeDecoder.Init(); _timestamp = new Timestamp(); _logManager = new OneLoggerLogManager(new SimpleConsoleLogger()); _configurationProvider = new ConfigProvider(); INetworkConfig networkConfig = _configurationProvider.GetConfig <INetworkConfig>(); networkConfig.DbBasePath = Path.Combine(Path.GetTempPath(), "PeerManagerTests"); networkConfig.IsActivePeerTimerEnabled = false; networkConfig.IsDiscoveryNodesPersistenceOn = false; networkConfig.IsPeersPersistenceOn = false; if (!Directory.Exists(networkConfig.DbBasePath)) { Directory.CreateDirectory(networkConfig.DbBasePath); } var syncManager = Substitute.For <ISynchronizationManager>(); Block genesisBlock = Build.A.Block.Genesis.TestObject; syncManager.Head.Returns(genesisBlock.Header); syncManager.Genesis.Returns(genesisBlock.Header); _nodeFactory = new NodeFactory(LimboLogs.Instance); _localPeer = new TestRlpxPeer(); var keyProvider = new PrivateKeyGenerator(new CryptoRandom()); var key = keyProvider.Generate().PublicKey; _synchronizationManager = Substitute.For <ISynchronizationManager>(); IStatsConfig statsConfig = _configurationProvider.GetConfig <IStatsConfig>(); var nodeTable = new NodeTable(_nodeFactory, Substitute.For <IKeyStore>(), new NodeDistanceCalculator(networkConfig), networkConfig, _logManager); nodeTable.Initialize(new NodeId(key)); _discoveryManager = new DiscoveryManager(new NodeLifecycleManagerFactory(_nodeFactory, nodeTable, new DiscoveryMessageFactory(networkConfig, _timestamp), Substitute.For <IEvictionManager>(), new NodeStatsProvider(_configurationProvider.GetConfig <IStatsConfig>(), _nodeFactory, _logManager, true), networkConfig, _logManager), _nodeFactory, nodeTable, new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)), networkConfig, _logManager); _discoveryManager.MessageSender = Substitute.For <IMessageSender>(); _transactionPool = NullTransactionPool.Instance; _blockTree = Substitute.For <IBlockTree>(); var app = new DiscoveryApp(new NodesLocator(nodeTable, _discoveryManager, _configurationProvider, _logManager), _discoveryManager, _nodeFactory, nodeTable, Substitute.For <IMessageSerializationService>(), new CryptoRandom(), Substitute.For <INetworkStorage>(), networkConfig, _logManager, new PerfService(_logManager)); app.Initialize(key); var sessionLogger = new PeerSessionLogger(_logManager, _configurationProvider, new PerfService(_logManager)); sessionLogger.Init(Path.GetTempPath()); var networkStorage = new NetworkStorage("test", networkConfig, _logManager, new PerfService(_logManager)); _peerManager = new PeerManager(_localPeer, app, _synchronizationManager, new NodeStatsProvider(statsConfig, _nodeFactory, _logManager, true), networkStorage, _nodeFactory, _configurationProvider, new PerfService(_logManager), _transactionPool, _logManager, sessionLogger); _peerManager.Init(true); }
public virtual void Initialize() { this.testRunner = this.CreateTestRunner(this.TestContext.TestName); this.workbook = this.testRunner.Workbook; Ioc.RegisterInstance <IWorkbook, IWorkbook>(this.workbook); this.synchronizationManager = this.testRunner.Manager; this.synchronizationManager.OperationFailed += (s, e) => Assert.Fail("Synchronization failed: " + e.Message); this.testRunner.BeforeTest().Wait(); this.OnTestInitialize(); }
public override void Init(SubsystemConfig config) { _config = (WorkflowManagerConfig)config; _syncManager = Application.GetSubsystemOrThrow <ISynchronizationManager>(); _fileSystemManager = Application.GetSubsystemOrThrow <IFileSystemManager>(); _scannerManager = Application.GetSubsystemOrThrow <IScannerManager>(); StateChanged += (sender, e) => Logger.LogInfo(Message.WorkflowStateChanged, e.State); var keyboard = (IKeyboardManager)Application.GetSubsystemOrThrow <UnionKeyboard>(); keyboard.KeyPressed += LogUserKeyPressed; LoadErrorState(); InitWorkflow(); }
public RlpxPeer(NodeId localNodeId, int localPort, ISynchronizationManager synchronizationManager, IMessageSerializationService messageSerializationService, IEncryptionHandshakeService encryptionHandshakeService, INodeStatsProvider nodeStatsProvider, ILogManager logManager, IPerfService perfService) { _encryptionHandshakeService = encryptionHandshakeService ?? throw new ArgumentNullException(nameof(encryptionHandshakeService)); _nodeStatsProvider = nodeStatsProvider ?? throw new ArgumentNullException(nameof(nodeStatsProvider)); _logManager = logManager ?? throw new ArgumentNullException(nameof(logManager)); _perfService = perfService; _logger = logManager.GetClassLogger(); _serializationService = messageSerializationService ?? throw new ArgumentNullException(nameof(messageSerializationService)); _synchronizationManager = synchronizationManager ?? throw new ArgumentNullException(nameof(synchronizationManager)); LocalNodeId = localNodeId ?? throw new ArgumentNullException(nameof(localNodeId)); _localPort = localPort; }
protected override Predicate <ITask> BuildTaskPredicateCore() { return(task => { if (syncManager == null && Ioc.HasType <ISynchronizationManager>()) { syncManager = Ioc.Resolve <ISynchronizationManager>(); syncManager.OperationCompleted += (s, e) => this.Tasks.ToList().ForEach(t => this.OnTaskPropertyChanged(t, new PropertyChangedEventArgs(string.Empty))); } return string.IsNullOrWhiteSpace(task.SyncId) || (syncManager != null && syncManager.IsSyncConfigured && syncManager.Metadata != null && syncManager.Metadata.EditedTasks.ContainsKey(task.Id)); }); }
public async Task ShouldNotRequestIfHeadBehind() { // Arrange IServiceCollection testServiceCollection = TestSystem.BuildTestServiceCollection(useStore: true); INetworkPeering mockNetworkPeering = Substitute.For <INetworkPeering>(); testServiceCollection.AddSingleton <INetworkPeering>(mockNetworkPeering); ServiceProvider testServiceProvider = testServiceCollection.BuildServiceProvider(); BeaconState state = TestState.PrepareTestState(testServiceProvider); IForkChoice forkChoice = testServiceProvider.GetService <IForkChoice>(); // Get genesis store initialise MemoryStoreProvider with the state IStore store = testServiceProvider.GetService <IStore>(); await forkChoice.InitializeForkChoiceStoreAsync(store, state); // Move forward time TimeParameters timeParameters = testServiceProvider.GetService <IOptions <TimeParameters> >().Value; ulong targetTime = 2 * 6; // slot 2 for (ulong timeSinceGenesis = 1; timeSinceGenesis <= targetTime; timeSinceGenesis++) { ulong time = state.GenesisTime + timeSinceGenesis; await forkChoice.OnTickAsync(store, time); if (timeSinceGenesis % timeParameters.SecondsPerSlot == 0) { BeaconBlock block = TestBlock.BuildEmptyBlockForNextSlot(testServiceProvider, state, BlsSignature.Zero); SignedBeaconBlock signedBlock = TestState.StateTransitionAndSignBlock(testServiceProvider, state, block); await forkChoice.OnBlockAsync(store, signedBlock); } } // Act PeeringStatus peeringStatus = new PeeringStatus( new ForkVersion(new byte[4] { 0, 0, 0, 0 }), Root.Zero, Epoch.Zero, new Root(Enumerable.Repeat((byte)0x56, 32).ToArray()), new Slot(1)); ISynchronizationManager synchronizationManager = testServiceProvider.GetService <ISynchronizationManager>(); await synchronizationManager.OnStatusResponseReceived("peer", peeringStatus); // Assert await mockNetworkPeering.DidNotReceive() .RequestBlocksAsync("peer", Arg.Any <Root>(), Arg.Any <Slot>(), Arg.Any <Slot>()); await mockNetworkPeering.DidNotReceive().DisconnectPeerAsync("peer"); }
public SyncProviderViewModel(ISynchronizationProvider activeProvider, ISynchronizationManager synchronizationManager, bool isRecommended, Action configure = null, Action remove = null) { if (activeProvider == null) { throw new ArgumentNullException("activeProvider"); } this.provider = activeProvider; this.isRecommended = isRecommended; this.synchronizationMetadata = synchronizationManager.Metadata; if (configure == null) { configure = () => { } } ; if (remove == null) { remove = () => { } } ; this.configureCommand = new RelayCommand(configure); this.removeCommand = new RelayCommand(remove); if (this.provider != null && !string.IsNullOrWhiteSpace(this.provider.LoginInfo)) { if (this.provider.LoginInfo.Contains("@")) { var split = this.provider.LoginInfo.Split('@'); this.loginInfoPrimary = split[0]; if (split.Length > 1) { this.loginInfoSecondary = "@" + split[1]; } } else { this.loginInfoPrimary = this.provider.LoginInfo; } } else { this.loginInfoPrimary = string.Empty; this.loginInfoSecondary = string.Empty; } } }
public static void SetDueAndAdjustReminder(this ITask task, DateTime?newDate, IEnumerable <ITask> impactedTasks, bool showNotification = false) { INotificationService notificationService = Ioc.Resolve <INotificationService>(); ISynchronizationManager syncManager = Ioc.Resolve <ISynchronizationManager>(); var oldDate = task.Due; // change due date (and if we sync with Exchange, start date might be updated too) task.Due = newDate; syncManager.SetDueDate(newDate, task.Start, v => task.Start = v); task.Modified = DateTime.Now; // check if we must update reminder date if (!task.Alarm.HasValue || !newDate.HasValue || !oldDate.HasValue) { if (showNotification) { if (newDate.HasValue) { var dateLong = string.Format("{0} {1}", newDate.Value.ToString("ddddd"), newDate.Value.ToString("M")); notificationService.ShowNotification(string.Format(StringResources.Notification_DueDateUpdatedFormat, dateLong)); } else { notificationService.ShowNotification(StringResources.Notification_DueDateRemoved); } } return; } int days = (int)(newDate.Value - oldDate.Value).TotalDays; task.Alarm = task.Alarm.Value.AddDays(days); if (showNotification) { string newReminderDatetime = string.Format("{0} {1}", task.Alarm.Value.ToString("M"), task.Alarm.Value.ToString("t")); string toastMessage = string.Format(StringResources.Dialog_ReminderUpdatedDateFormat, newReminderDatetime); if (impactedTasks.Count(t => t.Alarm.HasValue) > 1) { toastMessage = StringResources.Dialog_RemindersUpdated; } notificationService.ShowNotification(toastMessage); } }
public Eth62ProtocolHandler( IP2PSession p2PSession, IMessageSerializationService serializer, ISynchronizationManager syncManager, ILogManager logManager, IPerfService perfService, IBlockTree blockTree, ITransactionPool transactionPool, ITimestamp timestamp) : base(p2PSession, serializer, logManager) { SyncManager = syncManager; _perfService = perfService ?? throw new ArgumentNullException(nameof(perfService)); _blockTree = blockTree; _transactionPool = transactionPool; _timestamp = timestamp; }
public void SetUp() { _mockLoggerOptionsMonitor = Substitute.For <IOptionsMonitor <ConsoleLoggerOptions> >(); _mockLoggerOptionsMonitor.CurrentValue.Returns(new ConsoleLoggerOptions() { Format = ConsoleLoggerFormat.Systemd, DisableColors = true, IncludeScopes = true, TimestampFormat = " HH':'mm':'sszz " }); _loggerFactory = new LoggerFactory(new [] { new ConsoleLoggerProvider(_mockLoggerOptionsMonitor) }); _mockMothra = new MockMothra(); // mockMothra.StartCalled += settings => // { // ThreadPool.QueueUserWorkItem(x => // { // Thread.Sleep(TimeSpan.FromMilliseconds(100)); // byte[] peerUtf8 = Encoding.UTF8.GetBytes("peer1"); // mockMothra.RaisePeerDiscovered(peerUtf8); // }); // }; _mockForkChoice = Substitute.For <IForkChoice>(); _mockSynchronizationManager = Substitute.For <ISynchronizationManager>(); _mockStore = Substitute.For <IStore>(); _mockStore.IsInitialized.Returns(true); _mockMothraConfigurationMonitor = Substitute.For <IOptionsMonitor <MothraConfiguration> >(); _mockMothraConfigurationMonitor.CurrentValue.Returns(new MothraConfiguration()); // TODO: Replace with MothraNetworkPeering and mockMothra. _mockNetworkPeering = Substitute.For <INetworkPeering>(); _dataDirectory = new DataDirectory("data"); _peerManager = new PeerManager(_loggerFactory.CreateLogger <PeerManager>()); _peerDiscoveredProcessor = new PeerDiscoveredProcessor( _loggerFactory.CreateLogger <PeerDiscoveredProcessor>(), _mockSynchronizationManager, _peerManager); _rpcPeeringStatusProcessor = new RpcPeeringStatusProcessor( _loggerFactory.CreateLogger <RpcPeeringStatusProcessor>(), _mockSynchronizationManager, _peerManager); _rpcBeaconBlocksByRangeProcessor = new RpcBeaconBlocksByRangeProcessor(_loggerFactory.CreateLogger <RpcBeaconBlocksByRangeProcessor>(), _mockNetworkPeering, _mockForkChoice, _mockStore); _signedBeaconBlockProcessor = new SignedBeaconBlockProcessor( _loggerFactory.CreateLogger <SignedBeaconBlockProcessor>(), _mockMothraConfigurationMonitor, Substitute.For <IFileSystem>(), _mockForkChoice, _mockStore, _dataDirectory, _peerManager); }
public override void Init(SubsystemConfig config) { _config = (ElectionManagerConfig)config; _votingResultManager = Application.GetSubsystemOrThrow<IVotingResultManager>(); _recognitionManager = Application.GetSubsystemOrThrow<IRecognitionManager>(); _fileSystemManager = Application.GetSubsystemOrThrow<IFileSystemManager>(); _syncManager = Application.GetSubsystemOrThrow<ISynchronizationManager>(); }
public override void Init(SubsystemConfig config) { _config = (WorkflowManagerConfig)config; _syncManager = Application.GetSubsystemOrThrow<ISynchronizationManager>(); _fileSystemManager = Application.GetSubsystemOrThrow<IFileSystemManager>(); _scannerManager = Application.GetSubsystemOrThrow<IScannerManager>(); StateChanged += (sender, e) => Logger.LogInfo(Message.WorkflowStateChanged, e.State); var keyboard = (IKeyboardManager)Application.GetSubsystemOrThrow<UnionKeyboard>(); keyboard.KeyPressed += LogUserKeyPressed; LoadErrorState(); InitWorkflow(); }
protected override void Initialize(WorkflowExecutionContext context) { base.Initialize(context); var app = CoreApplication.Instance; _workflowManager = app.GetSubsystemOrThrow<IWorkflowManager>(); _scannerManager = app.GetSubsystemOrThrow<IScannerManager>(); _electionManager = app.GetSubsystemOrThrow<IElectionManager>(); _votingResultManager = app.GetSubsystemOrThrow<IVotingResultManager>(); _syncManager = app.GetSubsystemOrThrow<ISynchronizationManager>(); _soundManager = app.GetSubsystemOrThrow<ISoundManager>(); _keyboard = app.GetSubsystemOrThrow<UnionKeyboard>(); _configManager = app.GetSubsystemOrThrow<IConfigurationManager>(); _fileSystemManager = app.GetSubsystemOrThrow<IFileSystemManager>(); _printingManager = app.GetSubsystemOrThrow<IPrintingManager>(); _recognitionManager = app.GetSubsystemOrThrow<IRecognitionManager>(); _logger = _workflowManager.Logger; }