From 18efffe220777a9fb9c587e5930c6cdf62d8d754 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 26 Jul 2015 00:36:14 +0200 Subject: [PATCH] Fix extraData reporting. --- libethereum/BlockChain.cpp | 5 ++++- libethereum/BlockChain.h | 15 ++++++++++++--- libethereum/Client.cpp | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/libethereum/BlockChain.cpp b/libethereum/BlockChain.cpp index bd96f6607..37fd68673 100644 --- a/libethereum/BlockChain.cpp +++ b/libethereum/BlockChain.cpp @@ -620,7 +620,10 @@ ImportRoute BlockChain::import(VerifiedBlockRef const& _block, OverlayDB const& { ex << errinfo_now(time(0)); ex << errinfo_block(_block.block.toBytes()); - ex << errinfo_extraData(_block.info.extraData()); + // only populate extraData if we actually managed to extract it. otherwise, + // we might be clobbering the existing one. + if (!_block.info.extraData().empty()) + ex << errinfo_extraData(_block.info.extraData()); throw; } #endif diff --git a/libethereum/BlockChain.h b/libethereum/BlockChain.h index 847857a64..9c81f85f1 100644 --- a/libethereum/BlockChain.h +++ b/libethereum/BlockChain.h @@ -419,7 +419,10 @@ public: ex << errinfo_phase(1); ex << errinfo_now(time(0)); ex << errinfo_block(_block.toBytes()); - ex << errinfo_extraData(h.extraData()); + // only populate extraData if we actually managed to extract it. otherwise, + // we might be clobbering the existing one. + if (!h.extraData().empty()) + ex << errinfo_extraData(h.extraData()); if (_onBad) _onBad(ex); throw; @@ -441,7 +444,10 @@ public: ex << errinfo_uncleIndex(i); ex << errinfo_now(time(0)); ex << errinfo_block(_block.toBytes()); - ex << errinfo_extraData(h.extraData()); + // only populate extraData if we actually managed to extract it. otherwise, + // we might be clobbering the existing one. + if (!h.extraData().empty()) + ex << errinfo_extraData(h.extraData()); if (_onBad) _onBad(ex); throw; @@ -463,7 +469,10 @@ public: ex << errinfo_transactionIndex(i); ex << errinfo_transaction(d.toBytes()); ex << errinfo_block(_block.toBytes()); - ex << errinfo_extraData(h.extraData()); + // only populate extraData if we actually managed to extract it. otherwise, + // we might be clobbering the existing one. + if (!h.extraData().empty()) + ex << errinfo_extraData(h.extraData()); if (_onBad) _onBad(ex); throw; diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index d0445b612..0ffc4dcd7 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -219,10 +219,10 @@ void Client::onBadBlock(Exception& _ex) const } if (bytes const* ed = boost::get_error_info(_ex)) { - RLP r(*ed); report["hints"]["extraData"] = toHex(*ed); try { + RLP r(*ed); if (r[0].toInt() == 0) report["hints"]["minerVersion"] = r[1].toString(); }