2

I just recently updated my local repo of go-ethereum to commit 8ec6ccc54d1da7bbaa87bd0b489b1778ea729c90

I previously used the IPC Client like this in my code:

var client rpc.Client
if len(pathToIPCEndpoint) == 0 {
    glog.Errorf("No path to ipc endpoint specified, using default path: %s\n", node.DefaultIPCEndpoint())
    client, err = rpc.NewIPCClient(node.DefaultIPCEndpoint())
    if err != nil {
        glog.Fatalln(err)
    }
} else {
    client, err = rpc.NewIPCClient(pathToIPCEndpoint)
    if err != nil {
        glog.Fatalln(err)
    }
}

backend = backends.NewRPCBackend(client)

It seems like one should use rpc.DialIPC() since NewIPCCLient does not exists anymore. However I can't quite figure out how to migrate this code and couldn't find any documentation on the API changes.

Thanks in advance

1

The changes were introduced in this commit ("rpc: add new client, use it everywhere"). Have a look at the split-diff view to understand how internal calls to the APIs have changed.

You'll need to include a connection context from the Go-lang context package, and pass that in to DialIPC() as a parameter.

Instead of a JSON-encoded structure, the new API returns a pointer to a Client structure (from newClient())...:

c := &Client{
    writeConn:   conn,
    isHTTP:      isHTTP,
    connectFunc: connectFunc,
    close:       make(chan struct{}),
    didQuit:     make(chan struct{}),
    reconnected: make(chan net.Conn),
    readErr:     make(chan error),
    readResp:    make(chan []*jsonrpcMessage),
    requestOp:   make(chan *requestOp),
    sendDone:    make(chan error, 1),
    respWait:    make(map[string]*requestOp),
    subs:        make(map[string]*ClientSubscription),

...which you can continue to pass to NewRPCBackend(), which has been updated to take a pointer argument.

  • Thanks, I figured that part out since you answered. It seems like the method to create a new context is still in TODO state, or am I wrong? – MethDamon Jul 29 '16 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.