File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -450,25 +450,28 @@ async fn on_replication_connection(
450450 use tracing:: info;
451451
452452 let mut protocol = ProtocolBuilder :: new ( is_initiator) . connect ( stream. compat ( ) ) ;
453+ let mut channel_opened = false ;
453454 while let Some ( event) = protocol. next ( ) . await {
454455 let event = event?;
455456 match event {
456457 Event :: Handshake ( _) => {
457458 info ! ( "Event::Handshake" ) ;
458- if is_initiator {
459+ if is_initiator && !channel_opened {
459460 protocol. open ( * hypercore. key ( ) ) . await ?;
461+ channel_opened = true ;
460462 }
461463 }
462464 Event :: DiscoveryKey ( dkey) => {
463465 info ! ( "Event::DiscoveryKey" ) ;
464- if hypercore. discovery_key == dkey {
466+ if hypercore. discovery_key == dkey && !channel_opened {
465467 protocol. open ( * hypercore. key ( ) ) . await ?;
468+ channel_opened = true ;
466469 } else {
467470 panic ! ( "Invalid discovery key" ) ;
468471 }
469472 }
470473 Event :: Channel ( channel) => {
471- info ! ( "Event::Channel" ) ;
474+ info ! ( "Event::Channel is_initiator = {is_initiator} " ) ;
472475 hypercore. on_replication_peer ( channel) ;
473476 }
474477 Event :: Close ( _dkey) => {
You can’t perform that action at this time.
0 commit comments