Skip to content

Commit

Permalink
Merge pull request #377 from ardriveapp/PE-1067/Increase-transaction-…
Browse files Browse the repository at this point in the history
…wait-time

refactor: update tx pending threshold to 240m PE-1067
  • Loading branch information
javdhu authored Mar 7, 2022
2 parents 3685095 + 097b3c0 commit d196506
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 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
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<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=57" type="application/javascript"></script>
<script src="main.dart.js?version=58" type="application/javascript"></script>

</body>

Expand Down

0 comments on commit d196506

Please sign in to comment.