@@ -187,8 +187,6 @@ class _SyncRepository implements SyncRepository {
187
187
? 0
188
188
: _calculateSyncLastBlockHeight (drive.lastBlockHeight! ),
189
189
currentBlockHeight: currentBlockHeight,
190
- transactionParseBatchSize:
191
- 200 ~ / (syncProgress.drivesCount - syncProgress.drivesSynced),
192
190
ownerAddress: drive.ownerAddress,
193
191
txFechedCallback: txFechedCallback,
194
192
);
@@ -301,7 +299,6 @@ class _SyncRepository implements SyncRepository {
301
299
ownerAddress: ownerAddress,
302
300
lastBlockHeight: 0 ,
303
301
currentBlockHeight: 0 ,
304
- transactionParseBatchSize: 200 ,
305
302
txFechedCallback: txFechedCallback,
306
303
);
307
304
}
@@ -538,7 +535,6 @@ class _SyncRepository implements SyncRepository {
538
535
SecretKey ? cipherKey,
539
536
required int currentBlockHeight,
540
537
required int lastBlockHeight,
541
- required int transactionParseBatchSize,
542
538
required String ownerAddress,
543
539
Function (String driveId, int txCount)? txFechedCallback,
544
540
}) async * {
@@ -629,9 +625,6 @@ class _SyncRepository implements SyncRepository {
629
625
drive: drive,
630
626
driveKey: driveKey? .key,
631
627
currentBlockHeight: currentBlockHeight,
632
- lastBlockHeight: lastBlockHeight,
633
- batchSize: transactionParseBatchSize,
634
- snapshotDriveHistory: snapshotDriveHistory,
635
628
ownerAddress: ownerAddress,
636
629
);
637
630
} catch (e) {
@@ -727,10 +720,7 @@ class _SyncRepository implements SyncRepository {
727
720
required Stream <DriveEntityHistoryTransactionModel > transactions,
728
721
required Drive drive,
729
722
required SecretKey ? driveKey,
730
- required int lastBlockHeight,
731
723
required int currentBlockHeight,
732
- required int batchSize,
733
- required SnapshotDriveHistory snapshotDriveHistory,
734
724
required String ownerAddress,
735
725
}) {
736
726
final controller = StreamController <double >();
@@ -743,8 +733,6 @@ class _SyncRepository implements SyncRepository {
743
733
? 0
744
734
: numberOfDriveEntitiesParsed / numberOfDriveEntitiesToParse;
745
735
746
- final batch = < DriveEntityHistoryTransactionModel > [];
747
-
748
736
int ? firstBlockHeight;
749
737
late int totalBlockHeightDifference;
750
738
var fetchPhasePercentage = 0.0 ;
@@ -769,7 +757,6 @@ class _SyncRepository implements SyncRepository {
769
757
}
770
758
}
771
759
772
- batch.add (t);
773
760
numberOfDriveEntitiesToParse++ ;
774
761
775
762
if (firstBlockHeight != null ) {
@@ -781,37 +768,15 @@ class _SyncRepository implements SyncRepository {
781
768
controller.add (fetchPhasePercentage * fetchPhaseWeight);
782
769
}
783
770
784
- if (batch.length >= batchSize) {
785
- await _processTransactionBatch (
786
- batch,
787
- drive,
788
- driveKey,
789
- lastBlockHeight,
790
- currentBlockHeight,
791
- batchSize,
792
- ownerAddress,
793
- );
794
- numberOfDriveEntitiesParsed += batch.length;
795
- controller.add (fetchPhaseWeight +
796
- driveEntityParseProgress () * parsePhaseWeight);
797
- batch.clear ();
798
- }
799
- }
800
-
801
- if (batch.isNotEmpty) {
802
- await _processTransactionBatch (
803
- batch,
771
+ await _processTransaction (
772
+ t,
804
773
drive,
805
774
driveKey,
806
- lastBlockHeight,
807
- currentBlockHeight,
808
- batchSize,
809
775
ownerAddress,
810
776
);
811
- numberOfDriveEntitiesParsed += batch.length ;
777
+ numberOfDriveEntitiesParsed++ ;
812
778
controller.add (fetchPhaseWeight +
813
779
driveEntityParseProgress () * parsePhaseWeight);
814
- batch.clear ();
815
780
}
816
781
817
782
if (numberOfDriveEntitiesToParse == 0 ) {
@@ -836,22 +801,18 @@ class _SyncRepository implements SyncRepository {
836
801
return controller.stream;
837
802
}
838
803
839
- Future <void > _processTransactionBatch (
840
- List < DriveEntityHistoryTransactionModel > items ,
804
+ Future <void > _processTransaction (
805
+ DriveEntityHistoryTransactionModel item ,
841
806
Drive drive,
842
807
SecretKey ? driveKey,
843
- int lastBlockHeight,
844
- int currentBlockHeight,
845
- int batchSize,
846
808
String ownerAddress,
847
809
) async {
848
810
final driveEntities = < DriveEntity > [];
849
811
final folderEntities = < FolderEntity > [];
850
812
final fileEntities = < FileEntity > [];
851
- var processed = 0 ;
852
813
853
814
await for (final entity in _arweave.streamEntitiesFromTransactions (
854
- items ,
815
+ [item] ,
855
816
driveKey,
856
817
driveId: drive.id,
857
818
ownerAddress: ownerAddress,
@@ -863,41 +824,20 @@ class _SyncRepository implements SyncRepository {
863
824
} else if (entity is FileEntity ) {
864
825
fileEntities.add (entity);
865
826
}
866
-
867
- processed++ ;
868
- if (processed >= batchSize) {
869
- await _insertEntities (
870
- drive,
871
- driveEntities,
872
- folderEntities,
873
- fileEntities,
874
- );
875
- driveEntities.clear ();
876
- folderEntities.clear ();
877
- fileEntities.clear ();
878
- processed = 0 ;
879
- }
880
827
}
881
828
882
- if (driveEntities.isNotEmpty ||
883
- folderEntities.isNotEmpty ||
884
- fileEntities.isNotEmpty) {
885
- await _insertEntities (
886
- drive,
887
- driveEntities,
888
- folderEntities,
889
- fileEntities,
890
- );
829
+ if (driveEntities.isEmpty &&
830
+ folderEntities.isEmpty &&
831
+ fileEntities.isEmpty) {
832
+ return ;
891
833
}
892
834
893
- if (items.length < batchSize) {
894
- await _driveDao.writeToDrive (DrivesCompanion (
895
- id: Value (drive.id),
896
- lastBlockHeight: Value (currentBlockHeight),
897
- syncCursor: const Value (null ),
898
- isHidden: Value (drive.isHidden),
899
- ));
900
- }
835
+ await _insertEntities (
836
+ drive,
837
+ driveEntities,
838
+ folderEntities,
839
+ fileEntities,
840
+ );
901
841
}
902
842
903
843
Future <void > _insertEntities (
0 commit comments