diff --git a/client.go b/client.go index 03ec9bf1e339ec0cf0b871b176a8aabcc7777dbd..9d42cfc0519d816d76798de7c9248a1e1377db83 100644 --- a/client.go +++ b/client.go @@ -102,7 +102,7 @@ type clientConn struct { func (c *Client) newClientConn(conn ServerCodec) *clientConn { ctx := context.Background() ctx = context.WithValue(ctx, clientContextKey{}, c) - ctx = context.WithValue(ctx, peerInfoContextKey{}, conn.peerInfo()) + ctx = context.WithValue(ctx, peerInfoContextKey{}, conn.PeerInfo()) handler := newHandler(ctx, conn, c.r) return &clientConn{conn, handler} } diff --git a/handler.go b/handler.go index 7a699e7d1e4ce5d59161c5f0ac9028ecef2a143f..b1afde1a620de9495b9d4388ceae8bad00e43c45 100644 --- a/handler.go +++ b/handler.go @@ -133,7 +133,6 @@ func (h *handler) handleMsg(msg *jsonrpcMessage) { if ok := h.handleImmediate(msg); ok { return } - h.startCallProc(func(cp *callProc) { answer := h.handleCallMsg(cp, msg) h.addSubscriptions(cp.notifiers) diff --git a/http.go b/http.go index b8ba46906faf0c5334525db8f70cdd151a6c9890..3a5da57ef213c893cf74bba74ed2cee95f300e7d 100644 --- a/http.go +++ b/http.go @@ -64,8 +64,8 @@ func (hc *httpConn) writeJSON(context.Context, any) error { panic("writeJSON called on httpConn") } -func (hc *httpConn) peerInfo() PeerInfo { - panic("peerInfo called on httpConn") +func (hc *httpConn) PeerInfo() PeerInfo { + panic("PeerInfo called on httpConn") } func (hc *httpConn) remoteAddr() string { @@ -263,7 +263,7 @@ func newHTTPServerConn(r *http.Request, w http.ResponseWriter, pi PeerInfo) Serv return c } -func (c *httpServerConn) peerInfo() PeerInfo { +func (c *httpServerConn) PeerInfo() PeerInfo { return c.pi } @@ -293,7 +293,7 @@ func (c *httpServerConn) remoteAddr() string { // RemoteAddr returns the peer address of the underlying connection. func (t *httpServerConn) RemoteAddr() string { - return t.peerInfo().RemoteAddr + return t.PeerInfo().RemoteAddr } // SetWriteDeadline does nothing and always returns nil. diff --git a/json.go b/json.go index e58162265e42f2f8ed98141368652ed6d5019652..5d2ef41de73282827303fa5276df167a2cc1f2b4 100644 --- a/json.go +++ b/json.go @@ -216,7 +216,7 @@ func NewCodec(conn Conn) ServerCodec { return NewFuncCodec(conn, enc.Encode, dec.Decode) } -func (c *jsonCodec) peerInfo() PeerInfo { +func (c *jsonCodec) PeerInfo() PeerInfo { // This returns "ipc" because all other built-in transports have a separate codec type. return PeerInfo{Transport: "ipc", RemoteAddr: c.remote} } diff --git a/types.go b/types.go index b2c54f5378c4ad8e461dbf0e25d63129239d4059..0cdeb630e838c5c3f5d496d1434d454b2e4aa5f2 100644 --- a/types.go +++ b/types.go @@ -28,7 +28,7 @@ import ( // a RPC session. Implementations must be go-routine safe since the codec can be called in // multiple go-routines concurrently. type ServerCodec interface { - peerInfo() PeerInfo + PeerInfo() PeerInfo readBatch() (msgs []*jsonrpcMessage, isBatch bool, err error) close() diff --git a/websocket.go b/websocket.go index d34cd7900bf15ab8d936ad2f0f72cb434b677da3..94538b862c51b3d6bca01f68ef4051e331b8870d 100644 --- a/websocket.go +++ b/websocket.go @@ -194,7 +194,7 @@ func (wc *websocketCodec) close() { wc.conn.CloseRead(context.Background()) } -func (wc *websocketCodec) peerInfo() PeerInfo { +func (wc *websocketCodec) PeerInfo() PeerInfo { return wc.info }