private static IEnumerable <FilterLog> FilterLogsInBlockLowMemoryAllocation(LogFilter filter, ref ReceiptsIterator iterator) { List <FilterLog> logList = null; using (iterator) { long logIndexInBlock = 0; while (iterator.TryGetNext(out var receipt)) { LogEntriesIterator logsIterator = receipt.Logs == null ? new LogEntriesIterator(receipt.LogsRlp) : new LogEntriesIterator(receipt.Logs); if (filter.Matches(ref receipt.Bloom)) { while (logsIterator.TryGetNext(out var log)) { if (filter.Accepts(ref log)) { logList ??= new List <FilterLog>(); Keccak[] topics = log.Topics; if (topics == null) { var topicsValueDecoderContext = new Rlp.ValueDecoderContext(log.TopicsRlp); topics = KeccakDecoder.Instance.DecodeArray(ref topicsValueDecoderContext); } logList.Add(new FilterLog( logIndexInBlock, logsIterator.Index, receipt.BlockNumber, receipt.BlockHash.ToKeccak(), receipt.Index, receipt.TxHash.ToKeccak(), log.LoggersAddress.ToAddress(), log.Data.ToArray(), topics)); } logIndexInBlock++; } } else { while (logsIterator.TrySkipNext()) { logIndexInBlock++; } } } } return(logList ?? (IEnumerable <FilterLog>)Array.Empty <FilterLog>()); }
public bool TryGetReceiptsIterator(long blockNumber, Keccak blockHash, out ReceiptsIterator iterator) => _outStorage.TryGetReceiptsIterator(blockNumber, blockHash, out iterator);