From 2c0772aa0144a9c5135f2840d4715604e3917546 Mon Sep 17 00:00:00 2001 From: acrespo Date: Mon, 23 Sep 2024 18:25:47 -0300 Subject: [PATCH] Apollo: Release source code for 52.2 --- android/CHANGELOG.md | 6 +++ .../domain/action/OperationActions.java | 41 +++++++++++++++---- android/apolloui/build.gradle | 4 +- .../io/muun/common/model/OperationStatus.java | 3 ++ 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/android/CHANGELOG.md b/android/CHANGELOG.md index 775975ca..f2a48741 100644 --- a/android/CHANGELOG.md +++ b/android/CHANGELOG.md @@ -6,6 +6,12 @@ follow [https://changelog.md/](https://changelog.md/) guidelines. ## [Unreleased] +## [52.2] - 2024-09-23 + +### FIXED + +- Visual bug that prevent display of some of the oldest payments in payment history + ## [52.1] - 2024-08-02 ### ADDED diff --git a/android/apollo/src/main/java/io/muun/apollo/domain/action/OperationActions.java b/android/apollo/src/main/java/io/muun/apollo/domain/action/OperationActions.java index be29d484..98b55d50 100644 --- a/android/apollo/src/main/java/io/muun/apollo/domain/action/OperationActions.java +++ b/android/apollo/src/main/java/io/muun/apollo/domain/action/OperationActions.java @@ -5,11 +5,13 @@ import io.muun.apollo.domain.action.operation.CreateOperationAction; import io.muun.apollo.domain.action.operation.OperationMetadataMapper; import io.muun.apollo.domain.model.Operation; +import io.muun.apollo.domain.model.OperationWithMetadata; import io.muun.common.rx.RxHelper; import rx.Observable; import timber.log.Timber; +import java.util.List; import javax.inject.Inject; import javax.inject.Singleton; @@ -27,10 +29,12 @@ public class OperationActions { * Constructor. */ @Inject - public OperationActions(CreateOperationAction createOperation, - OperationDao operationDao, - HoustonClient houstonClient, - OperationMetadataMapper operationMapper) { + public OperationActions( + CreateOperationAction createOperation, + OperationDao operationDao, + HoustonClient houstonClient, + OperationMetadataMapper operationMapper + ) { Timber.d("[OperationActions] Execute Dependency Injection"); @@ -48,11 +52,30 @@ public Observable fetchReplaceOperations() { return operationDao.deleteAll().andThen( houstonClient.fetchOperations() - .flatMap(Observable::from) - // using concatMap to avoid parallelization, overflows JobExecutor's queue - // TODO use batching - .map(operationMapper::mapFromMetadata) - .concatMap(createOperation::saveOperation) + .doOnNext(list -> Timber.i("Received op history: size " + list.size())) + .buffer(20) + .flatMap(chunks -> { + + // Hack warning: we can't use flatMap (parallelization breaks + // JobExecutor threadpool capacity) nor concatMap (suddenly stops + // processing events from Observable.from() silently) directly. + // So we introduce some "parallel processing by batches". + // TODO we should really migrate to using batching Sqlite inserts + // instead of inserting one-by-one + + for (List chunk : chunks) { + if (!chunk.isEmpty()) { + Observable.from(chunk) + .doOnNext(op -> Timber.i("processing op:" + op.getId())) + .map(operationMapper::mapFromMetadata) + .flatMap(createOperation::saveOperation, 5) + .toBlocking() + .last(); + } + } + + return Observable.just(null); + }) .lastOrDefault(null) .map(RxHelper::toVoid) ); diff --git a/android/apolloui/build.gradle b/android/apolloui/build.gradle index 502e5b68..5dc350d6 100644 --- a/android/apolloui/build.gradle +++ b/android/apolloui/build.gradle @@ -94,8 +94,8 @@ android { applicationId "io.muun.apollo" minSdk 19 targetSdk 34 - versionCode 1201 - versionName "52.1" + versionCode 1202 + versionName "52.2" // Needed to make sure these classes are available in the main DEX file for API 19 // See: https://spin.atomicobject.com/2018/07/16/support-kitkat-multidex/ diff --git a/common/src/main/java/io/muun/common/model/OperationStatus.java b/common/src/main/java/io/muun/common/model/OperationStatus.java index 66943be3..110d5028 100644 --- a/common/src/main/java/io/muun/common/model/OperationStatus.java +++ b/common/src/main/java/io/muun/common/model/OperationStatus.java @@ -76,6 +76,9 @@ public enum OperationStatus { /** * Operation with its transaction present in a block (0 < confirmations < SETTLEMENT_NUMBER), * but not with enough transactions to be settled. + * TODO: the semantics for this status are no longer accurate (for instance, fulfilled + * incoming swaps are CONFIRMED whenever the preimage is revealed, regardless of the + * confirmation status of any transaction). */ CONFIRMED,