aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/block_validator.go6
-rw-r--r--core/state/statedb.go21
2 files changed, 24 insertions, 3 deletions
diff --git a/core/block_validator.go b/core/block_validator.go
index f777b9f23..c3f959324 100644
--- a/core/block_validator.go
+++ b/core/block_validator.go
@@ -64,7 +64,7 @@ func NewBlockValidator(config *ChainConfig, blockchain *BlockChain, pow pow.PoW)
//
// ValidateBlock also validates and makes sure that any previous state (or present)
// state that might or might not be present is checked to make sure that fast
-// sync has done it's job proper. This prevents the block validator form accepting
+// sync has done it's job proper. This prevents the block validator from accepting
// false positives where a header is present but the state is not.
func (v *BlockValidator) ValidateBlock(block *types.Block) error {
if v.bc.HasBlock(block.Hash()) {
@@ -139,7 +139,7 @@ func (v *BlockValidator) ValidateState(block, parent *types.Block, statedb *stat
// error if any of the included uncle headers were invalid. It returns an error
// if the validation failed.
func (v *BlockValidator) VerifyUncles(block, parent *types.Block) error {
- // validate that there at most 2 uncles included in this block
+ // validate that there are at most 2 uncles included in this block
if len(block.Uncles()) > 2 {
return ValidationError("Block can only contain maximum 2 uncles (contained %v)", len(block.Uncles()))
}
@@ -193,7 +193,7 @@ func (v *BlockValidator) ValidateHeader(header, parent *types.Header, checkPow b
if parent == nil {
return ParentError(header.ParentHash)
}
- // Short circuit if the header's already known or its parent missing
+ // Short circuit if the header's already known or its parent is missing
if v.bc.HasHeader(header.Hash()) {
return nil
}
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 70673799e..3e25e0c16 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -370,6 +370,27 @@ func (s *StateDB) IntermediateRoot() common.Hash {
return s.trie.Hash()
}
+// DeleteSuicides flags the suicided objects for deletion so that it
+// won't be referenced again when called / queried up on.
+//
+// DeleteSuicides should not be used for consensus related updates
+// under any circumstances.
+func (s *StateDB) DeleteSuicides() {
+ // Reset refund so that any used-gas calculations can use
+ // this method.
+ s.refund = new(big.Int)
+ for _, stateObject := range s.stateObjects {
+ if stateObject.dirty {
+ // If the object has been removed by a suicide
+ // flag the object as deleted.
+ if stateObject.remove {
+ stateObject.deleted = true
+ }
+ stateObject.dirty = false
+ }
+ }
+}
+
// Commit commits all state changes to the database.
func (s *StateDB) Commit() (root common.Hash, err error) {
root, batch := s.CommitBatch()