aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2015-05-27 07:47:10 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2015-05-27 07:47:10 +0800
commit3590591e674b14fd025aac91952d9408bb841527 (patch)
tree7dccb0359577de4b4daa0470c13e44a68b0859d5
parent612f01400f59b0b4d0db9f9ceaa38f45805ea89e (diff)
parent222249e622cd552b0500051fbbcbfb00a5366da4 (diff)
downloadgo-tangerine-3590591e674b14fd025aac91952d9408bb841527.tar
go-tangerine-3590591e674b14fd025aac91952d9408bb841527.tar.gz
go-tangerine-3590591e674b14fd025aac91952d9408bb841527.tar.bz2
go-tangerine-3590591e674b14fd025aac91952d9408bb841527.tar.lz
go-tangerine-3590591e674b14fd025aac91952d9408bb841527.tar.xz
go-tangerine-3590591e674b14fd025aac91952d9408bb841527.tar.zst
go-tangerine-3590591e674b14fd025aac91952d9408bb841527.zip
Merge pull request #1113 from obscuren/develop
core: block database version update
-rw-r--r--cmd/geth/admin.go25
-rw-r--r--cmd/geth/main.go12
-rw-r--r--core/block_processor.go5
3 files changed, 34 insertions, 8 deletions
diff --git a/cmd/geth/admin.go b/cmd/geth/admin.go
index 28786553c..8f9a009d7 100644
--- a/cmd/geth/admin.go
+++ b/cmd/geth/admin.go
@@ -88,6 +88,7 @@ func (js *jsre) adminBindings() {
debug.Set("getBlockRlp", js.getBlockRlp)
debug.Set("setHead", js.setHead)
debug.Set("processBlock", js.debugBlock)
+ debug.Set("seedhash", js.seedHash)
// undocumented temporary
debug.Set("waitForBlocks", js.waitForBlocks)
}
@@ -118,6 +119,27 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
return block, nil
}
+func (js *jsre) seedHash(call otto.FunctionCall) otto.Value {
+ if len(call.ArgumentList) > 0 {
+ if call.Argument(0).IsNumber() {
+ num, _ := call.Argument(0).ToInteger()
+ hash, err := ethash.GetSeedHash(uint64(num))
+ if err != nil {
+ fmt.Println(err)
+ return otto.UndefinedValue()
+ }
+ v, _ := call.Otto.ToValue(fmt.Sprintf("0x%x", hash))
+ return v
+ } else {
+ fmt.Println("arg not a number")
+ }
+ } else {
+ fmt.Println("requires number argument")
+ }
+
+ return otto.UndefinedValue()
+}
+
func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
txs := js.ethereum.TxPool().GetTransactions()
@@ -220,10 +242,11 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
vm.Debug = true
_, err = js.ethereum.BlockProcessor().RetryProcess(block)
if err != nil {
- glog.Infoln(err)
+ fmt.Println(err)
}
vm.Debug = old
+ fmt.Println("ok")
return otto.UndefinedValue()
}
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 9d935efbd..742dae10f 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -533,9 +533,9 @@ func importchain(ctx *cli.Context) {
}
// force database flush
- ethereum.BlockDb().Close()
- ethereum.StateDb().Close()
- ethereum.ExtraDb().Close()
+ ethereum.BlockDb().Flush()
+ ethereum.StateDb().Flush()
+ ethereum.ExtraDb().Flush()
fmt.Printf("Import done in %v", time.Since(start))
@@ -630,9 +630,9 @@ func upgradeDb(ctx *cli.Context) {
}
// force database flush
- ethereum.BlockDb().Close()
- ethereum.StateDb().Close()
- ethereum.ExtraDb().Close()
+ ethereum.BlockDb().Flush()
+ ethereum.StateDb().Flush()
+ ethereum.ExtraDb().Flush()
os.Remove(exportFile)
diff --git a/core/block_processor.go b/core/block_processor.go
index 3f10e5efd..037782407 100644
--- a/core/block_processor.go
+++ b/core/block_processor.go
@@ -21,7 +21,7 @@ import (
const (
// must be bumped when consensus algorithm is changed, this forces the upgradedb
// command to be run (forces the blocks to be imported again using the new algorithm)
- BlockChainVersion = 2
+ BlockChainVersion = 3
)
var receiptsPre = []byte("receipts-")
@@ -159,6 +159,9 @@ func (sm *BlockProcessor) RetryProcess(block *types.Block) (logs state.Logs, err
return nil, ParentError(header.ParentHash)
}
parent := sm.bc.GetBlock(header.ParentHash)
+ if !sm.Pow.Verify(block) {
+ return nil, ValidationError("Block's nonce is invalid (= %x)", block.Nonce)
+ }
return sm.processWithParent(block, parent)
}