diff options
author | obscuren <geffobscura@gmail.com> | 2014-01-25 00:51:35 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-01-25 00:51:35 +0800 |
commit | c636f8e3e66a24a13d2cc6b2e89280f362e0f91b (patch) | |
tree | 27694da209d38221fbbccbfb6bbfd0b1dd12322d /dev_console.go | |
parent | 7bf4f2a908235c75e795d0ca3796c76f9fc99454 (diff) | |
download | dexon-c636f8e3e66a24a13d2cc6b2e89280f362e0f91b.tar.gz dexon-c636f8e3e66a24a13d2cc6b2e89280f362e0f91b.tar.zst dexon-c636f8e3e66a24a13d2cc6b2e89280f362e0f91b.zip |
Broadcast block
Diffstat (limited to 'dev_console.go')
-rw-r--r-- | dev_console.go | 32 |
1 files changed, 32 insertions, 0 deletions
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{""}) |