Browse Source

block polarity enum && jsonrpc field

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
f77325de18
  1. 3
      libethereum/BlockChain.h
  2. 6
      libethereum/Client.cpp
  3. 2
      libethereum/Client.h
  4. 2
      libethereum/ClientBase.cpp
  5. 11
      libevm/ExtVMFace.h
  6. 3
      libweb3jsonrpc/WebThreeStubServerBase.cpp

3
libethereum/BlockChain.h

@ -81,7 +81,8 @@ using BlocksHash = std::unordered_map<h256, bytes>;
using TransactionHashes = h256s;
using UncleHashes = h256s;
struct ImportRoute {
struct ImportRoute
{
h256s deadBlocks;
h256s liveBlocks;
};

6
libethereum/Client.cpp

@ -480,7 +480,7 @@ void Client::appendFromNewPending(TransactionReceipt const& _receipt, h256Hash&
}
}
void Client::appendFromBlock(h256 const& _block, bool _polarity, h256Hash& io_changed)
void Client::appendFromBlock(h256 const& _block, BlockPolarity _polarity, h256Hash& io_changed)
{
// TODO: more precise check on whether the txs match.
auto d = m_bc.info(_block);
@ -682,7 +682,7 @@ void Client::onDeadBlocks(h256s const& _blocks, h256Hash& io_changed)
}
for (auto const& h: _blocks)
appendFromBlock(h, false, io_changed);
appendFromBlock(h, BlockPolarity::Dead, io_changed);
}
void Client::onNewBlocks(h256s const& _blocks, h256Hash& io_changed)
@ -702,7 +702,7 @@ void Client::onNewBlocks(h256s const& _blocks, h256Hash& io_changed)
h->noteNewBlocks();
for (auto const& h: _blocks)
appendFromBlock(h, true, io_changed);
appendFromBlock(h, BlockPolarity::Live, io_changed);
}
void Client::restartMining()

2
libethereum/Client.h

@ -251,7 +251,7 @@ protected:
/// Collate the changed filters for the hash of the given block.
/// Insert any filters that are activated into @a o_changed.
void appendFromBlock(h256 const& _blockHash, bool _polarity, h256Hash& io_changed);
void appendFromBlock(h256 const& _blockHash, BlockPolarity _polarity, h256Hash& io_changed);
/// Record that the set of filters @a _filters have changed.
/// This doesn't actually make any callbacks, but incrememnts some counters in m_watches.

2
libethereum/ClientBase.cpp

@ -217,7 +217,7 @@ LocalisedLogEntries ClientBase::logs(LogFilter const& _f) const
{
total += le.size();
for (unsigned j = 0; j < le.size(); ++j)
ret.insert(ret.begin(), LocalisedLogEntry(le[j], info, th, i, logIndex));
ret.insert(ret.begin(), LocalisedLogEntry(le[j], info, th, i, logIndex, BlockPolarity::Live));
}
}

11
libevm/ExtVMFace.h

@ -36,6 +36,13 @@ namespace dev
namespace eth
{
enum class BlockPolarity
{
Unknown,
Dead,
Live
};
struct LogEntry
{
LogEntry() {}
@ -76,7 +83,7 @@ struct LocalisedLogEntry: public LogEntry
h256 _th,
unsigned _ti,
unsigned _li,
bool _polarity = true
BlockPolarity _polarity = BlockPolarity::Unknown
): LogEntry(_le), blockHash(_bi.hash()), blockNumber((BlockNumber)_bi.number), transactionHash(_th), transactionIndex(_ti), logIndex(_li), mined(true), polarity(_polarity) {};
h256 blockHash = h256();
@ -85,7 +92,7 @@ struct LocalisedLogEntry: public LogEntry
unsigned transactionIndex = 0;
unsigned logIndex = 0;
bool mined = false;
bool polarity = true;
BlockPolarity polarity = BlockPolarity::Unknown;
h256 special = h256();
};

3
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -169,8 +169,11 @@ static Json::Value toJson(dev::eth::LocalisedLogEntry const& _e)
res["data"] = toJS(_e.data);
res["address"] = toJS(_e.address);
res["topics"] = Json::Value(Json::arrayValue);
res["polarity"] = _e.polarity == BlockPolarity::Live ? true : false;
for (auto const& t: _e.topics)
res["topics"].append(toJS(t));
if (_e.mined)
{
res["type"] = "mined";

Loading…
Cancel
Save