Broadcast block
This commit is contained in:
parent
7bf4f2a908
commit
c636f8e3e6
|
@ -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{""})
|
||||
|
||||
|
|
Loading…
Reference in New Issue