/// <inheritdoc /> public override async Task <bool> OnExecute() { if (Runner.Get <BlockStore>().Queue.Count() >= config.MaxItemsInQueue) { return(false); } if (TryDequeue(out SyncBlockOperation item)) { watch.Restart(); try { if (item.BlockInfo != null) { SyncBlockTransactionsOperation block = syncOperations.SyncBlock(syncConnection, item.BlockInfo); int inputs = block.Transactions.SelectMany(s => s.Inputs).Count(); int outputs = block.Transactions.SelectMany(s => s.Outputs).Count(); Runner.Get <BlockStore>().Enqueue(block); log.LogDebug($"Seconds = {watch.Elapsed.TotalSeconds} - BlockIndex = {block.BlockInfo.Height} - Transactions {block.Transactions.Count()} - Inputs {inputs} - Outputs {outputs} - ({inputs + outputs})"); } if (item.PoolTransactions != null) { SyncBlockTransactionsOperation pool = syncOperations.SyncPool(syncConnection, item.PoolTransactions); int inputs = pool.Transactions.SelectMany(s => s.Inputs).Count(); int outputs = pool.Transactions.SelectMany(s => s.Outputs).Count(); Runner.Get <BlockStore>().Enqueue(pool); log.LogDebug($"Seconds = {watch.Elapsed.TotalSeconds} - Pool = Sync - Transactions {pool.Transactions.Count()} - Inputs {inputs} - Outputs {outputs} - ({inputs + outputs})"); } } catch (BitcoinClientException bce) { if (bce.ErrorCode == -5) { if (bce.ErrorMessage == "No information available about transaction") { throw new SyncRestartException(string.Empty, bce); } } throw; } watch.Stop(); return(true); } return(await Task.FromResult(false)); }
/// <inheritdoc /> public override async Task <bool> OnExecute() { if (!config.SyncMemoryPool) { Abort = true; return(true); } if (Runner.GlobalState.Blocked) { return(false); } if (Runner.GlobalState.ChainTipHeight == 0 || Runner.GlobalState.StoreTip == null || Runner.GlobalState.IndexModeCompleted == false || Runner.GlobalState.IbdMode()) { // Don't sync mempool until api is at tip return(false); } if (initialized == false) { initialized = true; // read build mempool memory view syncOperations.InitializeMmpool(); } watch.Restart(); SyncPoolTransactions pool = syncOperations.FindPoolTransactions(syncConnection); if (!pool.Transactions.Any()) { return(false); } SyncBlockTransactionsOperation poolTrx = syncOperations.SyncPool(syncConnection, pool); storageOperations.InsertMempoolTransactions(poolTrx); watch.Stop(); log.LogInformation($"Mempool - New Transactions = {pool.Transactions.Count}, Seconds = {watch.Elapsed.TotalSeconds}"); return(await Task.FromResult(false)); }