@@ -131,9 +131,9 @@ func (n *NetworkManager) routeIncomingMessage(msg []byte) ([]byte, NetworkHandle
131
131
if l == 0 {
132
132
return nil , nil , false
133
133
}
134
- handlerID := msg [l - 1 ]
134
+ handlerID := msg [0 ]
135
135
handler , ok := n .handlers [handlerID ]
136
- return msg [: l - 1 ], handler , ok
136
+ return msg [1 : ], handler , ok
137
137
}
138
138
139
139
func (n * NetworkManager ) handleSharedRequestID (
@@ -344,7 +344,7 @@ func (w *WrappedAppSender) SendAppRequest(
344
344
requestID uint32 ,
345
345
appRequestBytes []byte ,
346
346
) error {
347
- appRequestBytes = append ( appRequestBytes , w . handler )
347
+ appRequestBytes = w . createMessageBytes ( appRequestBytes )
348
348
for nodeID := range nodeIDs {
349
349
newRequestID := w .n .getSharedRequestID (w .handler , nodeID , requestID )
350
350
if err := w .n .sender .SendAppRequest (
@@ -384,7 +384,7 @@ func (w *WrappedAppSender) SendAppResponse(
384
384
func (w * WrappedAppSender ) SendAppGossip (ctx context.Context , appGossipBytes []byte ) error {
385
385
return w .n .sender .SendAppGossip (
386
386
ctx ,
387
- append ( appGossipBytes , w . handler ),
387
+ w . createMessageBytes ( appGossipBytes ),
388
388
)
389
389
}
390
390
@@ -396,7 +396,7 @@ func (w *WrappedAppSender) SendAppGossipSpecific(
396
396
return w .n .sender .SendAppGossipSpecific (
397
397
ctx ,
398
398
nodeIDs ,
399
- append ( appGossipBytes , w . handler ),
399
+ w . createMessageBytes ( appGossipBytes ),
400
400
)
401
401
}
402
402
@@ -420,7 +420,7 @@ func (w *WrappedAppSender) SendCrossChainAppRequest(
420
420
ctx ,
421
421
chainID ,
422
422
requestID ,
423
- append ( appRequestBytes , w . handler ),
423
+ w . createMessageBytes ( appRequestBytes ),
424
424
)
425
425
}
426
426
@@ -441,3 +441,10 @@ func (w *WrappedAppSender) SendCrossChainAppResponse(
441
441
// requestID is associated with which handler.
442
442
return w .n .sender .SendCrossChainAppResponse (ctx , chainID , requestID , appResponseBytes )
443
443
}
444
+
445
+ func (w * WrappedAppSender ) createMessageBytes (src []byte ) []byte {
446
+ messageBytes := make ([]byte , 1 + len (src ))
447
+ messageBytes [0 ] = w .handler
448
+ copy (messageBytes [1 :], src )
449
+ return messageBytes
450
+ }
0 commit comments