public Task StartAsync(CancellationToken cancellationToken)
 {
     foreach (var network in waiters.All().Select(w => w.Network))
     {
         data.Add(network, new NetworkFingerprintData()
         {
             waiter = waiters.GetWaiter(network),
             DefaultDistribution = network.CryptoCode == "BTC" ? _DefaultBTC : null
         });
     }
     subscription = this.eventAggregator.Subscribe <RawBlockEvent>(evt =>
     {
         var d = data[evt.Network];
         // If we catchup lot's of old block we do not care about their
         // distribution.
         if (d.waiter.State != BitcoinDWaiterState.Ready)
         {
             return;
         }
         var blockDistribution = FingerprintDistribution.Calculate(evt.Block);
         lock (d)
         {
             d.BlockDistributions.Enqueue(blockDistribution);
             d.Distribution += blockDistribution;
             if (d.BlockDistributions.Count > BlockWindow)
             {
                 d.Distribution -= d.BlockDistributions.Dequeue();
             }
         }
     });
     return(Task.CompletedTask);
 }
 public Task StartAsync(CancellationToken cancellationToken)
 {
     subscription = this.eventAggregator.Subscribe <RawBlockEvent>(evt =>
     {
         var d = data[evt.Network];
         // If we catchup lot's of old block we do not care about their
         // distribution.
         if (d.waiter.State != BitcoinDWaiterState.Ready)
         {
             return;
         }
         var blockDistribution = FingerprintDistribution.Calculate(evt.Block);
         lock (d)
         {
             d.BlockDistributions.Enqueue(blockDistribution);
             d.Distribution += blockDistribution;
             if (d.BlockDistributions.Count > BlockWindow)
             {
                 d.Distribution -= d.BlockDistributions.Dequeue();
             }
         }
     });
     return(Task.CompletedTask);
 }