@@ -38,7 +38,7 @@ func (self Code) String() string {
3838 return string (self ) //strings.Join(Disassemble(self), " ")
3939}
4040
41- type Storage map [string ]common.Hash
41+ type Storage map [common. Hash ]common.Hash
4242
4343func (self Storage ) String () (str string ) {
4444 for key , value := range self {
@@ -112,45 +112,44 @@ func (c *StateObject) getAddr(addr common.Hash) common.Hash {
112112 return common .BytesToHash (ret )
113113}
114114
115- func (c * StateObject ) setAddr (addr [] byte , value common.Hash ) {
115+ func (c * StateObject ) setAddr (addr , value common.Hash ) {
116116 v , err := rlp .EncodeToBytes (bytes .TrimLeft (value [:], "\x00 " ))
117117 if err != nil {
118118 // if RLPing failed we better panic and not fail silently. This would be considered a consensus issue
119119 panic (err )
120120 }
121- c .trie .Update (addr , v )
121+ c .trie .Update (addr [:] , v )
122122}
123123
124124func (self * StateObject ) Storage () Storage {
125125 return self .storage
126126}
127127
128128func (self * StateObject ) GetState (key common.Hash ) common.Hash {
129- strkey := key .Str ()
130- value , exists := self .storage [strkey ]
129+ value , exists := self .storage [key ]
131130 if ! exists {
132131 value = self .getAddr (key )
133132 if (value != common.Hash {}) {
134- self .storage [strkey ] = value
133+ self .storage [key ] = value
135134 }
136135 }
137136
138137 return value
139138}
140139
141- func (self * StateObject ) SetState (k , value common.Hash ) {
142- self .storage [k . Str () ] = value
140+ func (self * StateObject ) SetState (key , value common.Hash ) {
141+ self .storage [key ] = value
143142 self .dirty = true
144143}
145144
146145// Update updates the current cached storage to the trie
147146func (self * StateObject ) Update () {
148147 for key , value := range self .storage {
149148 if (value == common.Hash {}) {
150- self .trie .Delete ([] byte ( key ) )
149+ self .trie .Delete (key [:] )
151150 continue
152151 }
153- self .setAddr ([] byte ( key ) , value )
152+ self .setAddr (key , value )
154153 }
155154}
156155
@@ -245,24 +244,22 @@ func (self *StateObject) Value() *big.Int {
245244 panic ("Value on StateObject should never be called" )
246245}
247246
248- func (self * StateObject ) EachStorage (cb func (key , value [] byte ) ) {
247+ func (self * StateObject ) ForEachStorage (cb func (key , value common. Hash ) bool ) {
249248 // When iterating over the storage check the cache first
250- for h , v := range self .storage {
251- cb ([] byte ( h ), v . Bytes () )
249+ for h , value := range self .storage {
250+ cb (h , value )
252251 }
253252
254253 it := self .trie .Iterator ()
255254 for it .Next () {
256255 // ignore cached values
257- key := self .trie .GetKey (it .Key )
258- if _ , ok := self .storage [string ( key ) ]; ! ok {
259- cb (key , it .Value )
256+ key := common . BytesToHash ( self .trie .GetKey (it .Key ) )
257+ if _ , ok := self .storage [key ]; ! ok {
258+ cb (key , common . BytesToHash ( it .Value ) )
260259 }
261260 }
262261}
263262
264- // Encoding
265-
266263type extStateObject struct {
267264 Nonce uint64
268265 Balance * big.Int
0 commit comments