Browse Source

Merge branch 'filter_logs' of https://github.com/ethereum/cpp-ethereum into logs

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
ee7cf138b4
  1. 5
      alethzero/MainWin.cpp
  2. 33
      libethereum/Client.cpp
  3. 1
      libethereum/MessageFilter.h
  4. 4
      libethereum/State.cpp
  5. 13
      libweb3jsonrpc/WebThreeStubServer.cpp

5
alethzero/MainWin.cpp

@ -290,11 +290,8 @@ void Main::installBalancesWatch()
for (unsigned i = 0; i < ethereum()->stateAt(coinsAddr, 0); ++i) for (unsigned i = 0; i < ethereum()->stateAt(coinsAddr, 0); ++i)
altCoins.push_back(right160(ethereum()->stateAt(coinsAddr, i + 1))); altCoins.push_back(right160(ethereum()->stateAt(coinsAddr, i + 1)));
for (auto i: m_myKeys) for (auto i: m_myKeys)
{
tf.address(i.address());
for (auto c: altCoins) for (auto c: altCoins)
tf.address(c); tf.address(c).topic(h256(i.address(), h256::AlignRight));
}
uninstallWatch(m_balancesFilter); uninstallWatch(m_balancesFilter);
m_balancesFilter = installWatch(tf, [=](){ onBalancesChange(); }); m_balancesFilter = installWatch(tf, [=](){ onBalancesChange(); });

33
libethereum/Client.cpp

@ -604,30 +604,37 @@ LogEntries Client::logs(LogFilter const& _f) const
#if ETH_DEBUG #if ETH_DEBUG
int total = 0; int total = 0;
#endif #endif
//? check block bloom // check block bloom
for (TransactionReceipt receipt: m_bc.receipts(h).receipts) if (_f.matches(m_bc.info(h).logBloom))
if (_f.matches(receipt.bloom())) for (TransactionReceipt receipt: m_bc.receipts(h).receipts)
{ {
LogEntries le = _f.matches(receipt); if (_f.matches(receipt.bloom()))
if (le.size())
{ {
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() && ret.size() != m; ++j)
{ {
if (s) if (s)
s--; s--;
else else
ret.insert(ret.begin(), le[j]); ret.insert(ret.begin(), le[j]);
}
} }
} }
if (!total)
falsePos++;
} }
else
skipped++;
if (n == end) if (n == end)
break; break;
} }
#if ETH_DEBUG #if ETH_DEBUG
// cdebug << (begin - n) << "searched; " << skipped << "skipped; " << falsePos << "false +ves"; cdebug << (begin - n) << "searched; " << skipped << "skipped; " << falsePos << "false +ves";
#endif #endif
return ret; return ret;
} }

1
libethereum/MessageFilter.h

@ -90,7 +90,6 @@ public:
LogEntries matches(TransactionReceipt const& _r) const; LogEntries matches(TransactionReceipt const& _r) const;
LogFilter address(Address _a) { m_addresses.insert(_a); return *this; } LogFilter address(Address _a) { m_addresses.insert(_a); return *this; }
LogFilter from(Address _a) { return topic(u256((u160)_a) + 1); }
LogFilter topic(h256 const& _t) { m_topics.insert(_t); return *this; } LogFilter topic(h256 const& _t) { m_topics.insert(_t); return *this; }
LogFilter withMax(unsigned _m) { m_max = _m; return *this; } LogFilter withMax(unsigned _m) { m_max = _m; return *this; }
LogFilter withSkip(unsigned _m) { m_skip = _m; return *this; } LogFilter withSkip(unsigned _m) { m_skip = _m; return *this; }

4
libethereum/State.cpp

@ -802,7 +802,7 @@ void State::commitToMine(BlockChain const& _bc)
{ {
uncommitToMine(); uncommitToMine();
cnote << "Committing to mine on block" << m_previousBlock.hash.abridged(); // cnote << "Committing to mine on block" << m_previousBlock.hash.abridged();
#ifdef ETH_PARANOIA #ifdef ETH_PARANOIA
commit(); commit();
cnote << "Pre-reward stateRoot:" << m_state.root(); cnote << "Pre-reward stateRoot:" << m_state.root();
@ -877,7 +877,7 @@ void State::commitToMine(BlockChain const& _bc)
// Commit any and all changes to the trie that are in the cache, then update the state root accordingly. // Commit any and all changes to the trie that are in the cache, then update the state root accordingly.
commit(); commit();
cnote << "Post-reward stateRoot:" << m_state.root().abridged(); // cnote << "Post-reward stateRoot:" << m_state.root().abridged();
// cnote << m_state; // cnote << m_state;
// cnote << *this; // cnote << *this;

13
libweb3jsonrpc/WebThreeStubServer.cpp

@ -113,17 +113,6 @@ static dev::eth::LogFilter toLogFilter(Json::Value const& _json) // commented to
filter.withMax(_json["max"].asInt()); filter.withMax(_json["max"].asInt());
if (_json["skip"].isInt()) if (_json["skip"].isInt())
filter.withSkip(_json["skip"].asInt()); filter.withSkip(_json["skip"].asInt());
if (!_json["from"].empty())
{
if (_json["from"].isArray())
{
for (auto i : _json["from"])
if (i.isString())
filter.from(jsToAddress(i.asString()));
}
else if (_json["from"].isString())
filter.from(jsToAddress(_json["from"].asString()));
}
if (!_json["address"].empty()) if (!_json["address"].empty())
{ {
if (_json["address"].isArray()) if (_json["address"].isArray())
@ -133,7 +122,7 @@ static dev::eth::LogFilter toLogFilter(Json::Value const& _json) // commented to
filter.address(jsToAddress(i.asString())); filter.address(jsToAddress(i.asString()));
} }
else if (_json["address"].isString()) else if (_json["address"].isString())
filter.from(jsToAddress(_json["address"].asString())); filter.address(jsToAddress(_json["address"].asString()));
} }
if (!_json["topics"].empty()) if (!_json["topics"].empty())
{ {

Loading…
Cancel
Save