services/rpcsrv: Strengthen Server error channel's type

According to docs, `Server` uses provided error channel only to write
encountered error to it. In this case, there is no need to accept rw
channel to create `Server` instance. Strengthening the type to
write-only will allow the caller to ensure control of reading errors
from the provided channel.

The change is backward compatible since any `chan` is `chan<-`.

Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
This commit is contained in:
Leonard Lyubich 2023-01-23 10:32:04 +03:00
parent 0c43b1ddca
commit d09158161e

View file

@ -133,7 +133,7 @@ type (
log *zap.Logger
shutdown chan struct{}
started *atomic.Bool
errChan chan error
errChan chan<- error
sessionsLock sync.Mutex
sessions map[string]*session
@ -255,7 +255,7 @@ var invalidBlockHeightError = func(index int, height int) *neorpc.Error {
// New creates a new Server struct.
func New(chain Ledger, conf config.RPC, coreServer *network.Server,
orc OracleHandler, log *zap.Logger, errChan chan error) Server {
orc OracleHandler, log *zap.Logger, errChan chan<- error) Server {
addrs := conf.GetAddresses()
httpServers := make([]*http.Server, len(addrs))
for i, addr := range addrs {