withTCPDialer overwrites the node-oriented dialer of rpc package, skips the naconn resolver and implies a default resolving method: addr := string(remote node ID).
()
| 47 | // withTCPDialer overwrites the node-oriented dialer of rpc package, skips the naconn resolver |
| 48 | // and implies a default resolving method: addr := string(remote node ID). |
| 49 | func withTCPDialer() func() { |
| 50 | dial := rpc.Dial |
| 51 | dialEx := rpc.DialEx |
| 52 | |
| 53 | rpc.Dial = func(remote proto.NodeID) (net.Conn, error) { |
| 54 | return net.Dial("tcp", string(remote)) |
| 55 | } |
| 56 | |
| 57 | rpc.DialEx = func(remote proto.NodeID, isAnonymous bool) (net.Conn, error) { |
| 58 | return net.Dial("tcp", string(remote)) |
| 59 | } |
| 60 | |
| 61 | // recover func |
| 62 | return func() { |
| 63 | rpc.Dial = dial |
| 64 | rpc.DialEx = dialEx |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func BenchmarkSessionPool_Get(b *testing.B) { |
| 69 | Convey("session pool", b, func(c C) { |
no outgoing calls
no test coverage detected