@@ -104,7 +104,7 @@ func (self *IterativeDump) onRoot(root common.Hash) {
104104 })
105105}
106106
107- func (self * StateDB ) performDump (c collector ) {
107+ func (self * StateDB ) performDump (c collector , excludeCode , excludeStorage bool ) {
108108
109109 c .onRoot (self .trie .Hash ())
110110
@@ -122,29 +122,33 @@ func (self *StateDB) performDump(c collector) {
122122 Nonce : data .Nonce ,
123123 Root : common .Bytes2Hex (data .Root [:]),
124124 CodeHash : common .Bytes2Hex (data .CodeHash ),
125- Code : common .Bytes2Hex (obj .Code (self .db )),
126- Storage : make (map [string ]string ),
127125 }
128- storageIt := trie .NewIterator (obj .getTrie (self .db ).NodeIterator (nil ))
129- for storageIt .Next () {
130- account .Storage [common .Bytes2Hex (self .trie .GetKey (storageIt .Key ))] = common .Bytes2Hex (storageIt .Value )
126+ if ! excludeCode {
127+ account .Code = common .Bytes2Hex (obj .Code (self .db ))
128+ }
129+ if ! excludeStorage {
130+ account .Storage = make (map [string ]string )
131+ storageIt := trie .NewIterator (obj .getTrie (self .db ).NodeIterator (nil ))
132+ for storageIt .Next () {
133+ account .Storage [common .Bytes2Hex (self .trie .GetKey (storageIt .Key ))] = common .Bytes2Hex (storageIt .Value )
134+ }
131135 }
132136 c .onAccount (common .Bytes2Hex (addr ), account )
133137 }
134138}
135139
136140// RawDump returns the entire state an a single large object
137- func (self * StateDB ) RawDump () Dump {
141+ func (self * StateDB ) RawDump (excludeCode , excludeStorage bool ) Dump {
138142
139143 dump := newCollectingDump ()
140- self .performDump (dump )
144+ self .performDump (dump , excludeCode , excludeStorage )
141145 return * dump
142146}
143147
144148// Dump returns a JSON string representing the entire state as a single json-object
145- func (self * StateDB ) Dump () []byte {
149+ func (self * StateDB ) Dump (excludeCode , excludeStorage bool ) []byte {
146150 dump := newCollectingDump ()
147- self .performDump (dump )
151+ self .performDump (dump , excludeCode , excludeStorage )
148152 json , err := json .MarshalIndent (dump , "" , " " )
149153 if err != nil {
150154 fmt .Println ("dump err" , err )
@@ -153,6 +157,6 @@ func (self *StateDB) Dump() []byte {
153157}
154158
155159// IterativeDump dumps out accounts as json-objects, delimited by linebreaks on stdout
156- func (self * StateDB ) IterativeDump () {
157- self .performDump (newIterativeDump (os .Stdout ))
160+ func (self * StateDB ) IterativeDump (excludeCode , excludeStorage bool ) {
161+ self .performDump (newIterativeDump (os .Stdout ), excludeCode , excludeStorage )
158162}
0 commit comments