Esempio n. 1
0
        private void RequestMissingTxs()
        {
            var listOfMissingTxToRequest = new List <KeyValuePair <byte[], IPeer> >();

            foreach (var pdBlock in PendingBlocks.OrderBy(x => x.Block.Header.Index))
            {
                if (!pdBlock.IsSynced)
                {
                    _logger?.Debug($"{pdBlock.MissingTxs.Count} missing txn for block {pdBlock.Block.Header.Index}");
                    foreach (var tx in pdBlock.MissingTxs.Where(m => !m.IsRequestInProgress))
                    {
                        if (listOfMissingTxToRequest.Count >= MaxOngoingTxRequests)
                        {
                            break;
                        }

                        listOfMissingTxToRequest.Add(new KeyValuePair <byte[], IPeer>(tx.Hash, pdBlock.Peer));
                        tx.IsRequestInProgress = true;
                    }

                    break;
                }
            }

            if (listOfMissingTxToRequest.Any())
            {
                _networkManager.QueueTransactionRequest(listOfMissingTxToRequest.Select(kvp => kvp.Key).ToList(),
                                                        listOfMissingTxToRequest.First().Value);
                _logger?.Debug($"Requested the following {listOfMissingTxToRequest.Count} transactions [" +
                               string.Join(", ", listOfMissingTxToRequest.Select(kvp => kvp.Key.ToHex())) + "]");
            }
        }
Esempio n. 2
0
 public List <PendingBlock> GetPendingBlocks()
 {
     return(PendingBlocks.OrderBy(pb => pb.Block.Header.Index).ToList());
 }