From e28632b997b4097fb6f899067ead02b90d9b887b Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 30 Jan 2014 23:50:15 +0100 Subject: [PATCH] Mine? --- dev_console.go | 4 ++-- ethereum.go | 44 ++++++++++++++++++++++++++------------------ 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/dev_console.go b/dev_console.go index 106c372f2..39176eeba 100644 --- a/dev_console.go +++ b/dev_console.go @@ -124,8 +124,8 @@ func (i *Console) ParseInput(input string) bool { ethutil.BigPow(2, 36), // diff ethutil.Big(tokens[2]))) // nonce case "decode": - d, _ := ethutil.Decode([]byte(tokens[1]), 0) - fmt.Printf("%q\n", d) + value := ethutil.NewRlpDecoder([]byte(tokens[1])) + fmt.Println(value) case "getaddr": encoded, _ := hex.DecodeString(tokens[1]) d := i.ethereum.BlockManager.BlockChain().CurrentBlock.State().Get(string(encoded)) diff --git a/ethereum.go b/ethereum.go index 2ffb6c929..810c30f49 100644 --- a/ethereum.go +++ b/ethereum.go @@ -8,7 +8,6 @@ import ( "github.com/ethereum/ethutil-go" _ "github.com/ethereum/ethwire-go" "log" - "math/big" "os" "os/signal" "path" @@ -89,26 +88,35 @@ func main() { // Fake block mining. It broadcasts a new block every 5 seconds go func() { + pow := ðchain.EasyPow{} + for { - - time.Sleep(blockTime * time.Second) - txs := ethereum.TxPool.Flush() + block := ethereum.BlockManager.BlockChain().NewBlock("82c3b0b72cf62f1a9ce97c64da8072efa28225d8", txs) - block := ethchain.CreateBlock( - ethereum.BlockManager.BlockChain().CurrentBlock.State().Root, - ethereum.BlockManager.BlockChain().LastBlockHash, - "123", - big.NewInt(1), - big.NewInt(1), - "", - txs) - err := ethereum.BlockManager.ProcessBlockWithState(block, block.State()) - if err != nil { - log.Println(err) - } else { - //log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) - } + nonce := pow.Search(block) + block.Nonce = nonce + + log.Println("nonce found:", nonce) + /* + time.Sleep(blockTime * time.Second) + + + block := ethchain.CreateBlock( + ethereum.BlockManager.BlockChain().CurrentBlock.State().Root, + ethereum.BlockManager.BlockChain().LastBlockHash, + "123", + big.NewInt(1), + big.NewInt(1), + "", + txs) + err := ethereum.BlockManager.ProcessBlockWithState(block, block.State()) + if err != nil { + log.Println(err) + } else { + //log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) + } + */ } }() }