Skip to content

Commit

Permalink
Merge pull request #2821 from Taraxa-project/fix_log_filter
Browse files Browse the repository at this point in the history
fix: add missing check of the to_block number in LogFilter::match_all
  • Loading branch information
kstdl authored Aug 6, 2024
2 parents 99af7b5 + 759750b commit b8168fd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions libraries/core_libs/network/rpc/eth/LogFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,23 @@ void LogFilter::match_one(const ExtendedTransactionLocation& trx_loc, const Tran

std::vector<LocalisedLogEntry> LogFilter::match_all(const FinalChain& final_chain) const {
std::vector<LocalisedLogEntry> ret;

// to_block can't be greater than the last executed block number
const auto last_block_number = final_chain.last_block_number();
auto to_blk_n = to_block_ ? *to_block_ : last_block_number;
if (to_blk_n > last_block_number) {
to_blk_n = last_block_number;
}

auto action = [&, this](EthBlockNumber blk_n) {
ExtendedTransactionLocation trx_loc{{{blk_n}, *final_chain.block_hash(blk_n)}};
ExtendedTransactionLocation trx_loc{{{blk_n}, final_chain.block_hash(blk_n).value()}};
auto hashes = final_chain.transaction_hashes(trx_loc.period);
for (const auto& hash : *hashes) {
trx_loc.trx_hash = hash;
match_one(trx_loc, *final_chain.transaction_receipt(hash), [&](const auto& lle) { ret.push_back(lle); });
match_one(trx_loc, final_chain.transaction_receipt(hash).value(), [&](const auto& lle) { ret.push_back(lle); });
++trx_loc.position;
}
};
auto to_blk_n = to_block_ ? *to_block_ : final_chain.last_block_number();
if (is_range_only_) {
for (auto blk_n = from_block_; blk_n <= to_blk_n; ++blk_n) {
action(blk_n);
Expand Down

0 comments on commit b8168fd

Please sign in to comment.