mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-10 20:54:33 +00:00
disable broken paynym connection status caching
This commit is contained in:
parent
d8096fdf93
commit
4bd55f6ee3
1 changed files with 35 additions and 30 deletions
|
@ -696,30 +696,40 @@ mixin PaynymWalletInterface {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool?> _checkHasConnectedCache(String paymentCodeString) async {
|
||||
final value = await _secureStorage.read(
|
||||
key: "$_connectedKeyPrefix$paymentCodeString");
|
||||
if (value == null) {
|
||||
return null;
|
||||
} else {
|
||||
final int rawBool = int.parse(value);
|
||||
return rawBool > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _setConnectedCache(
|
||||
String paymentCodeString, bool hasConnected) async {
|
||||
await _secureStorage.write(
|
||||
key: "$_connectedKeyPrefix$paymentCodeString",
|
||||
value: hasConnected ? "1" : "0");
|
||||
}
|
||||
// Future<bool?> _checkHasConnectedCache(String paymentCodeString) async {
|
||||
// final value = await _secureStorage.read(
|
||||
// key: "$_connectedKeyPrefix$paymentCodeString");
|
||||
// if (value == null) {
|
||||
// return null;
|
||||
// } else {
|
||||
// final int rawBool = int.parse(value);
|
||||
// return rawBool > 0;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Future<void> _setConnectedCache(
|
||||
// String paymentCodeString, bool hasConnected) async {
|
||||
// await _secureStorage.write(
|
||||
// key: "$_connectedKeyPrefix$paymentCodeString",
|
||||
// value: hasConnected ? "1" : "0");
|
||||
// }
|
||||
|
||||
// TODO optimize
|
||||
Future<bool> hasConnected(String paymentCodeString) async {
|
||||
final didConnect = await _checkHasConnectedCache(paymentCodeString);
|
||||
if (didConnect != null) {
|
||||
return didConnect;
|
||||
}
|
||||
// final didConnect = await _checkHasConnectedCache(paymentCodeString);
|
||||
// if (didConnect == true) {
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// final keys = await lookupKey(paymentCodeString);
|
||||
//
|
||||
// final tx = await _db
|
||||
// .getTransactions(_walletId)
|
||||
// .filter()
|
||||
// .subTypeEqualTo(TransactionSubType.bip47Notification).and()
|
||||
// .address((q) =>
|
||||
// q.anyOf<String, Transaction>(keys, (q, e) => q.otherDataEqualTo(e)))
|
||||
// .findAll();
|
||||
|
||||
final myNotificationAddress =
|
||||
await getMyNotificationAddress(DerivePathTypeExt.primaryFor(_coin));
|
||||
|
@ -733,19 +743,14 @@ mixin PaynymWalletInterface {
|
|||
for (final tx in txns) {
|
||||
if (tx.type == TransactionType.incoming &&
|
||||
tx.address.value?.value == myNotificationAddress.value) {
|
||||
PaymentCode? unBlindedPaymentCode;
|
||||
unBlindedPaymentCode = await unBlindedPaymentCodeFromTransaction(
|
||||
transaction: tx,
|
||||
myNotificationAddress: myNotificationAddress,
|
||||
);
|
||||
unBlindedPaymentCode = await unBlindedPaymentCodeFromTransaction(
|
||||
final unBlindedPaymentCode = await unBlindedPaymentCodeFromTransaction(
|
||||
transaction: tx,
|
||||
myNotificationAddress: myNotificationAddress,
|
||||
);
|
||||
|
||||
if (unBlindedPaymentCode != null &&
|
||||
paymentCodeString == unBlindedPaymentCode.toString()) {
|
||||
await _setConnectedCache(paymentCodeString, true);
|
||||
// await _setConnectedCache(paymentCodeString, true);
|
||||
return true;
|
||||
}
|
||||
} else if (tx.type == TransactionType.outgoing) {
|
||||
|
@ -753,7 +758,7 @@ mixin PaynymWalletInterface {
|
|||
final code =
|
||||
await paymentCodeStringByKey(tx.address.value!.otherData!);
|
||||
if (code == paymentCodeString) {
|
||||
await _setConnectedCache(paymentCodeString, true);
|
||||
// await _setConnectedCache(paymentCodeString, true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -761,7 +766,7 @@ mixin PaynymWalletInterface {
|
|||
}
|
||||
|
||||
// otherwise return no
|
||||
await _setConnectedCache(paymentCodeString, false);
|
||||
// await _setConnectedCache(paymentCodeString, false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue