public void CreateServices(BitcoinNode bitcoinNode, CancellationToken cancellationToken)
 {
     foreach (NodeServiceInfo serviceInfo in services)
     {
         serviceInfo.Service = serviceInfo.ServiceFactory.Create(bitcoinNode, cancellationToken);
     }
 }
 public INodeService Create(BitcoinNode node, CancellationToken cancellationToken)
 {
     return new TestNodeService(log, cancellationToken, shutdownTimeout, disposeShouldFail);
 }
        public void StartNode()
        {
            SQLiteBlockchainStorage storage = SQLiteBlockchainStorage.Open(applicationContext.Settings.BlockchainFolder);
            BitcoinNode node = new BitcoinNode(storage);
            try
            {
                node.Start();
            }
            catch (Exception ex)
            {
                viewContext.ShowError(ex);
                //todo: dispose storage?
                return;
            }
            BitcoinNode oldNode = applicationContext.BitcoinNode;
            applicationContext.BitcoinNode = node;
            if (oldNode != null)
            {
                //todo: unregister handlers?
            }

            //todo: unregister handlers?
            const string nodeStateChangedEventType = "NodeStateChanged";
            node.PropertyChanged += (sender, args) => applicationContext.EventManager.Notify(nodeStateChangedEventType);
            node.ConnectionCollection.Changed += () => applicationContext.EventManager.Notify(nodeStateChangedEventType);
            node.Blockchain.StateChanged += () => applicationContext.EventManager.Notify(nodeStateChangedEventType);

            //todo: updates are too frequent, consider adding a delay to EventManager
            applicationContext.EventManager.Watch(nodeStateChangedEventType, OnNodePropertyChanged);

            UpdateValues();
        }