Broadcast block

This commit is contained in:
obscuren 2014-01-24 17:51:35 +01:00
parent 7bf4f2a908
commit c636f8e3e6

View File

@ -9,6 +9,8 @@ import (
"github.com/ethereum/ethchain-go" "github.com/ethereum/ethchain-go"
"github.com/ethereum/ethdb-go" "github.com/ethereum/ethdb-go"
"github.com/ethereum/ethutil-go" "github.com/ethereum/ethutil-go"
"github.com/ethereum/ethwire-go"
"math/big"
"os" "os"
"strings" "strings"
) )
@ -49,6 +51,9 @@ func (i *Console) ValidateInput(action string, argumentLength int) error {
case action == "tx" && argumentLength != 2: case action == "tx" && argumentLength != 2:
err = true err = true
expArgCount = 2 expArgCount = 2
case action == "getaddr" && argumentLength != 1:
err = true
expArgCount = 1
} }
if err { if err {
@ -109,8 +114,35 @@ func (i *Console) ParseInput(input string) bool {
case "decode": case "decode":
d, _ := ethutil.Decode([]byte(tokens[1]), 0) d, _ := ethutil.Decode([]byte(tokens[1]), 0)
fmt.Printf("%q\n", d) 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": case "encode":
fmt.Printf("%q\n", ethutil.Encode(tokens[1])) 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": case "tx":
tx := ethchain.NewTransaction(tokens[1], ethutil.Big(tokens[2]), []string{""}) tx := ethchain.NewTransaction(tokens[1], ethutil.Big(tokens[2]), []string{""})