From 97882a65bbe87beed8f939591f13ee01f7af6fa7 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 24 Jan 2014 20:16:48 +0100 Subject: Dev test mining --- ethereum.go | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'ethereum.go') diff --git a/ethereum.go b/ethereum.go index e7775f143..9d81880f2 100644 --- a/ethereum.go +++ b/ethereum.go @@ -6,11 +6,14 @@ import ( "github.com/ethereum/eth-go" "github.com/ethereum/ethchain-go" "github.com/ethereum/ethutil-go" + "github.com/ethereum/ethwire-go" "log" + "math/big" "os" "os/signal" "path" "runtime" + "time" ) const Debug = true @@ -78,21 +81,32 @@ func main() { RegisterInterupts(ethereum) + ethereum.Start() + if StartMining { - log.Println("Mining started") - dagger := ðchain.Dagger{} + log.Println("Dev Test Mining started") + // Fake block mining. It broadcasts a new block every 5 seconds go func() { for { - res := dagger.Search(ethutil.Big("01001"), ethutil.BigPow(2, 36)) - log.Println("Res dagger", res) - //ethereum.Broadcast("blockmine", ethutil.Encode(res.String())) + time.Sleep(5 * time.Second) + + block := ethchain.CreateBlock( + ethereum.BlockManager.BlockChain().LastBlock.State().Root, + ethereum.BlockManager.LastBlockHash, + "123", + big.NewInt(1), + big.NewInt(1), + "", + ethereum.TxPool.Flush()) + + ethereum.BlockManager.ProcessBlockWithState(block, block.State()) + ethereum.Broadcast(ethwire.MsgBlockTy, block.RlpData()) + log.Println("\n", block.String()) } }() } - ethereum.Start() - // Wait for shutdown ethereum.WaitForShutdown() } -- cgit v1.2.3