Beispiel #1
0
        private void ProcessBlock(Height height, Block block)
        {
            var keys = KeyManager.GetKeys().ToList();

            foreach (var tx in block.Transactions)
            {
                ProcessTransaction(new SmartTransaction(tx, height), keys);
            }

            ProcessedBlocks.Add(block.GetHash());

            NewBlockProcessed?.Invoke(this, block);
        }
Beispiel #2
0
        private async Task ProcessFilterModelAsync(FilterModel filterModel, CancellationToken cancel)
        {
            var matchFound = filterModel.Filter.MatchAny(KeyManager.GetPubKeyScriptBytes(), filterModel.FilterKey);

            if (matchFound)
            {
                Block currentBlock = await FetchBlockAsync(filterModel.Header.BlockHash, cancel);                 // Wait until not downloaded.

                var height = new Height(filterModel.Header.Height);

                var txsToProcess = new List <SmartTransaction>();
                for (int i = 0; i < currentBlock.Transactions.Count; i++)
                {
                    Transaction tx = currentBlock.Transactions[i];
                    txsToProcess.Add(new SmartTransaction(tx, height, currentBlock.GetHash(), i, firstSeen: currentBlock.Header.BlockTime));
                }
                TransactionProcessor.Process(txsToProcess);
                KeyManager.SetBestHeight(height);

                NewBlockProcessed?.Invoke(this, currentBlock);
            }

            LastProcessedFilter = filterModel;
        }