mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-16 17:27:37 +00:00
Fixes.
This commit is contained in:
parent
a7a0f59b9c
commit
fdb0f49f88
5 changed files with 42 additions and 29 deletions
|
@ -212,13 +212,18 @@ String getPublicSpendKey() =>
|
|||
convertUTF8ToString(pointer: getPublicSpendKeyNative());
|
||||
|
||||
class SyncListener {
|
||||
SyncListener({this.onNewBlock});
|
||||
SyncListener({this.onNewBlock}) {
|
||||
_cachedBlockchainHeight = 0;
|
||||
_lastKnownBlockHeight = 0;
|
||||
_initialSyncHeight = 0;
|
||||
}
|
||||
|
||||
void Function(int, int, double) onNewBlock;
|
||||
|
||||
Timer _updateSyncInfoTimer;
|
||||
int _cachedBlockchainHeight = 0;
|
||||
int _lastKnownBlockHeight = 0;
|
||||
int _cachedBlockchainHeight;
|
||||
int _lastKnownBlockHeight;
|
||||
int _initialSyncHeight;
|
||||
|
||||
Future<int> getNodeHeightOrUpdate(int baseHeight) async {
|
||||
if (_cachedBlockchainHeight < baseHeight || _cachedBlockchainHeight == 0) {
|
||||
|
@ -231,6 +236,7 @@ class SyncListener {
|
|||
void start() {
|
||||
_cachedBlockchainHeight = 0;
|
||||
_lastKnownBlockHeight = 0;
|
||||
_initialSyncHeight = 0;
|
||||
_updateSyncInfoTimer ??=
|
||||
Timer.periodic(Duration(milliseconds: 1200), (_) async {
|
||||
var syncHeight = getSyncingHeight();
|
||||
|
@ -239,6 +245,10 @@ class SyncListener {
|
|||
syncHeight = getCurrentHeight();
|
||||
}
|
||||
|
||||
if (_initialSyncHeight <= 0) {
|
||||
_initialSyncHeight = syncHeight;
|
||||
}
|
||||
|
||||
final bchHeight = await getNodeHeightOrUpdate(syncHeight);
|
||||
|
||||
if (_lastKnownBlockHeight == syncHeight || syncHeight == null) {
|
||||
|
@ -246,10 +256,15 @@ class SyncListener {
|
|||
}
|
||||
|
||||
_lastKnownBlockHeight = syncHeight;
|
||||
final track = bchHeight - syncHeight;
|
||||
final track = bchHeight - _initialSyncHeight;
|
||||
final diff = track - (bchHeight - syncHeight);
|
||||
final ptc = diff <= 0 ? 0.0 : diff / track;
|
||||
final left = bchHeight - syncHeight;
|
||||
|
||||
if (syncHeight < 0 || left < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 1. Actual new height; 2. Blocks left to finish; 3. Progress in percents;
|
||||
onNewBlock?.call(syncHeight, left, ptc);
|
||||
});
|
||||
|
|
|
@ -354,7 +354,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 12;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -494,7 +494,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 12;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
@ -528,7 +528,7 @@
|
|||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CURRENT_PROJECT_VERSION = 12;
|
||||
CURRENT_PROJECT_VERSION = 17;
|
||||
DEVELOPMENT_TEAM = 32J6BB6VUS;
|
||||
ENABLE_BITCODE = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
|
|
|
@ -39,10 +39,12 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
subaddressList.update(accountIndex: account.id);
|
||||
subaddress = subaddressList.subaddresses.first;
|
||||
address = subaddress.address;
|
||||
_lastAutosaveTimestamp = 0;
|
||||
});
|
||||
_cachedRefreshHeight = 0;
|
||||
}
|
||||
|
||||
static const int _autoAfterSyncSaceInterval = 60000;
|
||||
|
||||
@override
|
||||
final MoneroTransactionHistory transactionHistory;
|
||||
|
||||
|
@ -81,7 +83,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
String _filename;
|
||||
SyncListener _listener;
|
||||
ReactionDisposer _onAccountChangeReaction;
|
||||
int _cachedRefreshHeight;
|
||||
int _lastAutosaveTimestamp;
|
||||
|
||||
Future<void> init() async {
|
||||
await accountList.update();
|
||||
|
@ -95,7 +97,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
address = subaddress.address;
|
||||
_setListeners();
|
||||
await transactionHistory.update();
|
||||
print('walletInfo.isRecovery ${walletInfo.isRecovery}');
|
||||
|
||||
if (walletInfo.isRecovery) {
|
||||
monero_wallet.setRecoveringFromSeed(isRecovery: walletInfo.isRecovery);
|
||||
|
||||
|
@ -156,6 +158,8 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
try {
|
||||
syncStatus = StartingSyncStatus();
|
||||
monero_wallet.startRefresh();
|
||||
_setListeners();
|
||||
_listener?.start();
|
||||
} catch (e) {
|
||||
syncStatus = FailedSyncStatus();
|
||||
print(e);
|
||||
|
@ -234,7 +238,6 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
void _setListeners() {
|
||||
_listener?.stop();
|
||||
_listener = monero_wallet.setListeners(_onNewBlock);
|
||||
_listener.start();
|
||||
}
|
||||
|
||||
void _setInitialHeight() {
|
||||
|
@ -292,18 +295,15 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
int _getUnlockedBalance() =>
|
||||
monero_wallet.getUnlockedBalance(accountIndex: account.id);
|
||||
|
||||
int _lastAutosaveTimestamp = 0;
|
||||
final int _autosaveInterval = 60000;
|
||||
|
||||
Future<void> _autoSave() async {
|
||||
Future<void> _afterSyncSave() async {
|
||||
final nowTimestamp = DateTime.now().millisecondsSinceEpoch;
|
||||
final sum = _lastAutosaveTimestamp + _autosaveInterval;
|
||||
final sum = _lastAutosaveTimestamp + _autoAfterSyncSaceInterval;
|
||||
|
||||
if (_lastAutosaveTimestamp != 0 && sum < nowTimestamp) {
|
||||
return;
|
||||
}
|
||||
|
||||
_lastAutosaveTimestamp = nowTimestamp + _autosaveInterval;
|
||||
_lastAutosaveTimestamp = nowTimestamp + _autoAfterSyncSaceInterval;
|
||||
await save();
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance> with Store {
|
|||
|
||||
if (blocksLeft < moneroBlockSize) {
|
||||
syncStatus = SyncedSyncStatus();
|
||||
await _autoSave();
|
||||
await _afterSyncSave();
|
||||
} else {
|
||||
syncStatus = SyncingSyncStatus(blocksLeft, ptc);
|
||||
}
|
||||
|
|
|
@ -73,12 +73,14 @@ class ValidableAnnotatedEditableText extends EditableText {
|
|||
final TextStyle invalidStyle;
|
||||
|
||||
@override
|
||||
ValidableAnnotatedEditableTextState createState() => ValidableAnnotatedEditableTextState();
|
||||
ValidableAnnotatedEditableTextState createState() =>
|
||||
ValidableAnnotatedEditableTextState();
|
||||
}
|
||||
|
||||
class ValidableAnnotatedEditableTextState extends EditableTextState {
|
||||
@override
|
||||
ValidableAnnotatedEditableText get widget => super.widget as ValidableAnnotatedEditableText;
|
||||
ValidableAnnotatedEditableText get widget =>
|
||||
super.widget as ValidableAnnotatedEditableText;
|
||||
|
||||
List<Annotation> getRanges() {
|
||||
final result = List<Annotation>();
|
||||
|
@ -154,17 +156,13 @@ class ValidableAnnotatedEditableTextState extends EditableTextState {
|
|||
final text = textEditingValue.text;
|
||||
final ranges = getRanges().toSet();
|
||||
|
||||
print('text $text');
|
||||
|
||||
if (ranges.isNotEmpty) {
|
||||
return TextSpan(
|
||||
style: widget.style,
|
||||
children: ranges.map((item) {
|
||||
final _text = item.range.textInside(text);
|
||||
print(
|
||||
'_text $_text; range ${item.range.start} : ${item.range.end}');
|
||||
return TextSpan(style: item.style, text: _text);
|
||||
}).toList());
|
||||
children: ranges
|
||||
.map((item) => TextSpan(
|
||||
style: item.style, text: item.range.textInside(text)))
|
||||
.toList());
|
||||
}
|
||||
|
||||
return TextSpan(style: widget.style, text: text);
|
||||
|
|
|
@ -589,7 +589,7 @@ packages:
|
|||
name: node_interop
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
version: "1.2.0"
|
||||
node_io:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
Loading…
Reference in a new issue