cmd/geth, core: Updated DB version & seedhash debug method

This commit is contained in:
obscuren 2015-05-27 00:11:54 +02:00
parent 612f01400f
commit b2f2806055
2 changed files with 28 additions and 2 deletions

@ -88,6 +88,7 @@ func (js *jsre) adminBindings() {
debug.Set("getBlockRlp", js.getBlockRlp) debug.Set("getBlockRlp", js.getBlockRlp)
debug.Set("setHead", js.setHead) debug.Set("setHead", js.setHead)
debug.Set("processBlock", js.debugBlock) debug.Set("processBlock", js.debugBlock)
debug.Set("seedhash", js.seedHash)
// undocumented temporary // undocumented temporary
debug.Set("waitForBlocks", js.waitForBlocks) debug.Set("waitForBlocks", js.waitForBlocks)
} }
@ -118,6 +119,27 @@ func (js *jsre) getBlock(call otto.FunctionCall) (*types.Block, error) {
return block, nil 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 { func (js *jsre) pendingTransactions(call otto.FunctionCall) otto.Value {
txs := js.ethereum.TxPool().GetTransactions() txs := js.ethereum.TxPool().GetTransactions()
@ -220,10 +242,11 @@ func (js *jsre) debugBlock(call otto.FunctionCall) otto.Value {
vm.Debug = true vm.Debug = true
_, err = js.ethereum.BlockProcessor().RetryProcess(block) _, err = js.ethereum.BlockProcessor().RetryProcess(block)
if err != nil { if err != nil {
glog.Infoln(err) fmt.Println(err)
} }
vm.Debug = old vm.Debug = old
fmt.Println("ok")
return otto.UndefinedValue() return otto.UndefinedValue()
} }

@ -21,7 +21,7 @@ import (
const ( const (
// must be bumped when consensus algorithm is changed, this forces the upgradedb // 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) // command to be run (forces the blocks to be imported again using the new algorithm)
BlockChainVersion = 2 BlockChainVersion = 3
) )
var receiptsPre = []byte("receipts-") var receiptsPre = []byte("receipts-")
@ -159,6 +159,9 @@ func (sm *BlockProcessor) RetryProcess(block *types.Block) (logs state.Logs, err
return nil, ParentError(header.ParentHash) return nil, ParentError(header.ParentHash)
} }
parent := sm.bc.GetBlock(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) return sm.processWithParent(block, parent)
} }