Commit 5e36e3cc authored by obscuren's avatar obscuren

Process transactions

parent ec883db3
...@@ -144,11 +144,15 @@ func (i *Console) ParseInput(input string) bool { ...@@ -144,11 +144,15 @@ func (i *Console) ParseInput(input string) bool {
case "encode": case "encode":
fmt.Printf("%q\n", ethutil.Encode(tokens[1])) fmt.Printf("%q\n", ethutil.Encode(tokens[1]))
case "tx": case "tx":
recipient, _ := hex.DecodeString(tokens[1]) recipient, err := hex.DecodeString(tokens[1])
if err != nil {
fmt.Println("recipient err:", err)
} else {
tx := ethchain.NewTransaction(recipient, ethutil.Big(tokens[2]), []string{""}) tx := ethchain.NewTransaction(recipient, ethutil.Big(tokens[2]), []string{""})
fmt.Printf("%x\n", tx.Hash()) fmt.Printf("%x\n", tx.Hash())
i.ethereum.TxPool.QueueTransaction(tx) i.ethereum.TxPool.QueueTransaction(tx)
}
case "gettx": case "gettx":
addr, _ := hex.DecodeString(tokens[1]) addr, _ := hex.DecodeString(tokens[1])
data, _ := ethutil.Config.Db.Get(addr) data, _ := ethutil.Config.Db.Get(addr)
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/ethereum/eth-go" "github.com/ethereum/eth-go"
"github.com/ethereum/ethchain-go" "github.com/ethereum/ethchain-go"
"github.com/ethereum/ethutil-go" "github.com/ethereum/ethutil-go"
"github.com/ethereum/ethwire-go"
"log" "log"
"os" "os"
"os/signal" "os/signal"
...@@ -88,17 +89,12 @@ func main() { ...@@ -88,17 +89,12 @@ func main() {
// Create a new block which we're going to mine // Create a new block which we're going to mine
block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs) block := ethereum.BlockManager.BlockChain().NewBlock(addr, txs)
// Apply all transactions to the block // Apply all transactions to the block
ethereum.BlockManager.ApplyTransactions(block) ethereum.BlockManager.ApplyTransactions(block, block.Transactions())
// Search the nonce // Search the nonce
block.Nonce = pow.Search(block) block.Nonce = pow.Search(block)
// Process the block and verify ethereum.Broadcast(ethwire.MsgBlockTy, []interface{}{block.RlpValue().Value})
err := ethereum.BlockManager.ProcessBlock(block)
if err != nil {
log.Println(err)
} else {
log.Println("\n+++++++ MINED BLK +++++++\n", block.String()) log.Println("\n+++++++ MINED BLK +++++++\n", block.String())
} }
}
}() }()
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment