Skip to content

Commit

Permalink
Merge pull request #391 from ardriveapp/dev
Browse files Browse the repository at this point in the history
Release 1.8.0 PE-1099
  • Loading branch information
javdhu authored Mar 10, 2022
2 parents 08b14d7 + d196506 commit dbd377d
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
16 changes: 14 additions & 2 deletions lib/blocs/sync/sync_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:math';

import 'package:ardrive/blocs/activity/activity_cubit.dart';
import 'package:ardrive/blocs/sync/ghost_folder.dart';
Expand All @@ -21,10 +22,11 @@ import '../blocs.dart';
part 'sync_state.dart';

const kRequiredTxConfirmationCount = 15;
const kRequiredTxConfirmationPendingThreshold = 60;
const kRequiredTxConfirmationPendingThreshold = 60 * 8;

const kSyncTimerDuration = 5;
const kArConnectSyncTimerDuration = 2;
const kBlockHeightLookBack = 240;

/// The [SyncCubit] periodically syncs the user's owned and attached drives and their contents.
/// It also checks the status of unconfirmed transactions made by revisions.
Expand Down Expand Up @@ -161,7 +163,9 @@ class SyncCubit extends Cubit<SyncState> {

final driveSyncProcesses = drives.map((drive) => _syncDrive(
drive.id,
lastBlockHeight: drive.lastBlockHeight!,
lastBlockHeight: calculateSyncLastBlockHeight(
drive.lastBlockHeight!,
),
currentBlockheight: currentBlockHeight,
).onError((error, stackTrace) {
print('Error syncing drive with id ${drive.id}');
Expand All @@ -183,6 +187,14 @@ class SyncCubit extends Cubit<SyncState> {
emit(SyncIdle());
}

int calculateSyncLastBlockHeight(int lastBlockHeight) {
if (_lastSync != null) {
return lastBlockHeight;
} else {
return max(lastBlockHeight - kBlockHeightLookBack, 0);
}
}

Future<void> createGhosts({String? ownerAddress}) async {
//Finalize missing parent list

Expand Down
5 changes: 4 additions & 1 deletion lib/blocs/upload/bundle_upload_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class BundleUploadHandle implements UploadHandle {

/// Uploads the bundle, emitting an event whenever the progress is updated.
Stream<Null> upload(ArweaveService arweave) async* {
await for (final upload in arweave.client.transactions.upload(bundleTx)) {
await for (final upload in arweave.client.transactions.upload(
bundleTx,
maxConcurrentUploadCount: 32,
)) {
uploadProgress = upload.progress;
yield null;
}
Expand Down
5 changes: 4 additions & 1 deletion lib/blocs/upload/file_upload_handle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ class FileUploadHandle implements UploadHandle {
Stream<Null> upload(ArweaveService arweave) async* {
await arweave.postTx(entityTx);

await for (final upload in arweave.client.transactions.upload(dataTx)) {
await for (final upload in arweave.client.transactions.upload(
dataTx,
maxConcurrentUploadCount: 32,
)) {
uploadProgress = upload.progress;
yield null;
}
Expand Down
9 changes: 7 additions & 2 deletions lib/blocs/upload/upload_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:file_selector/file_selector.dart';
import 'package:meta/meta.dart';
import 'package:mime/mime.dart';
import 'package:pedantic/pedantic.dart';
import 'package:rxdart/rxdart.dart';
import 'package:uuid/uuid.dart';

import '../blocs.dart';
Expand Down Expand Up @@ -181,7 +182,9 @@ class UploadCubit extends Cubit<UploadState> {
pstService: _pst,
wallet: profile.wallet,
);
await for (final _ in bundleHandle.upload(_arweave)) {
await for (final _ in bundleHandle
.upload(_arweave)
.debounceTime(Duration(milliseconds: 500))) {
emit(UploadInProgress(uploadPlan: uploadPlan));
}
bundleHandle.dispose();
Expand All @@ -196,7 +199,9 @@ class UploadCubit extends Cubit<UploadState> {
await uploadHandle.writeFileEntityToDatabase(
driveDao: _driveDao,
);
await for (final _ in uploadHandle.upload(_arweave)) {
await for (final _ in uploadHandle
.upload(_arweave)
.debounceTime(Duration(milliseconds: 500))) {
emit(UploadInProgress(uploadPlan: uploadPlan));
}
uploadHandle.dispose();
Expand Down
13 changes: 10 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v2.0.1"
resolved-ref: "594732e73df2614e95d290e4478884950bf40159"
ref: "v3.0.0"
resolved-ref: "77e70189f15b03138097839ac363076cb68ed4d0"
url: "https://github.com/ardriveapp/arweave-dart"
source: git
version: "2.0.1"
version: "3.0.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -775,6 +775,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.1"
retry:
dependency: transitive
description:
name: retry
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
rxdart:
dependency: "direct main"
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ publish_to: 'none'
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.7.3
version: 1.8.0

environment:
sdk: '>=2.13.0 <3.0.0'
Expand All @@ -27,7 +27,7 @@ dependencies:
arweave:
git:
url: https://github.com/ardriveapp/arweave-dart
ref: v2.0.1
ref: v3.0.0
cryptography: ^2.0.1
flutter_bloc: ^8.0.1
flutter_portal: ^0.4.0
Expand Down
4 changes: 2 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
<script defer src="avsc.min.js"></script>
<script defer src="js/tagparser.js"></script>
<script defer src="sql-wasm.js"></script>
<script src="main.dart.js?version=56" type="application/javascript"></script>
<script src="main.dart.js?version=58" type="application/javascript"></script>

</body>

</html>
</html>

0 comments on commit dbd377d

Please sign in to comment.