@@ -152,11 +152,13 @@ func createDecoder(info *notificationsProtocol, handshakeDecoder HandshakeDecode
152
152
}
153
153
154
154
// createNotificationsMessageHandler returns a function that is called by the handler of *inbound* streams.
155
- func (s * Service ) createNotificationsMessageHandler (info * notificationsProtocol ,
156
- messageHandler NotificationsMessageHandler ,
157
- batchHandler NotificationsMessageBatchHandler ) messageHandler {
155
+ func (s * Service ) createNotificationsMessageHandler (
156
+ info * notificationsProtocol ,
157
+ notificationsMessageHandler NotificationsMessageHandler ,
158
+ batchHandler NotificationsMessageBatchHandler ,
159
+ ) messageHandler {
158
160
return func (stream libp2pnetwork.Stream , m Message ) error {
159
- if m == nil || info == nil || info .handshakeValidator == nil || messageHandler == nil {
161
+ if m == nil || info == nil || info .handshakeValidator == nil || notificationsMessageHandler == nil {
160
162
return nil
161
163
}
162
164
@@ -214,6 +216,10 @@ func (s *Service) createNotificationsMessageHandler(info *notificationsProtocol,
214
216
}
215
217
216
218
logger .Tracef ("receiver: sent handshake to peer %s using protocol %s" , peer , info .protocolID )
219
+
220
+ if err := stream .CloseWrite (); err != nil {
221
+ logger .Tracef ("failed to close stream for writing: %s" , err )
222
+ }
217
223
}
218
224
219
225
return nil
@@ -227,7 +233,7 @@ func (s *Service) createNotificationsMessageHandler(info *notificationsProtocol,
227
233
return nil
228
234
}
229
235
230
- propagate , err := messageHandler (peer , msg )
236
+ propagate , err := notificationsMessageHandler (peer , msg )
231
237
if err != nil {
232
238
return err
233
239
}
@@ -380,6 +386,10 @@ func (s *Service) sendHandshake(peer peer.ID, hs Handshake, info *notificationsP
380
386
hsData .received = true
381
387
}
382
388
389
+ if err := stream .CloseRead (); err != nil {
390
+ logger .Tracef ("failed to close stream for reading: %s" , err )
391
+ }
392
+
383
393
if err = info .handshakeValidator (peer , resp ); err != nil {
384
394
logger .Tracef ("failed to validate handshake from peer %s using protocol %s: %s" , peer , info .protocolID , err )
385
395
hsData .validated = false
0 commit comments