From d09158161ea569aedeb8c3dab817b46499e476ab Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Mon, 23 Jan 2023 10:32:04 +0300 Subject: [PATCH] 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 --- pkg/services/rpcsrv/server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/rpcsrv/server.go b/pkg/services/rpcsrv/server.go index 97ef82e73..e2a5d2a58 100644 --- a/pkg/services/rpcsrv/server.go +++ b/pkg/services/rpcsrv/server.go @@ -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 {