From c636f8e3e66a24a13d2cc6b2e89280f362e0f91b Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 24 Jan 2014 17:51:35 +0100 Subject: [PATCH] Broadcast block --- dev_console.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/dev_console.go b/dev_console.go index b515b3e5c..252860fc8 100644 --- a/dev_console.go +++ b/dev_console.go @@ -9,6 +9,8 @@ import ( "github.com/ethereum/ethchain-go" "github.com/ethereum/ethdb-go" "github.com/ethereum/ethutil-go" + "github.com/ethereum/ethwire-go" + "math/big" "os" "strings" ) @@ -49,6 +51,9 @@ func (i *Console) ValidateInput(action string, argumentLength int) error { case action == "tx" && argumentLength != 2: err = true expArgCount = 2 + case action == "getaddr" && argumentLength != 1: + err = true + expArgCount = 1 } if err { @@ -109,8 +114,35 @@ func (i *Console) ParseInput(input string) bool { case "decode": d, _ := ethutil.Decode([]byte(tokens[1]), 0) fmt.Printf("%q\n", d) + case "getaddr": + encoded, _ := hex.DecodeString(tokens[1]) + d := i.ethereum.BlockManager.BlockChain().LastBlock.State().Get(string(encoded)) + if d != "" { + decoder := ethutil.NewRlpDecoder([]byte(d)) + fmt.Println(decoder) + } else { + fmt.Println("getaddr: address unknown") + } case "encode": fmt.Printf("%q\n", ethutil.Encode(tokens[1])) + case "newblk": + block := ethchain.CreateBlock( + i.ethereum.BlockManager.BlockChain().LastBlock.State().Root, + i.ethereum.BlockManager.LastBlockHash, + "123", + big.NewInt(1), + big.NewInt(1), + "", + i.ethereum.TxPool.Flush(), + ) + i.ethereum.Broadcast(ethwire.MsgBlockTy, block.RlpData()) + //fmt.Println(ethutil.NewRlpValue(block.RlpData()).Get(0)) + //err := i.ethereum.BlockManager.ProcessBlock(block) + //if err != nil { + // fmt.Println(err) + //} else { + + // } case "tx": tx := ethchain.NewTransaction(tokens[1], ethutil.Big(tokens[2]), []string{""})