From ab838bf1673ed478a657756b78853f94a53efbc9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 30 Jul 2015 17:11:28 +0200 Subject: [PATCH] Actually stream data rather than using json spirit. --- alethzero/MainWin.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 6a9db4a22..f7f0f0fa5 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1870,22 +1870,29 @@ void Main::on_dumpBlockState_triggered() ofstream f(fn.toStdString()); if (f.is_open()) { - js::mObject s; + f << "{" << endl; +// js::mObject s; State state = ethereum()->state(h); + int fi = 0; for (pair const& i: state.addresses()) { - js::mObject a; - a["balance"] = toString(i.second); - a["nonce"] = toString(state.transactionsFrom(i.first)); - a["codeHash"] = state.codeHash(i.first).hex(); - js::mObject st; - for (pair const& j: state.storage(i.first)) - st[minHex(j.first)] = st[minHex(j.second)]; - a["storage"] = st; - s[i.first.hex()] = a; + f << (fi++ ? "," : "") << "\"" << i.first.hex() << "\": { "; + f << "\"balance\": \"" << toString(i.second) << "\", "; + if (state.codeHash(i.first) != EmptySHA3) + { + f << "\"codeHash\": \"" << state.codeHash(i.first).hex() << "\", "; + f << "\"storage\": {"; + int fj = 0; + for (pair const& j: state.storage(i.first)) + f << (fj++ ? "," : "") << "\"" << minHex(j.first) << "\":\"" << minHex(j.second) << "\""; + f << "}, "; + } + f << "\"nonce\": \"" << toString(state.transactionsFrom(i.first)) << "\""; + f << "}" << endl; // end account + if (!(fi % 100)) + f << flush; } - js::mValue v(s); - js::write_stream(v, f, true); + f << "}"; } } #endif