aboutsummaryrefslogtreecommitdiffstats
path: root/core/block_processor.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-19 02:13:53 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-19 02:13:53 +0800
commitbd0c0a633bebe8893c4b06a50740047e4376107c (patch)
tree0b0632fa78f80206eb1fd96dd2b3d3e6b43ac1aa /core/block_processor.go
parentd6adadc5e37f3d01cac25b5371e1c42b7036735a (diff)
parent40717465bc8c0e2feb0f1e48ddc721c7292ba992 (diff)
downloadgo-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.tar
go-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.tar.gz
go-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.tar.bz2
go-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.tar.lz
go-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.tar.xz
go-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.tar.zst
go-tangerine-bd0c0a633bebe8893c4b06a50740047e4376107c.zip
Merge pull request #1022 from obscuren/parallel_nonce_checks
Parallelise nonce checks
Diffstat (limited to 'core/block_processor.go')
-rw-r--r--core/block_processor.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/core/block_processor.go b/core/block_processor.go
index 0652d217f..20e6722a4 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -188,7 +188,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
state := state.New(parent.Root(), sm.db)
// Block validation
- if err = sm.ValidateHeader(block.Header(), parent.Header()); err != nil {
+ if err = sm.ValidateHeader(block.Header(), parent.Header(), false); err != nil {
return
}
@@ -268,7 +268,7 @@ func (sm *BlockProcessor) processWithParent(block, parent *types.Block) (logs st
// Validates the current block. Returns an error if the block was invalid,
// an uncle or anything that isn't on the current block chain.
// Validation validates easy over difficult (dagger takes longer time = difficult)
-func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
+func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header, checkPow bool) error {
if big.NewInt(int64(len(block.Extra))).Cmp(params.MaximumExtraDataSize) == 1 {
return fmt.Errorf("Block extra data too long (%d)", len(block.Extra))
}
@@ -299,9 +299,11 @@ func (sm *BlockProcessor) ValidateHeader(block, parent *types.Header) error {
return BlockEqualTSErr //ValidationError("Block timestamp equal or less than previous block (%v - %v)", block.Time, parent.Time)
}
- // Verify the nonce of the block. Return an error if it's not valid
- if !sm.Pow.Verify(types.NewBlockWithHeader(block)) {
- return ValidationError("Block's nonce is invalid (= %x)", block.Nonce)
+ if checkPow {
+ // Verify the nonce of the block. Return an error if it's not valid
+ if !sm.Pow.Verify(types.NewBlockWithHeader(block)) {
+ return ValidationError("Block's nonce is invalid (= %x)", block.Nonce)
+ }
}
return nil
@@ -375,7 +377,7 @@ func (sm *BlockProcessor) VerifyUncles(statedb *state.StateDB, block, parent *ty
return UncleError("uncle[%d](%x)'s parent unknown (%x)", i, hash[:4], uncle.ParentHash[0:4])
}
- if err := sm.ValidateHeader(uncle, ancestorHeaders[uncle.ParentHash]); err != nil {
+ if err := sm.ValidateHeader(uncle, ancestorHeaders[uncle.ParentHash], true); err != nil {
return ValidationError(fmt.Sprintf("uncle[%d](%x) header invalid: %v", i, hash[:4], err))
}
}