Skip to content

Commit

Permalink
fix: always run CoinJoinService and simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Nov 6, 2023
1 parent b7291d1 commit 57e83ad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public class BlockchainServiceImpl extends LifecycleService implements Blockchai
@Inject PackageInfoProvider packageInfoProvider;
@Inject ConnectivityManager connectivityManager;
@Inject BlockchainStateDataProvider blockchainStateDataProvider;
@Inject CoinJoinService coinJoinService; // not used in this class, but we need to create it
private BlockStore blockStore;
private BlockStore headerStore;
private File blockChainFile;
Expand Down
11 changes: 2 additions & 9 deletions wallet/src/de/schildbach/wallet/service/CoinJoinService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class CoinJoinMixingService @Inject constructor(
override val mixingProgress: Flow<Double>
get() = _progressFlow
private val _progressFlow = MutableStateFlow(0.00)
private var clientOptionsConfigured = false

init {
blockchainStateProvider.observeNetworkStatus()
Expand All @@ -168,10 +167,7 @@ class CoinJoinMixingService @Inject constructor(
.launchIn(coroutineScope)

walletDataProvider.observeBalance()
.onEach { balance ->
log.info("coinjoin: total balance: $balance (before distinct)")
}
//.distinctUntilChanged()
.distinctUntilChanged()
.onEach { balance ->
// switch to our context
coroutineScope.launch {
Expand Down Expand Up @@ -337,10 +333,7 @@ class CoinJoinMixingService @Inject constructor(
private val requestDecryptedKey = RequestDecryptedKey { decryptKey(it) }

private fun configureMixing() {
if (!clientOptionsConfigured) {
configureMixing(walletDataProvider.getWalletBalance())
clientOptionsConfigured = true;
}
configureMixing(walletDataProvider.getWalletBalance())
}
/** set CoinJoinClientOptions based on CoinJoinMode */
private fun configureMixing(amount: Coin) {
Expand Down

0 comments on commit 57e83ad

Please sign in to comment.