@@ -205,6 +205,7 @@ class LightningRepo @Inject constructor(
205205
206206 // Initial state sync
207207 syncState()
208+ updateGeoBlockState()
208209
209210 // Perform post-startup tasks
210211 connectToTrustedPeers().onFailure { e ->
@@ -238,6 +239,15 @@ class LightningRepo @Inject constructor(
238239 }
239240 }
240241
242+ /* *Updates the shouldBlockLightning state and returns the current value*/
243+ private suspend fun updateGeoBlockState (): Boolean {
244+ val shouldBlock = coreService.shouldBlockLightning()
245+ _lightningState .update {
246+ it.copy(shouldBlockLightning = shouldBlock)
247+ }
248+ return shouldBlock
249+ }
250+
241251 fun setInitNodeLifecycleState () {
242252 _lightningState .update { it.copy(nodeLifecycleState = NodeLifecycleState .Initializing ) }
243253 }
@@ -414,7 +424,7 @@ class LightningRepo @Inject constructor(
414424 description : String ,
415425 expirySeconds : UInt = 86_400u,
416426 ): Result <String > = executeWhenNodeRunning(" Create invoice" ) {
417- if (coreService.shouldBlockLightning ()) {
427+ if (updateGeoBlockState ()) {
418428 return @executeWhenNodeRunning Result .failure(ServiceError .GeoBlocked )
419429 }
420430
@@ -661,7 +671,6 @@ class LightningRepo @Inject constructor(
661671 nodeStatus = getStatus(),
662672 peers = getPeers().orEmpty(),
663673 channels = getChannels().orEmpty(),
664- shouldBlockLightning = coreService.shouldBlockLightning()
665674 )
666675 }
667676 }
0 commit comments