Skip to content

Commit

Permalink
resolve igor's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
unclezoro committed Jan 20, 2022
1 parent 6299c90 commit 4607f60
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ func (bc *BlockChain) tryRewindBadBlocks() {
snaps := bc.snaps
// Verified and Result is false
if snaps != nil && snaps.Snapshot(block.Root()) != nil &&
snaps.Snapshot(block.Root()).Verified() && !snaps.Snapshot(block.Root()).WaitVerified() {
snaps.Snapshot(block.Root()).Verified() && !snaps.Snapshot(block.Root()).WaitAndGetVerifyRes() {
// Rewind by one block
log.Warn("current block verified failed, rewind to its parent", "height", block.NumberU64(), "hash", block.Hash())
bc.futureBlocks.Remove(block.Hash())
Expand Down
4 changes: 2 additions & 2 deletions core/state/snapshot/difflayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ func (dl *diffLayer) Root() common.Hash {
return dl.root
}

// WaitVerified will wait until the diff layer been verified and return the verification result
func (dl *diffLayer) WaitVerified() bool {
// WaitAndGetVerifyRes will wait until the diff layer been verified and return the verification result
func (dl *diffLayer) WaitAndGetVerifyRes() bool {
if dl.verifiedCh == nil {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion core/state/snapshot/disklayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (dl *diskLayer) Root() common.Hash {
return dl.root
}

func (dl *diskLayer) WaitVerified() bool {
func (dl *diskLayer) WaitAndGetVerifyRes() bool {
return true
}

Expand Down
4 changes: 2 additions & 2 deletions core/state/snapshot/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ type Snapshot interface {
// Root returns the root hash for which this snapshot was made.
Root() common.Hash

// WaitVerified will wait until the snapshot been verified
WaitVerified() bool
// WaitAndGetVerifyRes will wait until the snapshot been verified and return verification result
WaitAndGetVerifyRes() bool

// Verified returns whether the snapshot is verified
Verified() bool
Expand Down
4 changes: 2 additions & 2 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func newStateDB(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB,

snapVerified := sdb.snap != nil && sdb.snap.Verified()
tr, err := db.OpenTrie(root)
// return error when 1. failed to open trie and 2. the snap is not nil and done verification
// return error when 1. failed to open trie and 2. the snap is nil or the snap is not nil and done verification
if err != nil && (sdb.snap == nil || snapVerified) {
return nil, err
}
Expand Down Expand Up @@ -1020,7 +1020,7 @@ func (s *StateDB) AccountsIntermediateRoot() error {

// We need wait for the parent trie to commit
if s.snap != nil {
if valid := s.snap.WaitVerified(); !valid {
if valid := s.snap.WaitAndGetVerifyRes(); !valid {
return fmt.Errorf("verification on parent snap failed")
}
}
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
// so any modifications are written to the trie
root, err := statedb.IntermediateRoot(deleteEmptyObjects)
if err != nil {
return roots, err
return nil, err
}
roots = append(roots, root)
}
Expand Down

0 comments on commit 4607f60

Please sign in to comment.