Skip to content

Commit b2f2806

Browse files
committed
cmd/geth, core: Updated DB version & seedhash debug method
1 parent 612f014 commit b2f2806

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

cmd/geth/admin.go

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ func (js *jsre) adminBindings() {
8888
debug.Set("getBlockRlp", js.getBlockRlp)
8989
debug.Set("setHead", js.setHead)
9090
debug.Set("processBlock", js.debugBlock)
91+
debug.Set("seedhash", js.seedHash)
9192
// undocumented temporary
9293
debug.Set("waitForBlocks", js.waitForBlocks)
9394
}
@@ -118,6 +119,27 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
118119
return block, nil
119120
}
120121

122+
func (js *jsre) seedHash(call otto.FunctionCall) otto.Value {
123+
if len(call.ArgumentList) > 0 {
124+
if call.Argument(0).IsNumber() {
125+
num, _ := call.Argument(0).ToInteger()
126+
hash, err := ethash.GetSeedHash(uint64(num))
127+
if err != nil {
128+
fmt.Println(err)
129+
return otto.UndefinedValue()
130+
}
131+
v, _ := call.Otto.ToValue(fmt.Sprintf("0x%x", hash))
132+
return v
133+
} else {
134+
fmt.Println("arg not a number")
135+
}
136+
} else {
137+
fmt.Println("requires number argument")
138+
}
139+
140+
return otto.UndefinedValue()
141+
}
142+
121143
func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
122144
txs := js.ethereum.TxPool().GetTransactions()
123145

@@ -220,10 +242,11 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
220242
vm.Debug = true
221243
_, err = js.ethereum.BlockProcessor().RetryProcess(block)
222244
if err != nil {
223-
glog.Infoln(err)
245+
fmt.Println(err)
224246
}
225247
vm.Debug = old
226248

249+
fmt.Println("ok")
227250
return otto.UndefinedValue()
228251
}
229252

core/block_processor.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
const (
2222
// must be bumped when consensus algorithm is changed, this forces the upgradedb
2323
// command to be run (forces the blocks to be imported again using the new algorithm)
24-
BlockChainVersion = 2
24+
BlockChainVersion = 3
2525
)
2626

2727
var receiptsPre = []byte("receipts-")
@@ -159,6 +159,9 @@ func (sm *BlockProcessor) RetryProcess(block *types.Block) (logs state.Logs, err
159159
return nil, ParentError(header.ParentHash)
160160
}
161161
parent := sm.bc.GetBlock(header.ParentHash)
162+
if !sm.Pow.Verify(block) {
163+
return nil, ValidationError("Block's nonce is invalid (= %x)", block.Nonce)
164+
}
162165

163166
return sm.processWithParent(block, parent)
164167
}

0 commit comments

Comments
 (0)