aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/gethrpctest
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2016-02-05 17:33:24 +0800
committerPéter Szilágyi <peterke@gmail.com>2016-02-05 17:33:24 +0800
commitba7c125153ce1be30985784a18edf38645406d03 (patch)
tree92c1e2b8ec6ef0d4b39381148b3497e311e80b95 /cmd/gethrpctest
parent212828963172b3921827df15abdc8602480e947d (diff)
parent188ab928c3f2a2eac5ee0f7ac42cbf2f35568bcd (diff)
downloaddexon-ba7c125153ce1be30985784a18edf38645406d03.tar.gz
dexon-ba7c125153ce1be30985784a18edf38645406d03.tar.zst
dexon-ba7c125153ce1be30985784a18edf38645406d03.zip
Merge pull request #2168 from karalabe/move-rpc-into-node
cmd, common, node, rpc: move IPC into the node itself
Diffstat (limited to 'cmd/gethrpctest')
-rw-r--r--cmd/gethrpctest/main.go61
1 files changed, 2 insertions, 59 deletions
diff --git a/cmd/gethrpctest/main.go b/cmd/gethrpctest/main.go
index 8522258a9..becd09f5a 100644
--- a/cmd/gethrpctest/main.go
+++ b/cmd/gethrpctest/main.go
@@ -18,25 +18,20 @@
package main
import (
+ "errors"
"flag"
"io/ioutil"
"log"
"os"
"os/signal"
- "path/filepath"
- "runtime"
-
- "errors"
"github.com/ethereum/go-ethereum/accounts"
- "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/ethereum/go-ethereum/node"
- "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/tests"
"github.com/ethereum/go-ethereum/whisper"
)
@@ -89,11 +84,6 @@ func main() {
}
log.Println("Initial test suite passed...")
- if err := StartIPC(stack); err != nil {
- log.Fatalf("Failed to start IPC interface: %v\n", err)
- }
- log.Println("IPC Interface started, accepting requests...")
-
// Start the RPC interface and wait until terminated
if err := StartRPC(stack); err != nil {
log.Fatalf("Failed to start RPC interface: %v", err)
@@ -109,7 +99,7 @@ func main() {
// keystore path and initial pre-state.
func MakeSystemNode(keydir string, privkey string, test *tests.BlockTest) (*node.Node, error) {
// Create a networkless protocol stack
- stack, err := node.New(&node.Config{NoDiscovery: true})
+ stack, err := node.New(&node.Config{IpcPath: node.DefaultIpcEndpoint(), NoDiscovery: true})
if err != nil {
return nil, err
}
@@ -194,50 +184,3 @@ func StartRPC(stack *node.Node) error {
glog.V(logger.Error).Infof("Unable to start RPC-HTTP interface, could not find admin API")
return errors.New("Unable to start RPC-HTTP interface")
}
-
-// StartIPC initializes an IPC interface to the given protocol stack.
-func StartIPC(stack *node.Node) error {
- var ethereum *eth.Ethereum
- if err := stack.Service(&ethereum); err != nil {
- return err
- }
-
- endpoint := `\\.\pipe\geth.ipc`
- if runtime.GOOS != "windows" {
- endpoint = filepath.Join(common.DefaultDataDir(), "geth.ipc")
- }
-
- listener, err := rpc.CreateIPCListener(endpoint)
- if err != nil {
- return err
- }
-
- server := rpc.NewServer()
-
- // register package API's this node provides
- offered := stack.APIs()
- for _, api := range offered {
- server.RegisterName(api.Namespace, api.Service)
- glog.V(logger.Debug).Infof("Register %T under namespace '%s' for IPC service\n", api.Service, api.Namespace)
- }
-
- //var ethereum *eth.Ethereum
- //if err := stack.Service(&ethereum); err != nil {
- // return err
- //}
-
- go func() {
- glog.V(logger.Info).Infof("Start IPC server on %s\n", endpoint)
- for {
- conn, err := listener.Accept()
- if err != nil {
- glog.V(logger.Error).Infof("Unable to accept connection - %v\n", err)
- }
-
- codec := rpc.NewJSONCodec(conn)
- go server.ServeCodec(codec)
- }
- }()
-
- return nil
-}