diff options
author | obscuren <geffobscura@gmail.com> | 2014-05-15 03:34:21 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-05-15 03:34:21 +0800 |
commit | 942f552c620471602326c1ded54095c1cf41ed76 (patch) | |
tree | cbc1f21a967bb522afad6c891afb4c4628f16ab4 /ethereum | |
parent | 809b4ae0f68da7a6904208662dc316cd669184fe (diff) | |
parent | a73ae8727d38391c6975a9fa149043e6c69a2f30 (diff) | |
download | go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.tar go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.tar.gz go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.tar.bz2 go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.tar.lz go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.tar.xz go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.tar.zst go-tangerine-942f552c620471602326c1ded54095c1cf41ed76.zip |
Merge branch 'release/poc5-rc6'poc5-rc6
Diffstat (limited to 'ethereum')
-rw-r--r-- | ethereum/dev_console.go | 8 | ||||
-rw-r--r-- | ethereum/ethereum.go | 54 |
2 files changed, 21 insertions, 41 deletions
diff --git a/ethereum/dev_console.go b/ethereum/dev_console.go index 9bdd58942..5941c03ab 100644 --- a/ethereum/dev_console.go +++ b/ethereum/dev_console.go @@ -173,8 +173,8 @@ func (i *Console) ParseInput(input string) bool { } else { tx := ethchain.NewTransactionMessage(recipient, ethutil.Big(tokens[2]), ethutil.Big(tokens[3]), ethutil.Big(tokens[4]), nil) - key := ethutil.Config.Db.GetKeys()[0] - tx.Sign(key.PrivateKey) + keyPair := ethutil.GetKeyRing().Get(0) + tx.Sign(keyPair.PrivateKey) i.ethereum.TxPool().QueueTransaction(tx) fmt.Printf("%x\n", tx.Hash()) @@ -207,8 +207,8 @@ func (i *Console) ParseInput(input string) bool { contract := ethchain.NewContractCreationTx(ethutil.Big(tokens[0]), ethutil.Big(tokens[1]), ethutil.Big(tokens[1]), mainScript, initScript) - key := ethutil.Config.Db.GetKeys()[0] - contract.Sign(key.PrivateKey) + keyPair := ethutil.GetKeyRing().Get(0) + contract.Sign(keyPair.PrivateKey) i.ethereum.TxPool().QueueTransaction(contract) diff --git a/ethereum/ethereum.go b/ethereum/ethereum.go index babebbb48..2abf6da42 100644 --- a/ethereum/ethereum.go +++ b/ethereum/ethereum.go @@ -1,13 +1,9 @@ package main import ( - "encoding/hex" "fmt" "github.com/ethereum/eth-go" "github.com/ethereum/eth-go/ethchain" - "github.com/ethereum/eth-go/ethminer" - "github.com/ethereum/eth-go/ethpub" - "github.com/ethereum/eth-go/ethrpc" "github.com/ethereum/eth-go/ethutil" "github.com/ethereum/go-ethereum/utils" "log" @@ -68,10 +64,9 @@ func main() { log.SetOutput(logfile) logSys = log.New(logfile, "", flags) logger.AddLogSystem(logSys) - } - /*else { + } else { logSys = log.New(os.Stdout, "", flags) - }*/ + } ethchain.InitFees() @@ -106,8 +101,19 @@ func main() { } os.Exit(0) case ExportKey: - key := ethutil.Config.Db.GetKeys()[0] - logSys.Println(fmt.Sprintf("prvk: %x\n", key.PrivateKey)) + keyPair := ethutil.GetKeyRing().Get(0) + fmt.Printf(` +Generating new address and keypair. +Please keep your keys somewhere save. + +++++++++++++++++ KeyRing +++++++++++++++++++ +addr: %x +prvk: %x +pubk: %x +++++++++++++++++++++++++++++++++++++++++++++ +save these words so you can restore your account later: %s +`, keyPair.Address(), keyPair.PrivateKey, keyPair.PublicKey) + os.Exit(0) case ShowGenesis: logSys.Println(ethereum.BlockChain().Genesis()) @@ -127,28 +133,7 @@ func main() { ethereum.Mining = StartMining if StartMining { - logger.Infoln("Miner started") - - // Fake block mining. It broadcasts a new block every 5 seconds - go func() { - - if StartMining { - logger.Infoln("Miner started") - - go func() { - data, _ := ethutil.Config.Db.Get([]byte("KeyRing")) - keyRing := ethutil.NewValueFromBytes(data) - addr := keyRing.Get(1).Bytes() - - pair, _ := ethchain.NewKeyPairFromSec(ethutil.FromHex(hex.EncodeToString(addr))) - - miner := ethminer.NewDefaultMiner(pair.Address(), ethereum) - miner.Start() - - }() - } - }() - + utils.DoMining(ethereum) } if StartConsole { @@ -162,12 +147,7 @@ func main() { go console.Start() } if StartRpc { - ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort) - if err != nil { - logger.Infoln("Could not start RPC interface:", err) - } else { - go ethereum.RpcServer.Start() - } + utils.DoRpc(ethereum, RpcPort) } RegisterInterrupts(ethereum) |