From 237d044a73fe0b28a4b61eb676ac08300d090095 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 12 Jun 2015 00:41:28 +0900 Subject: [PATCH] Reprocess in eth -i, don't network by default. --- eth/main.cpp | 29 ++++++++++++++++++++++++++--- libethereum/State.cpp | 7 ++++++- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/eth/main.cpp b/eth/main.cpp index 5497a2cda..a7f483966 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -108,6 +108,7 @@ void interactiveHelp() << " exportconfig Export the config (.RLP) to the path provided." << endl << " importconfig Import the config (.RLP) from the path provided." << endl << " inspect Dumps a contract to /.evm." << endl + << " reprocess Reprocess a given block." << endl << " dumptrace Dumps a transaction trace" << endl << "to . should be one of pretty, standard, standard+." << endl << " dumpreceipt Dumps a transation receipt." << endl << " exit Exits the application." << endl; @@ -806,13 +807,19 @@ int main(int argc, char** argv) cout << "Transaction Signer: " << signingKey << endl; cout << "Mining Benefactor: " << beneficiary << endl; - web3.startNetwork(); - cout << "Node ID: " << web3.enode() << endl; + + if (bootstrap || !remoteHost.empty()) + { + web3.startNetwork(); + cout << "Node ID: " << web3.enode() << endl; + } + else + cout << "Networking disabled. To start, use netstart or pass -b or a remote host." << endl; if (bootstrap) for (auto const& i: Host::pocHosts()) web3.requirePeer(i.first, i.second); - if (remoteHost.size()) + if (!remoteHost.empty()) web3.addNode(p2p::NodeId(), remoteHost + ":" + toString(remotePort)); #if ETH_JSONRPC || !ETH_TRUE @@ -1403,6 +1410,22 @@ int main(int argc, char** argv) cout << "Hex: " << toHex(rb) << endl; cout << r << endl; } + else if (c && cmd == "reprocess") + { + string block; + iss >> block; + h256 blockHash; + try + { + if (block.size() == 64 || block.size() == 66) + blockHash = h256(block); + else + blockHash = c->blockChain().numberHash(stoi(block)); + c->state(blockHash); + } + catch (...) + {} + } else if (c && cmd == "dumptrace") { unsigned block; diff --git a/libethereum/State.cpp b/libethereum/State.cpp index c80863d2f..a4b784b6f 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -141,7 +141,12 @@ State::State(OverlayDB const& _db, BlockChain const& _bc, h256 _h, ImportRequire // 2. Enact the block's transactions onto this state. m_ourAddress = bi.coinbaseAddress; - enact(BlockChain::verifyBlock(b), _bc, _ir); + boost::timer t; + auto vb = BlockChain::verifyBlock(b); + cnote << "verifyBlock:" << t.elapsed(); + t.restart(); + enact(vb, _bc, _ir); + cnote << "enact:" << t.elapsed(); } else {