aboutsummaryrefslogtreecommitdiffstats
path: root/ethereum.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-01-25 03:16:48 +0800
committerobscuren <geffobscura@gmail.com>2014-01-25 03:16:48 +0800
commit97882a65bbe87beed8f939591f13ee01f7af6fa7 (patch)
treeacf017ecd4bfd8ed89c5ca0ecf34fb033cc1d969 /ethereum.go
parentc636f8e3e66a24a13d2cc6b2e89280f362e0f91b (diff)
downloadgo-tangerine-97882a65bbe87beed8f939591f13ee01f7af6fa7.tar.gz
go-tangerine-97882a65bbe87beed8f939591f13ee01f7af6fa7.tar.zst
go-tangerine-97882a65bbe87beed8f939591f13ee01f7af6fa7.zip
Dev test mining
Diffstat (limited to 'ethereum.go')
-rw-r--r--ethereum.go28
1 files changed, 21 insertions, 7 deletions
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 := &ethchain.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()
}