Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add names to nameless routes #1986

Merged
merged 3 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions infrastructure/network/netadapter/netadapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions infrastructure/network/netadapter/netconnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/network/netadapter/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(fmt.Sprintf("%s - outgoing", name), outgoingRouteMaxMessages),
}
return &router
}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/network/rpcclient/rpcrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down