diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-25 08:25:36 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-25 08:25:36 +0800 |
commit | e32b1a1d975e1bd8dfc3211b400872ba42bf1498 (patch) | |
tree | 8b5244475d7fa45fa33f0f70627d0f775c4e629b | |
parent | 97882a65bbe87beed8f939591f13ee01f7af6fa7 (diff) | |
download | go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.tar go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.tar.gz go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.tar.bz2 go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.tar.lz go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.tar.xz go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.tar.zst go-tangerine-e32b1a1d975e1bd8dfc3211b400872ba42bf1498.zip |
Fake block mining
-rw-r--r-- | ethereum.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ethereum.go b/ethereum.go index 9d81880f2..2d79659b0 100644 --- a/ethereum.go +++ b/ethereum.go @@ -6,7 +6,7 @@ import ( "github.com/ethereum/eth-go" "github.com/ethereum/ethchain-go" "github.com/ethereum/ethutil-go" - "github.com/ethereum/ethwire-go" + _ "github.com/ethereum/ethwire-go" "log" "math/big" "os" @@ -84,12 +84,15 @@ func main() { ethereum.Start() if StartMining { - log.Println("Dev Test Mining started") + blockTime := time.Duration(15) + log.Printf("Dev Test Mining started. Blocks found each %d seconds\n", blockTime) // Fake block mining. It broadcasts a new block every 5 seconds go func() { for { - time.Sleep(5 * time.Second) + txs := ethereum.TxPool.Flush() + + time.Sleep(blockTime * time.Second) block := ethchain.CreateBlock( ethereum.BlockManager.BlockChain().LastBlock.State().Root, @@ -98,11 +101,13 @@ func main() { 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()) + txs) + err := ethereum.BlockManager.ProcessBlockWithState(block, block.State()) + if err != nil { + log.Println(err) + } else { + log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) + } } }() } |