Skip to content

Commit 0c10cb9

Browse files
authored
Merge pull request #283 from synonymdev/fix/transfer-watch-pooling
Fix/transfer watch pooling
2 parents bc9f14c + fbf58cb commit 0c10cb9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/src/main/java/to/bitkit/repositories/BlocktankRepo.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package to.bitkit.repositories
22

3+
import com.synonym.bitkitcore.BtOrderState2
34
import com.synonym.bitkitcore.CreateCjitOptions
45
import com.synonym.bitkitcore.CreateOrderOptions
56
import com.synonym.bitkitcore.IBtEstimateFeeResponse2
@@ -142,7 +143,13 @@ class BlocktankRepo @Inject constructor(
142143
)
143144
}
144145

145-
Logger.debug("Orders refreshed: ${orders.size} orders, ${cjitEntries.size} cjit entries", context = TAG)
146+
Logger.debug(
147+
"Orders refreshed: ${orders.size} orders, " +
148+
"${cjitEntries.size} cjit entries, " +
149+
"${_blocktankState.value.paidOrders.size} paid orders",
150+
context = TAG
151+
)
152+
openChannelWithPaidOrders()
146153
} catch (e: Throwable) {
147154
Logger.error("Failed to refresh orders", e, context = TAG)
148155
} finally {
@@ -284,6 +291,12 @@ class BlocktankRepo @Inject constructor(
284291
}
285292
}
286293

294+
private suspend fun openChannelWithPaidOrders() = withContext(bgDispatcher) {
295+
_blocktankState.value.paidOrders.filter { it.state2 == BtOrderState2.PAID }.forEach { order ->
296+
openChannel(order.id)
297+
}
298+
}
299+
287300
private suspend fun defaultCreateOrderOptions(clientBalanceSat: ULong): CreateOrderOptions {
288301
val nodeId = lightningService.nodeId ?: throw ServiceError.NodeNotStarted
289302
val timestamp = nowTimestamp().toString()

0 commit comments

Comments
 (0)