|
|
@ -833,8 +833,6 @@ LocalisedLogEntries Client::logs(LogFilter const& _f) const |
|
|
|
LocalisedLogEntries ret; |
|
|
|
unsigned begin = min<unsigned>(m_bc.number() + 1, (unsigned)_f.latest()); |
|
|
|
unsigned end = min(m_bc.number(), min(begin, (unsigned)_f.earliest())); |
|
|
|
unsigned m = _f.max(); |
|
|
|
unsigned s = _f.skip(); |
|
|
|
|
|
|
|
// Handle pending transactions differently as they're not on the block chain.
|
|
|
|
if (begin > m_bc.number()) |
|
|
@ -847,71 +845,52 @@ LocalisedLogEntries Client::logs(LogFilter const& _f) const |
|
|
|
auto sha3 = m_postMine.pending()[i].sha3(); |
|
|
|
LogEntries le = _f.matches(tr); |
|
|
|
if (le.size()) |
|
|
|
{ |
|
|
|
for (unsigned j = 0; j < le.size() && ret.size() != m; ++j) |
|
|
|
if (s) |
|
|
|
s--; |
|
|
|
else |
|
|
|
ret.insert(ret.begin(), LocalisedLogEntry(le[j], begin, sha3)); |
|
|
|
} |
|
|
|
for (unsigned j = 0; j < le.size(); ++j) |
|
|
|
ret.insert(ret.begin(), LocalisedLogEntry(le[j], begin, sha3)); |
|
|
|
} |
|
|
|
begin = m_bc.number(); |
|
|
|
} |
|
|
|
|
|
|
|
set<unsigned> matchingBlocks; |
|
|
|
for (auto const& i: _f.bloomPossibilities()) |
|
|
|
for (auto u: m_bc.withBlockBloom(i, end, begin)) |
|
|
|
matchingBlocks.insert(u); |
|
|
|
|
|
|
|
#if ETH_DEBUG |
|
|
|
// fill these params
|
|
|
|
unsigned skipped = 0; |
|
|
|
unsigned falsePos = 0; |
|
|
|
#endif |
|
|
|
auto h = m_bc.numberHash(begin); |
|
|
|
unsigned n = begin; |
|
|
|
for (; ret.size() != m && n != end; n--, h = m_bc.details(h).parent) |
|
|
|
for (auto n: matchingBlocks) |
|
|
|
{ |
|
|
|
#if ETH_DEBUG |
|
|
|
int total = 0; |
|
|
|
#endif |
|
|
|
// check block bloom
|
|
|
|
auto blockBloom = m_bc.blockBloom(n); |
|
|
|
if (_f.matches(blockBloom)) |
|
|
|
auto h = m_bc.numberHash(n); |
|
|
|
auto receipts = m_bc.receipts(h).receipts; |
|
|
|
for (size_t i = 0; i < receipts.size(); i++) |
|
|
|
{ |
|
|
|
auto receipts = m_bc.receipts(h).receipts; |
|
|
|
for (size_t i = 0; i < receipts.size(); i++) |
|
|
|
TransactionReceipt receipt = receipts[i]; |
|
|
|
if (_f.matches(receipt.bloom())) |
|
|
|
{ |
|
|
|
TransactionReceipt receipt = receipts[i]; |
|
|
|
if (_f.matches(receipt.bloom())) |
|
|
|
auto info = m_bc.info(h); |
|
|
|
auto h = transaction(info.hash, i).sha3(); |
|
|
|
LogEntries le = _f.matches(receipt); |
|
|
|
if (le.size()) |
|
|
|
{ |
|
|
|
auto info = m_bc.info(h); |
|
|
|
auto h = transaction(info.hash, i).sha3(); |
|
|
|
LogEntries le = _f.matches(receipt); |
|
|
|
if (le.size()) |
|
|
|
{ |
|
|
|
#if ETH_DEBUG |
|
|
|
total += le.size(); |
|
|
|
total += le.size(); |
|
|
|
#endif |
|
|
|
for (unsigned j = 0; j < le.size() && ret.size() != m; ++j) |
|
|
|
{ |
|
|
|
if (s) |
|
|
|
s--; |
|
|
|
else |
|
|
|
ret.insert(ret.begin(), LocalisedLogEntry(le[j], n, h)); |
|
|
|
} |
|
|
|
} |
|
|
|
for (unsigned j = 0; j < le.size(); ++j) |
|
|
|
ret.insert(ret.begin(), LocalisedLogEntry(le[j], n, h)); |
|
|
|
} |
|
|
|
#if ETH_DEBUG |
|
|
|
if (!total) |
|
|
|
falsePos++; |
|
|
|
#endif |
|
|
|
} |
|
|
|
#if ETH_DEBUG |
|
|
|
} |
|
|
|
else |
|
|
|
skipped++; |
|
|
|
if (!total) |
|
|
|
falsePos++; |
|
|
|
#endif |
|
|
|
if (n == end) |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
#if ETH_DEBUG |
|
|
|
cdebug << (begin - n) << "searched; " << skipped << "skipped; " << falsePos << "false +ves"; |
|
|
|
cdebug << matchingBlocks.size() << "searched from" << (end - begin) << "skipped; " << falsePos << "false +ves"; |
|
|
|
#endif |
|
|
|
return ret; |
|
|
|
} |
|
|
|