Fix reorg loop when anchor offset = 0

This commit is contained in:
Hanh 2022-10-28 18:28:10 +08:00
parent 8ad5191878
commit b8f1f10661
2 changed files with 3 additions and 2 deletions

View File

@ -783,7 +783,8 @@ abstract class _SyncStatus with Store {
Future<void> reorg() async { Future<void> reorg() async {
final _syncedHeight = await getDbSyncedHeight(); final _syncedHeight = await getDbSyncedHeight();
if (_syncedHeight != null) { if (_syncedHeight != null) {
final rewindHeight = max(_syncedHeight.height - settings.anchorOffset, 0); final offset = max(settings.anchorOffset, 1);
final rewindHeight = max(_syncedHeight.height - offset, 0);
final height = WarpApi.rewindTo(rewindHeight); final height = WarpApi.rewindTo(rewindHeight);
showSnackBar(S.current.blockReorgDetectedRewind(height)); showSnackBar(S.current.blockReorgDetectedRewind(height));
syncStatus.reset(); syncStatus.reset();

@ -1 +1 @@
Subproject commit 152fe56a1e0d47bf86d2ec4b9c953dd294e0787a Subproject commit 92e3e17e66f266b1137181dd26fe3fc19700e3f2