aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamesh Nair <ram@hiddentao.com>2014-02-01 12:25:40 +0800
committerRamesh Nair <ram@hiddentao.com>2014-02-01 12:25:40 +0800
commitf4433a680482fda18b9273195ed7c65f5314f157 (patch)
tree5fd588a3aa44be7008df24f4e67629e4d616e2f0
parent9cdf8f2cba0469429f3d3f2aeacdbb4844928a0a (diff)
parente28632b997b4097fb6f899067ead02b90d9b887b (diff)
downloaddexon-f4433a680482fda18b9273195ed7c65f5314f157.tar.gz
dexon-f4433a680482fda18b9273195ed7c65f5314f157.tar.zst
dexon-f4433a680482fda18b9273195ed7c65f5314f157.zip
Merge branch 'master' into readme
Conflicts: README.md
-rw-r--r--dev_console.go16
-rw-r--r--ethereum.go48
2 files changed, 36 insertions, 28 deletions
diff --git a/dev_console.go b/dev_console.go
index 91d911ec2..39176eeba 100644
--- a/dev_console.go
+++ b/dev_console.go
@@ -76,11 +76,11 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
}
func (i *Console) PrintRoot() {
- root := ethutil.Conv(i.trie.RootT)
+ root := ethutil.Conv(i.trie.Root)
if len(root.AsBytes()) != 0 {
fmt.Println(hex.EncodeToString(root.AsBytes()))
} else {
- fmt.Println(i.trie.RootT)
+ fmt.Println(i.trie.Root)
}
}
@@ -108,15 +108,15 @@ func (i *Console) ParseInput(input string) bool {
} else {
switch tokens[0] {
case "update":
- i.trie.UpdateT(tokens[1], tokens[2])
+ i.trie.Update(tokens[1], tokens[2])
i.PrintRoot()
case "get":
- fmt.Println(i.trie.GetT(tokens[1]))
+ fmt.Println(i.trie.Get(tokens[1]))
case "root":
i.PrintRoot()
case "rawroot":
- fmt.Println(i.trie.RootT)
+ fmt.Println(i.trie.Root)
case "print":
i.db.Print()
case "dag":
@@ -124,11 +124,11 @@ 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.CurrentBlock.State().Get(string(encoded))
+ d := i.ethereum.BlockManager.BlockChain().CurrentBlock.State().Get(string(encoded))
if d != "" {
decoder := ethutil.NewRlpDecoder([]byte(d))
fmt.Println(decoder)
diff --git a/ethereum.go b/ethereum.go
index d58033cdc..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"
@@ -84,31 +83,40 @@ func main() {
ethereum.Start()
if StartMining {
- blockTime := time.Duration(15)
+ blockTime := time.Duration(10)
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(blockTime * time.Second)
+ pow := &ethchain.EasyPow{}
+ for {
txs := ethereum.TxPool.Flush()
-
- block := ethchain.CreateBlock(
- ethereum.BlockManager.CurrentBlock.State().Root,
- ethereum.BlockManager.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())
- }
+ block := ethereum.BlockManager.BlockChain().NewBlock("82c3b0b72cf62f1a9ce97c64da8072efa28225d8", txs)
+
+ 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())
+ }
+ */
}
}()
}