@@ -54,13 +54,13 @@ func (s Storage) Copy() Storage {
5454 return cpy
5555}
5656
57- // stateObject represents an Ethereum account which is being modified.
57+ // StateObject represents an Ethereum account which is being modified.
5858//
5959// The usage pattern is as follows:
6060// - First you need to obtain a state object.
6161// - Account values as well as storages can be accessed and modified through the object.
6262// - Finally, call commit to return the changes of storage trie and update account data.
63- type stateObject struct {
63+ type StateObject struct {
6464 db * StateDB
6565 address common.Address // address of ethereum account
6666 addrHash common.Hash // hash of ethereum address of the account
@@ -92,20 +92,20 @@ type stateObject struct {
9292}
9393
9494// empty returns whether the account is considered empty.
95- func (s * stateObject ) empty () bool {
95+ func (s * StateObject ) empty () bool {
9696 return s .data .Nonce == 0 && s .data .Balance .IsZero () && bytes .Equal (s .data .CodeHash , types .EmptyCodeHash .Bytes ()) && s .data .Extra .IsZero ()
9797}
9898
9999// newObject creates a state object.
100- func newObject (db * StateDB , address common.Address , acct * types.StateAccount ) * stateObject {
100+ func newObject (db * StateDB , address common.Address , acct * types.StateAccount ) * StateObject {
101101 var (
102102 origin = acct
103103 created = acct == nil // true if the account was not existent
104104 )
105105 if acct == nil {
106106 acct = types .NewEmptyStateAccount ()
107107 }
108- return & stateObject {
108+ return & StateObject {
109109 db : db ,
110110 address : address ,
111111 addrHash : crypto .Keccak256Hash (address [:]),
@@ -119,15 +119,15 @@ func newObject(db *StateDB, address common.Address, acct *types.StateAccount) *s
119119}
120120
121121// EncodeRLP implements rlp.Encoder.
122- func (s * stateObject ) EncodeRLP (w io.Writer ) error {
122+ func (s * StateObject ) EncodeRLP (w io.Writer ) error {
123123 return rlp .Encode (w , & s .data )
124124}
125125
126- func (s * stateObject ) markSelfdestructed () {
126+ func (s * StateObject ) markSelfdestructed () {
127127 s .selfDestructed = true
128128}
129129
130- func (s * stateObject ) touch () {
130+ func (s * StateObject ) touch () {
131131 s .db .journal .append (touchChange {
132132 account : & s .address ,
133133 })
@@ -141,7 +141,7 @@ func (s *stateObject) touch() {
141141// getTrie returns the associated storage trie. The trie will be opened
142142// if it's not loaded previously. An error will be returned if trie can't
143143// be loaded.
144- func (s * stateObject ) getTrie () (Trie , error ) {
144+ func (s * StateObject ) getTrie () (Trie , error ) {
145145 if s .trie == nil {
146146 // Try fetching from prefetcher first
147147 if s .data .Root != types .EmptyRootHash && s .db .prefetcher != nil {
@@ -160,7 +160,7 @@ func (s *stateObject) getTrie() (Trie, error) {
160160}
161161
162162// GetState retrieves a value from the account storage trie.
163- func (s * stateObject ) GetState (key common.Hash ) common.Hash {
163+ func (s * StateObject ) GetState (key common.Hash ) common.Hash {
164164 // If we have a dirty value for this state entry, return it
165165 value , dirty := s .dirtyStorage [key ]
166166 if dirty {
@@ -171,7 +171,7 @@ func (s *stateObject) GetState(key common.Hash) common.Hash {
171171}
172172
173173// GetCommittedState retrieves a value from the committed account storage trie.
174- func (s * stateObject ) GetCommittedState (key common.Hash ) common.Hash {
174+ func (s * StateObject ) GetCommittedState (key common.Hash ) common.Hash {
175175 // If we have a pending write or clean cached, return that
176176 if value , pending := s .pendingStorage [key ]; pending {
177177 return value
@@ -231,7 +231,7 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
231231}
232232
233233// SetState updates a value in account storage.
234- func (s * stateObject ) SetState (key , value common.Hash ) {
234+ func (s * StateObject ) SetState (key , value common.Hash ) {
235235 // If the new value is the same as old, don't set
236236 prev := s .GetState (key )
237237 if prev == value {
@@ -246,13 +246,13 @@ func (s *stateObject) SetState(key, value common.Hash) {
246246 s .setState (key , value )
247247}
248248
249- func (s * stateObject ) setState (key , value common.Hash ) {
249+ func (s * StateObject ) setState (key , value common.Hash ) {
250250 s .dirtyStorage [key ] = value
251251}
252252
253253// finalise moves all dirty storage slots into the pending area to be hashed or
254254// committed later. It is invoked at the end of every transaction.
255- func (s * stateObject ) finalise (prefetch bool ) {
255+ func (s * StateObject ) finalise (prefetch bool ) {
256256 slotsToPrefetch := make ([][]byte , 0 , len (s .dirtyStorage ))
257257 for key , value := range s .dirtyStorage {
258258 s .pendingStorage [key ] = value
@@ -274,7 +274,7 @@ func (s *stateObject) finalise(prefetch bool) {
274274// loading or updating of the trie, an error will be returned. Furthermore,
275275// this function will return the mutated storage trie, or nil if there is no
276276// storage change at all.
277- func (s * stateObject ) updateTrie () (Trie , error ) {
277+ func (s * StateObject ) updateTrie () (Trie , error ) {
278278 // Make sure all dirty slots are finalized into the pending storage area
279279 s .finalise (false )
280280
@@ -362,7 +362,7 @@ func (s *stateObject) updateTrie() (Trie, error) {
362362
363363// updateRoot flushes all cached storage mutations to trie, recalculating the
364364// new storage trie root.
365- func (s * stateObject ) updateRoot () {
365+ func (s * StateObject ) updateRoot () {
366366 // Flush cached storage mutations into trie, short circuit if any error
367367 // is occurred or there is not change in the trie.
368368 tr , err := s .updateTrie ()
@@ -379,7 +379,7 @@ func (s *stateObject) updateRoot() {
379379// commit obtains a set of dirty storage trie nodes and updates the account data.
380380// The returned set can be nil if nothing to commit. This function assumes all
381381// storage mutations have already been flushed into trie by updateRoot.
382- func (s * stateObject ) commit () (* trienode.NodeSet , error ) {
382+ func (s * StateObject ) commit () (* trienode.NodeSet , error ) {
383383 // Short circuit if trie is not even loaded, don't bother with committing anything
384384 if s .trie == nil {
385385 s .origin = s .data .Copy ()
@@ -405,7 +405,7 @@ func (s *stateObject) commit() (*trienode.NodeSet, error) {
405405
406406// AddBalance adds amount to s's balance.
407407// It is used to add funds to the destination account of a transfer.
408- func (s * stateObject ) AddBalance (amount * uint256.Int ) {
408+ func (s * StateObject ) AddBalance (amount * uint256.Int ) {
409409 // EIP161: We must check emptiness for the objects such that the account
410410 // clearing (0,0,0 objects) can take effect.
411411 if amount .IsZero () {
@@ -419,27 +419,27 @@ func (s *stateObject) AddBalance(amount *uint256.Int) {
419419
420420// SubBalance removes amount from s's balance.
421421// It is used to remove funds from the origin account of a transfer.
422- func (s * stateObject ) SubBalance (amount * uint256.Int ) {
422+ func (s * StateObject ) SubBalance (amount * uint256.Int ) {
423423 if amount .IsZero () {
424424 return
425425 }
426426 s .SetBalance (new (uint256.Int ).Sub (s .Balance (), amount ))
427427}
428428
429- func (s * stateObject ) SetBalance (amount * uint256.Int ) {
429+ func (s * StateObject ) SetBalance (amount * uint256.Int ) {
430430 s .db .journal .append (balanceChange {
431431 account : & s .address ,
432432 prev : new (uint256.Int ).Set (s .data .Balance ),
433433 })
434434 s .setBalance (amount )
435435}
436436
437- func (s * stateObject ) setBalance (amount * uint256.Int ) {
437+ func (s * StateObject ) setBalance (amount * uint256.Int ) {
438438 s .data .Balance = amount
439439}
440440
441- func (s * stateObject ) deepCopy (db * StateDB ) * stateObject {
442- obj := & stateObject {
441+ func (s * StateObject ) DeepCopy (db * StateDB ) * StateObject {
442+ obj := & StateObject {
443443 db : db ,
444444 address : s .address ,
445445 addrHash : s .addrHash ,
@@ -464,12 +464,12 @@ func (s *stateObject) deepCopy(db *StateDB) *stateObject {
464464//
465465
466466// Address returns the address of the contract/account
467- func (s * stateObject ) Address () common.Address {
467+ func (s * StateObject ) Address () common.Address {
468468 return s .address
469469}
470470
471471// Code returns the contract code associated with this object, if any.
472- func (s * stateObject ) Code () []byte {
472+ func (s * StateObject ) Code () []byte {
473473 if s .code != nil {
474474 return s .code
475475 }
@@ -487,7 +487,7 @@ func (s *stateObject) Code() []byte {
487487// CodeSize returns the size of the contract code associated with this object,
488488// or zero if none. This method is an almost mirror of Code, but uses a cache
489489// inside the database to avoid loading codes seen recently.
490- func (s * stateObject ) CodeSize () int {
490+ func (s * StateObject ) CodeSize () int {
491491 if s .code != nil {
492492 return len (s .code )
493493 }
@@ -501,7 +501,7 @@ func (s *stateObject) CodeSize() int {
501501 return size
502502}
503503
504- func (s * stateObject ) SetCode (codeHash common.Hash , code []byte ) {
504+ func (s * StateObject ) SetCode (codeHash common.Hash , code []byte ) {
505505 prevcode := s .Code ()
506506 s .db .journal .append (codeChange {
507507 account : & s .address ,
@@ -511,36 +511,36 @@ func (s *stateObject) SetCode(codeHash common.Hash, code []byte) {
511511 s .setCode (codeHash , code )
512512}
513513
514- func (s * stateObject ) setCode (codeHash common.Hash , code []byte ) {
514+ func (s * StateObject ) setCode (codeHash common.Hash , code []byte ) {
515515 s .code = code
516516 s .data .CodeHash = codeHash [:]
517517 s .dirtyCode = true
518518}
519519
520- func (s * stateObject ) SetNonce (nonce uint64 ) {
520+ func (s * StateObject ) SetNonce (nonce uint64 ) {
521521 s .db .journal .append (nonceChange {
522522 account : & s .address ,
523523 prev : s .data .Nonce ,
524524 })
525525 s .setNonce (nonce )
526526}
527527
528- func (s * stateObject ) setNonce (nonce uint64 ) {
528+ func (s * StateObject ) setNonce (nonce uint64 ) {
529529 s .data .Nonce = nonce
530530}
531531
532- func (s * stateObject ) CodeHash () []byte {
532+ func (s * StateObject ) CodeHash () []byte {
533533 return s .data .CodeHash
534534}
535535
536- func (s * stateObject ) Balance () * uint256.Int {
536+ func (s * StateObject ) Balance () * uint256.Int {
537537 return s .data .Balance
538538}
539539
540- func (s * stateObject ) Nonce () uint64 {
540+ func (s * StateObject ) Nonce () uint64 {
541541 return s .data .Nonce
542542}
543543
544- func (s * stateObject ) Root () common.Hash {
544+ func (s * StateObject ) Root () common.Hash {
545545 return s .data .Root
546546}
0 commit comments