diff options
Diffstat (limited to 'chain')
-rw-r--r-- | chain/chain_manager.go | 5 | ||||
-rw-r--r-- | chain/dagger.go | 14 |
2 files changed, 12 insertions, 7 deletions
diff --git a/chain/chain_manager.go b/chain/chain_manager.go index 45af61e48..b71510833 100644 --- a/chain/chain_manager.go +++ b/chain/chain_manager.go @@ -321,7 +321,6 @@ func NewChain(blocks Blocks) *BlockChain { return chain } -// This function assumes you've done your checking. No checking is done at this stage anymore func (self *ChainManager) InsertChain(chain Blocks) error { for _, block := range chain { td, messages, err := self.Ethereum.BlockManager().Process(block) @@ -330,7 +329,9 @@ func (self *ChainManager) InsertChain(chain Blocks) error { continue } - chainlogger.Infof("block process failed %v (%x)\n", block.Number, block.Hash()[:4]) + chainlogger.Infof("block #%v process failed (%x)\n", block.Number, block.Hash()[:4]) + chainlogger.Infoln(block) + chainlogger.Infoln(err) return err } diff --git a/chain/dagger.go b/chain/dagger.go index 2cf70e091..a0ccaeeca 100644 --- a/chain/dagger.go +++ b/chain/dagger.go @@ -81,13 +81,17 @@ func (pow *EasyPow) Verify(hash []byte, diff *big.Int, nonce []byte) bool { d := append(hash, nonce...) sha.Write(d) - v := ethutil.BigPow(2, 256) - ret := new(big.Int).Div(v, diff) + verification := new(big.Int).Div(ethutil.BigPow(2, 256), diff) + res := ethutil.U256(ethutil.BigD(sha.Sum(nil))) - res := new(big.Int) - res.SetBytes(sha.Sum(nil)) + /* + fmt.Printf("hash w/o nonce %x\n", hash) + fmt.Printf("2**256 / %v = %v\n", diff, verification) + fmt.Printf("%v <= %v\n", res, verification) + fmt.Printf("vlen: %d rlen: %d\n", len(verification.Bytes()), len(res.Bytes())) + */ - return res.Cmp(ret) == -1 + return res.Cmp(verification) <= 0 } func (pow *EasyPow) SetHash(hash *big.Int) { |