mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Add names to nameless routes (#1986)
* add names to nameless routes * Update router.go Co-authored-by: Ori Newman <orinewman1@gmail.com>
This commit is contained in:
parent
58d627e05a
commit
2eca0f0b5f
@ -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()
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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})
|
||||
|
Loading…
x
Reference in New Issue
Block a user