From c129fbe5b19c4587934eeb5448e1cee1805185d3 Mon Sep 17 00:00:00 2001 From: VassilyChe Date: Wed, 23 Mar 2022 13:01:25 +0300 Subject: [PATCH 1/2] add names to nameless routes --- infrastructure/network/netadapter/netadapter.go | 4 ++-- infrastructure/network/netadapter/netconnection.go | 4 ++-- infrastructure/network/netadapter/router/router.go | 4 ++-- infrastructure/network/rpcclient/rpcrouter.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/infrastructure/network/netadapter/netadapter.go b/infrastructure/network/netadapter/netadapter.go index a2111e52a7..33fe00df89 100644 --- a/infrastructure/network/netadapter/netadapter.go +++ b/infrastructure/network/netadapter/netadapter.go @@ -128,7 +128,7 @@ func (na *NetAdapter) P2PConnectionCount() int { } func (na *NetAdapter) onP2PConnectedHandler(connection server.Connection) error { - netConnection := newNetConnection(connection, na.p2pRouterInitializer) + netConnection := newNetConnection(connection, na.p2pRouterInitializer, "on P2P connected") na.p2pConnectionsLock.Lock() defer na.p2pConnectionsLock.Unlock() @@ -148,7 +148,7 @@ func (na *NetAdapter) onP2PConnectedHandler(connection server.Connection) error } func (na *NetAdapter) onRPCConnectedHandler(connection server.Connection) error { - netConnection := newNetConnection(connection, na.rpcRouterInitializer) + netConnection := newNetConnection(connection, na.rpcRouterInitializer, "on RPC connected") netConnection.setOnDisconnectedHandler(func() {}) netConnection.start() diff --git a/infrastructure/network/netadapter/netconnection.go b/infrastructure/network/netadapter/netconnection.go index 13fec6f1d5..8f0c655040 100644 --- a/infrastructure/network/netadapter/netconnection.go +++ b/infrastructure/network/netadapter/netconnection.go @@ -20,8 +20,8 @@ type NetConnection struct { isRouterClosed uint32 } -func newNetConnection(connection server.Connection, routerInitializer RouterInitializer) *NetConnection { - router := routerpkg.NewRouter() +func newNetConnection(connection server.Connection, routerInitializer RouterInitializer, name string) *NetConnection { + router := routerpkg.NewRouter(name) netConnection := &NetConnection{ connection: connection, diff --git a/infrastructure/network/netadapter/router/router.go b/infrastructure/network/netadapter/router/router.go index a4301d3c3c..5a6667ca95 100644 --- a/infrastructure/network/netadapter/router/router.go +++ b/infrastructure/network/netadapter/router/router.go @@ -24,10 +24,10 @@ type Router struct { } // NewRouter creates a new empty router -func NewRouter() *Router { +func NewRouter(name string) *Router { router := Router{ incomingRoutes: make(map[appmessage.MessageCommand]*Route), - outgoingRoute: newRouteWithCapacity("", outgoingRouteMaxMessages), + outgoingRoute: newRouteWithCapacity(name, outgoingRouteMaxMessages), } return &router } diff --git a/infrastructure/network/rpcclient/rpcrouter.go b/infrastructure/network/rpcclient/rpcrouter.go index 4e4565311b..6b893a3c2c 100644 --- a/infrastructure/network/rpcclient/rpcrouter.go +++ b/infrastructure/network/rpcclient/rpcrouter.go @@ -11,7 +11,7 @@ type rpcRouter struct { } func buildRPCRouter() (*rpcRouter, error) { - router := routerpkg.NewRouter() + router := routerpkg.NewRouter("RPC server") routes := make(map[appmessage.MessageCommand]*routerpkg.Route, len(appmessage.RPCMessageCommandToString)) for messageType := range appmessage.RPCMessageCommandToString { route, err := router.AddIncomingRoute("rpc client", []appmessage.MessageCommand{messageType}) From d5c8aec99ade5fc4caa1dc38c91886f433505a0c Mon Sep 17 00:00:00 2001 From: Aleoami Date: Sun, 27 Mar 2022 23:25:53 +0300 Subject: [PATCH 2/2] Update router.go --- infrastructure/network/netadapter/router/router.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/infrastructure/network/netadapter/router/router.go b/infrastructure/network/netadapter/router/router.go index 5a6667ca95..2f7816fd82 100644 --- a/infrastructure/network/netadapter/router/router.go +++ b/infrastructure/network/netadapter/router/router.go @@ -27,7 +27,7 @@ type Router struct { func NewRouter(name string) *Router { router := Router{ incomingRoutes: make(map[appmessage.MessageCommand]*Route), - outgoingRoute: newRouteWithCapacity(name, outgoingRouteMaxMessages), + outgoingRoute: newRouteWithCapacity(fmt.Sprintf("%s - outgoing", name), outgoingRouteMaxMessages), } return &router }