Exemplo n.º 1
0
        public void GetDeltaIndexRangeFromPeers(ulong index, int range)
        {
            var deltaHistoryRequest = new DeltaHistoryRequest
            {
                Height = (uint)index, Range = (uint)range
            };

            _deltaHistoryRanker = new DeltaHistoryRanker(deltaHistoryRequest);
        }
Exemplo n.º 2
0
 private async Task SyncDeltaIndexes()
 {
     while (_isRunning)
     {
         if (_deltaHistoryRanker != null)
         {
             var peers            = _deltaHeightWatcher.DeltaHeightRanker.GetPeers();
             var messageCount     = Math.Min(_minimumPeers, 50);
             var minimumThreshold = messageCount * _threshold;
             var score            = _deltaHistoryRanker.GetHighestScore();
             if (score > minimumThreshold)
             {
                 var deltaIndexes = _deltaHistoryRanker.GetMostPopular();
                 _deltaHistoryRanker = null;
                 _scoredDeltaIndexRangeSubject.OnNext(deltaIndexes);
                 continue;
             }
             _peerClient.SendMessageToPeers(_deltaHistoryRanker.DeltaHistoryRequest, peers);
         }
         await Task.Delay(2000);
     }
 }