Skip to content

Instantly share code, notes, and snippets.

@obscuren
Created October 27, 2016 10:31
Show Gist options
  • Save obscuren/5740142ba0c3b8a4afaf7aac43aae9df to your computer and use it in GitHub Desktop.
Save obscuren/5740142ba0c3b8a4afaf7aac43aae9df to your computer and use it in GitHub Desktop.
diff --git a/core/state/state_object.go b/core/state/state_object.go
index 94033a3..6f59159 100644
--- a/core/state/state_object.go
+++ b/core/state/state_object.go
@@ -91,6 +91,11 @@ type StateObject struct {
onDirty func(addr common.Address) // Callback method to mark a state object newly dirty
}
+// empty returns whether the accoun is considered empty.
+func (s *StateObject) empty() bool {
+ return s.data.empty()
+}
+
// Account is the Ethereum consensus representation of accounts.
// These objects are stored in the main account trie.
type Account struct {
@@ -100,12 +105,9 @@ type Account struct {
CodeHash []byte
}
+// empty returns whether the accoun is considered empty.
func (a Account) empty() bool {
- return a.Nonce == 0 && a.Balance.BitLen() == 0 && bytes.Equal(a.CodeHash, emptyCodeHash) && a.Root == trie.EmptyRoot
-}
-
-func (s *StateObject) empty() bool {
- return len(s.cachedStorage) == 0 && len(s.dirtyStorage) == 0 && s.data.empty()
+ return a.Nonce == 0 && a.Balance.BitLen() == 0 && bytes.Equal(a.CodeHash, emptyCodeHash)
}
// newObject creates a state object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment