Skip to content

Commit

Permalink
modify blockchain.HasState function
Browse files Browse the repository at this point in the history
  • Loading branch information
erickyan86 committed Jun 5, 2019
1 parent c1c0d37 commit 66f06c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions blockchain/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ func (bc *BlockChain) ResetWithGenesisBlock(genesis *types.Block) error {

bc.currentBlock.Store(bc.genesisBlock)
bc.irreversibleNumber.Store(bc.genesisBlock.NumberU64())

return nil
}

Expand Down Expand Up @@ -399,7 +398,8 @@ func (bc *BlockChain) HasBlock(hash common.Hash, number uint64) bool {

// HasState checks if state trie is fully present in the database or not.
func (bc *BlockChain) HasState(hash common.Hash) bool {
return rawdb.ReadBlockStateOut(bc.db, hash) != nil
_, err := state.New(hash, bc.stateCache)
return err == nil
}

// HasBlockAndState checks if a block and state is fully present in the database or not.
Expand All @@ -408,7 +408,7 @@ func (bc *BlockChain) HasBlockAndState(hash common.Hash, number uint64) bool {
if block == nil {
return false
}
return bc.HasState(hash)
return bc.HasState(block.Root())
}

// GetBlock retrieves a block from the database by hash and number, caching it if found.
Expand Down Expand Up @@ -687,7 +687,6 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.
}
return false, err
}

}

// Write the positional metadata for transaction/receipt lookups and preimages
Expand Down
2 changes: 1 addition & 1 deletion scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function release {
notes="NOTES.md"
echo "Building and releasing $tag..."
echo "Building and pushing binaries"
[[ -e "$notes" ]] && goreleaser --release-notes "$notes" || goreleaser
[[ -e "$notes" ]] && goreleaser --release-notes "$notes" --rm-dist
}

# If passed argument try to use that as tag otherwise read from local repo
Expand Down

0 comments on commit 66f06c6

Please sign in to comment.