add full diff objects to output

This commit is contained in:
Roy Crihfield 2023-09-27 16:32:44 +08:00
parent 353b68c395
commit f30168fa52

View File

@ -70,16 +70,35 @@ func writeDiff(outputDir string, number int, diff *statediff.StateObject) {
} }
defer f.Close() defer f.Close()
for _, item := range diff.IPLDs { 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) panic(err)
} }
} }
for _, item := range diff.Nodes { 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) panic(err)
} }
for _, storage := range item.StorageDiff { 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) panic(err)
} }
} }