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