Browse Source

Actually stream data rather than using json spirit.

cl-refactor
Gav Wood 10 years ago
parent
commit
ab838bf167
  1. 29
      alethzero/MainWin.cpp

29
alethzero/MainWin.cpp

@ -1870,22 +1870,29 @@ void Main::on_dumpBlockState_triggered()
ofstream f(fn.toStdString()); ofstream f(fn.toStdString());
if (f.is_open()) if (f.is_open())
{ {
js::mObject s; f << "{" << endl;
// js::mObject s;
State state = ethereum()->state(h); State state = ethereum()->state(h);
int fi = 0;
for (pair<Address, u256> const& i: state.addresses()) for (pair<Address, u256> const& i: state.addresses())
{ {
js::mObject a; f << (fi++ ? "," : "") << "\"" << i.first.hex() << "\": { ";
a["balance"] = toString(i.second); f << "\"balance\": \"" << toString(i.second) << "\", ";
a["nonce"] = toString(state.transactionsFrom(i.first)); if (state.codeHash(i.first) != EmptySHA3)
a["codeHash"] = state.codeHash(i.first).hex(); {
js::mObject st; f << "\"codeHash\": \"" << state.codeHash(i.first).hex() << "\", ";
f << "\"storage\": {";
int fj = 0;
for (pair<u256, u256> const& j: state.storage(i.first)) for (pair<u256, u256> const& j: state.storage(i.first))
st[minHex(j.first)] = st[minHex(j.second)]; f << (fj++ ? "," : "") << "\"" << minHex(j.first) << "\":\"" << minHex(j.second) << "\"";
a["storage"] = st; f << "}, ";
s[i.first.hex()] = a; }
f << "\"nonce\": \"" << toString(state.transactionsFrom(i.first)) << "\"";
f << "}" << endl; // end account
if (!(fi % 100))
f << flush;
} }
js::mValue v(s); f << "}";
js::write_stream(v, f, true);
} }
} }
#endif #endif

Loading…
Cancel
Save