Commit Graph

5 Commits

Author SHA1 Message Date
Patrick Mylund Nielsen 3d91976f08
Geth 1.7.2 rebase and addition of Istanbul BFT (#207) 2017-10-31 18:24:11 -04:00
Felix Lange e32925397b rpc: add context argument to EthSubscribe
It's inconsistent not to pass it and most callers will
work with contexts anyway.
2016-08-05 20:48:33 +02:00
Felix Lange f5f042ffdc rpc: ensure client doesn't block for slow subscribers
I initially made the client block if the 100-element buffer was
exceeded. It turns out that this is inconvenient for simple uses of the
client which subscribe and perform calls on the same goroutine, e.g.

    client, _ := rpc.Dial(...)
    ch := make(chan int) // note: no buffer
    sub, _ := client.EthSubscribe(ch, "something")
    for event := range ch {
        client.Call(...)
    }

This innocent looking code will lock up if the server suddenly decides
to send 2000 notifications. In this case, the client's main loop won't
accept the call because it is trying to deliver a notification to ch.

The issue is kind of hard to explain in the docs and few people will
actually read them. Buffering is the simple option and works with close
to no overhead for subscribers that always listen.
2016-08-05 20:48:33 +02:00
Felix Lange 464660651d rpc: don't exceed context deadline while waiting for send lock 2016-08-05 13:27:02 +02:00
Felix Lange 91b7690428 rpc: add new client, use it everywhere
The new client implementation supports concurrent requests,
subscriptions and replaces the various ad hoc RPC clients
throughout go-ethereum.
2016-07-22 23:21:27 +02:00