@@ -513,7 +513,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
513513 override fun run () {
514514 handleDroppedPeers()
515515 }
516- }, 1000 , 1000 )
516+ }, 1000 , 3000 )
517517 timerTaskScheduled = true
518518 }
519519
@@ -638,7 +638,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
638638
639639 try {
640640 currentlyConnectingPeers.add(pubKey)
641- peerHandler!! .connect(pubKey.hexa(), InetSocketAddress (address, port.toInt()), 10 )
641+ peerHandler!! .connect(pubKey.hexa(), InetSocketAddress (address, port.toInt()), 3000 )
642642 LdkEventEmitter .send(EventTypes .native_log, " Connection to peer $pubKey re-established by handleDroppedPeers()." )
643643 } catch (e: Exception ) {
644644 LdkEventEmitter .send(EventTypes .native_log, " Error connecting peer $pubKey . Error: $e " )
@@ -667,19 +667,20 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
667667 currentlyConnectingPeers.add(pubKey)
668668 peerHandler!! .connect(pubKey.hexa(), InetSocketAddress (address, port.toInt()), timeout.toInt())
669669
670+ handleResolve(promise, LdkCallbackResponses .add_peer_success)
671+ } catch (e: Exception ) {
672+ handleReject(promise, LdkErrors .add_peer_fail, Error (e))
673+ } finally {
674+ currentlyConnectingPeers.remove(pubKey)
675+
676+ // Should retry if success or fail
670677 if (! addedPeers.map { it[" pubKey" ] as String }.contains(pubKey)) {
671678 addedPeers.add(hashMapOf(
672679 " address" to address,
673680 " port" to port,
674681 " pubKey" to pubKey
675682 ))
676683 }
677-
678- handleResolve(promise, LdkCallbackResponses .add_peer_success)
679- } catch (e: Exception ) {
680- handleReject(promise, LdkErrors .add_peer_fail, Error (e))
681- } finally {
682- currentlyConnectingPeers.remove(pubKey)
683684 }
684685 }
685686
0 commit comments