Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
This commit is contained in:
commit
278ee3f16c
@ -4,8 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ethereum/eth-go"
|
"github.com/ethereum/eth-go"
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
|
||||||
"github.com/ethereum/eth-go/ethrpc"
|
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/ethereal/ui"
|
"github.com/ethereum/go-ethereum/ethereal/ui"
|
||||||
"github.com/ethereum/go-ethereum/utils"
|
"github.com/ethereum/go-ethereum/utils"
|
||||||
@ -115,12 +113,7 @@ save these words so you can restore your account later: %s
|
|||||||
}
|
}
|
||||||
|
|
||||||
if StartRpc {
|
if StartRpc {
|
||||||
ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort)
|
utils.DoRpc(ethereum, RpcPort)
|
||||||
if err != nil {
|
|
||||||
log.Println("Could not start RPC interface:", err)
|
|
||||||
} else {
|
|
||||||
go ethereum.RpcServer.Start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Starting Ethereum GUI v%s\n", ethutil.Config.Ver)
|
log.Printf("Starting Ethereum GUI v%s\n", ethutil.Config.Ver)
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ethereum/eth-go"
|
"github.com/ethereum/eth-go"
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
|
||||||
"github.com/ethereum/eth-go/ethrpc"
|
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/utils"
|
"github.com/ethereum/go-ethereum/utils"
|
||||||
"log"
|
"log"
|
||||||
@ -149,12 +147,7 @@ save these words so you can restore your account later: %s
|
|||||||
go console.Start()
|
go console.Start()
|
||||||
}
|
}
|
||||||
if StartRpc {
|
if StartRpc {
|
||||||
ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort)
|
utils.DoRpc(ethereum, RpcPort)
|
||||||
if err != nil {
|
|
||||||
logger.Infoln("Could not start RPC interface:", err)
|
|
||||||
} else {
|
|
||||||
go ethereum.RpcServer.Start()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegisterInterrupts(ethereum)
|
RegisterInterrupts(ethereum)
|
||||||
|
32
utils/cmd.go
32
utils/cmd.go
@ -3,24 +3,44 @@ package utils
|
|||||||
import (
|
import (
|
||||||
"github.com/ethereum/eth-go"
|
"github.com/ethereum/eth-go"
|
||||||
"github.com/ethereum/eth-go/ethminer"
|
"github.com/ethereum/eth-go/ethminer"
|
||||||
_ "github.com/ethereum/eth-go/ethrpc"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
|
"github.com/ethereum/eth-go/ethrpc"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"log"
|
"log"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func DoRpc(ethereum *eth.Ethereum, RpcPort int) {
|
||||||
|
var err error
|
||||||
|
ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.NewPEthereum(ethereum), RpcPort)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Could not start RPC interface:", err)
|
||||||
|
} else {
|
||||||
|
go ethereum.RpcServer.Start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func DoMining(ethereum *eth.Ethereum) {
|
func DoMining(ethereum *eth.Ethereum) {
|
||||||
// Set Mining status
|
// Set Mining status
|
||||||
ethereum.Mining = true
|
ethereum.Mining = true
|
||||||
|
|
||||||
log.Println("Miner started")
|
if ethutil.GetKeyRing().Len() == 0 {
|
||||||
|
log.Println("No address found, can't start mining")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
keyPair := ethutil.GetKeyRing().Get(0)
|
||||||
|
addr := keyPair.Address()
|
||||||
|
|
||||||
// Fake block mining. It broadcasts a new block every 5 seconds
|
|
||||||
go func() {
|
go func() {
|
||||||
keyPair := ethutil.GetKeyRing().Get(0)
|
// Give it some time to connect with peers
|
||||||
addr := keyPair.Address()
|
time.Sleep(3 * time.Second)
|
||||||
|
|
||||||
|
for ethereum.IsUpToDate() == false {
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
}
|
||||||
|
log.Println("Miner started")
|
||||||
|
|
||||||
miner := ethminer.NewDefaultMiner(addr, ethereum)
|
miner := ethminer.NewDefaultMiner(addr, ethereum)
|
||||||
miner.Start()
|
miner.Start()
|
||||||
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user