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)
altCoins.push_back(right160(ethereum()->stateAt(coinsAddr, i + 1)));
for (auto i: m_myKeys)
{
tf.address(i.address());
for (auto c: altCoins)
tf.address(c);
}
tf.address(c).topic(h256(i.address(), h256::AlignRight));
uninstallWatch(m_balancesFilter);
m_balancesFilter = installWatch(tf, [=](){ onBalancesChange(); });

33
libethereum/Client.cpp

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

1
libethereum/MessageFilter.h

@ -90,7 +90,6 @@ public:
LogEntries matches(TransactionReceipt const& _r) const;
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 withMax(unsigned _m) { m_max = _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();
cnote << "Committing to mine on block" << m_previousBlock.hash.abridged();
// cnote << "Committing to mine on block" << m_previousBlock.hash.abridged();
#ifdef ETH_PARANOIA
commit();
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();
cnote << "Post-reward stateRoot:" << m_state.root().abridged();
// cnote << "Post-reward stateRoot:" << m_state.root().abridged();
// cnote << m_state;
// 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());
if (_json["skip"].isInt())
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"].isArray())
@ -133,7 +122,7 @@ static dev::eth::LogFilter toLogFilter(Json::Value const& _json) // commented to
filter.address(jsToAddress(i.asString()));
}
else if (_json["address"].isString())
filter.from(jsToAddress(_json["address"].asString()));
filter.address(jsToAddress(_json["address"].asString()));
}
if (!_json["topics"].empty())
{

Loading…
Cancel
Save