forked from cerc-io/plugeth
Refactored RPC client to utils so it can be reused
This commit is contained in:
parent
2012e0c67a
commit
9fce273ce9
@ -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"
|
||||||
@ -104,12 +102,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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"
|
||||||
@ -139,12 +137,7 @@ func main() {
|
|||||||
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)
|
||||||
|
13
utils/cmd.go
13
utils/cmd.go
@ -5,12 +5,23 @@ import (
|
|||||||
"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/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"
|
"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
|
||||||
|
Loading…
Reference in New Issue
Block a user