rpc, p2p/simulations: use github.com/gorilla/websocket (#20289)
* rpc: improve codec abstraction rpc.ServerCodec is an opaque interface. There was only one way to get a codec using existing APIs: rpc.NewJSONCodec. This change exports newCodec (as NewFuncCodec) and NewJSONCodec (as NewCodec). It also makes all codec methods non-public to avoid showing internals in godoc. While here, remove codec options in tests because they are not supported anymore. * p2p/simulations: use github.com/gorilla/websocket This package was the last remaining user of golang.org/x/net/websocket. Migrating to the new library wasn't straightforward because it is no longer possible to treat WebSocket connections as a net.Conn. * vendor: delete golang.org/x/net/websocket * rpc: fix godoc comments and run gofmt
This commit is contained in:
committed by
Péter Szilágyi
parent
9e71f55bfa
commit
7c4a4eb58a
10
rpc/types.go
10
rpc/types.go
@ -45,19 +45,19 @@ type Error interface {
|
||||
// a RPC session. Implementations must be go-routine safe since the codec can be called in
|
||||
// multiple go-routines concurrently.
|
||||
type ServerCodec interface {
|
||||
Read() (msgs []*jsonrpcMessage, isBatch bool, err error)
|
||||
Close()
|
||||
readBatch() (msgs []*jsonrpcMessage, isBatch bool, err error)
|
||||
close()
|
||||
jsonWriter
|
||||
}
|
||||
|
||||
// jsonWriter can write JSON messages to its underlying connection.
|
||||
// Implementations must be safe for concurrent use.
|
||||
type jsonWriter interface {
|
||||
Write(context.Context, interface{}) error
|
||||
writeJSON(context.Context, interface{}) error
|
||||
// Closed returns a channel which is closed when the connection is closed.
|
||||
Closed() <-chan interface{}
|
||||
closed() <-chan interface{}
|
||||
// RemoteAddr returns the peer address of the connection.
|
||||
RemoteAddr() string
|
||||
remoteAddr() string
|
||||
}
|
||||
|
||||
type BlockNumber int64
|
||||
|
Reference in New Issue
Block a user