fix json format of state snapshot (#5504)
This commit is contained in:
parent
9d6c50ea2f
commit
87ce264926
@ -461,7 +461,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
|
|||||||
let at = cmd.at;
|
let at = cmd.at;
|
||||||
let mut i = 0usize;
|
let mut i = 0usize;
|
||||||
|
|
||||||
out.write_fmt(format_args!("{{ \"state\": [", )).expect("Couldn't write to stream.");
|
out.write_fmt(format_args!("{{ \"state\": {{", )).expect("Couldn't write to stream.");
|
||||||
loop {
|
loop {
|
||||||
let accounts = client.list_accounts(at, last.as_ref(), 1000).ok_or("Specified block not found")?;
|
let accounts = client.list_accounts(at, last.as_ref(), 1000).ok_or("Specified block not found")?;
|
||||||
if accounts.is_empty() {
|
if accounts.is_empty() {
|
||||||
@ -498,13 +498,11 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut si = 0;
|
|
||||||
for key in keys.into_iter() {
|
for key in keys.into_iter() {
|
||||||
if si != 0 {
|
if last_storage.is_some() {
|
||||||
out.write(b",").expect("Write error");
|
out.write(b",").expect("Write error");
|
||||||
}
|
}
|
||||||
out.write_fmt(format_args!("\n\t\"0x{}\": \"0x{}\"", key.hex(), client.storage_at(&account, &key, at).unwrap_or_else(Default::default).hex())).expect("Write error");
|
out.write_fmt(format_args!("\n\t\"0x{}\": \"0x{}\"", key.hex(), client.storage_at(&account, &key, at).unwrap_or_else(Default::default).hex())).expect("Write error");
|
||||||
si += 1;
|
|
||||||
last_storage = Some(key);
|
last_storage = Some(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -519,7 +517,7 @@ fn execute_export_state(cmd: ExportState) -> Result<(), String> {
|
|||||||
last = Some(account);
|
last = Some(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.write_fmt(format_args!("\n]}}")).expect("Write error");
|
out.write_fmt(format_args!("\n}}}}")).expect("Write error");
|
||||||
info!("Export completed.");
|
info!("Export completed.");
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user