From 6ab368cf7426195a0d44b14ad6d82c020c024395 Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 28 Jan 2014 15:35:19 +0100 Subject: [PATCH 1/4] Changed block chain specific methods --- dev_console.go | 2 +- ethereum.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dev_console.go b/dev_console.go index 91d911ec2..74ba343cd 100644 --- a/dev_console.go +++ b/dev_console.go @@ -128,7 +128,7 @@ func (i *Console) ParseInput(input string) bool { fmt.Printf("%q\n", d) 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..8608ca47a 100644 --- a/ethereum.go +++ b/ethereum.go @@ -84,7 +84,7 @@ func main() { ethereum.Start() if StartMining { - blockTime := time.Duration(15) + blockTime := time.Duration(2) log.Printf("Dev Test Mining started. Blocks found each %d seconds\n", blockTime) // Fake block mining. It broadcasts a new block every 5 seconds @@ -96,8 +96,8 @@ func main() { txs := ethereum.TxPool.Flush() block := ethchain.CreateBlock( - ethereum.BlockManager.CurrentBlock.State().Root, - ethereum.BlockManager.LastBlockHash, + ethereum.BlockManager.BlockChain().CurrentBlock.State().Root, + ethereum.BlockManager.BlockChain().LastBlockHash, "123", big.NewInt(1), big.NewInt(1), From ab43c001f7642eaacb8d3bbcde5f0016ce73a85d Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Wed, 29 Jan 2014 14:08:40 -0800 Subject: [PATCH 2/4] typo? --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fe3ec304d..3693fb6b0 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Ethereum Go makes use of a modified `secp256k1-go` and therefor GMP. Install ======= -```go get -u -t https://github.com/ethereum/go-ethereum``` +```go get -u -t github.com/ethereum/go-ethereum``` Command line options From 27a03d3eea5451ddb84dbb1ff33ee916259635d0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 30 Jan 2014 00:47:09 +0100 Subject: [PATCH 3/4] Updated to the new Trie --- dev_console.go | 10 +++++----- ethereum.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dev_console.go b/dev_console.go index 74ba343cd..106c372f2 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": diff --git a/ethereum.go b/ethereum.go index 8608ca47a..2ffb6c929 100644 --- a/ethereum.go +++ b/ethereum.go @@ -84,7 +84,7 @@ func main() { ethereum.Start() if StartMining { - blockTime := time.Duration(2) + 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 @@ -107,7 +107,7 @@ func main() { if err != nil { log.Println(err) } else { - log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) + //log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) } } }() From e28632b997b4097fb6f899067ead02b90d9b887b Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 30 Jan 2014 23:50:15 +0100 Subject: [PATCH 4/4] Mine? --- dev_console.go | 4 ++-- ethereum.go | 46 +++++++++++++++++++++++++++------------------- 2 files changed, 29 insertions(+), 21 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() { - for { - - time.Sleep(blockTime * time.Second) + pow := ðchain.EasyPow{} + for { txs := ethereum.TxPool.Flush() - - 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()) - } + 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()) + } + */ } }() }