Add full diff objects to output #4

Merged
roysc merged 3 commits from add-data into main 2023-09-27 16:46:14 +00:00
Showing only changes of commit f30168fa52 - Show all commits

View File

@ -70,16 +70,35 @@ func writeDiff(outputDir string, number int, diff *statediff.StateObject) {
}
defer f.Close()
for _, item := range diff.IPLDs {
if _, err = f.WriteString("ipld," + item.CID + "\n"); err != nil {
s := fmt.Sprintf("ipld,%s,%x\n",
item.CID,
item.Content,
)
if _, err = f.WriteString(s); err != nil {
panic(err)
}
}
for _, item := range diff.Nodes {
if _, err = f.WriteString("state," + item.AccountWrapper.CID + "\n"); err != nil {
s := fmt.Sprintf("state,%s,%x,%t,%v,%v,%s,%x\n",
item.AccountWrapper.CID,
item.AccountWrapper.LeafKey,
item.Removed,
item.AccountWrapper.Account.Nonce,
item.AccountWrapper.Account.Balance,
item.AccountWrapper.Account.Root,
item.AccountWrapper.Account.CodeHash,
)
if _, err = f.WriteString(s); err != nil {
panic(err)
}
for _, storage := range item.StorageDiff {
if _, err = f.WriteString("storage," + storage.CID + "\n"); err != nil {
s := fmt.Sprintf("storage,%s,%x,%t,%x\n",
storage.CID,
storage.LeafKey,
storage.Removed,
storage.Value,
)
if _, err = f.WriteString(s); err != nil {
panic(err)
}
}