diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index e3fcf83c1..2d3abd922 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -81,7 +81,8 @@ using BlocksHash = std::unordered_map; using TransactionHashes = h256s; using UncleHashes = h256s; -struct ImportRoute { +struct ImportRoute +{ h256s deadBlocks; h256s liveBlocks; }; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 7d967f669..ea144c307 100644 --- a/libethereum/Client.cpp +++ b/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() diff --git a/libethereum/Client.h b/libethereum/Client.h index eb05983b2..e25e8e0e4 100644 --- a/libethereum/Client.h +++ b/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. diff --git a/libethereum/ClientBase.cpp b/libethereum/ClientBase.cpp index d5bc0dbb9..2b25599cb 100644 --- a/libethereum/ClientBase.cpp +++ b/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)); } } diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 24c55d816..2d65631e0 100644 --- a/libevm/ExtVMFace.h +++ b/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(); }; diff --git a/libweb3jsonrpc/WebThreeStubServerBase.cpp b/libweb3jsonrpc/WebThreeStubServerBase.cpp index f88443ee5..5bdd98e87 100644 --- a/libweb3jsonrpc/WebThreeStubServerBase.cpp +++ b/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";