mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
bandaid hack
This commit is contained in:
parent
ea89441914
commit
f4b01ee642
2 changed files with 20 additions and 15 deletions
|
@ -208,7 +208,7 @@ class ElectrumXClient {
|
||||||
await getElectrumAdapter()?.close();
|
await getElectrumAdapter()?.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _checkElectrumAdapter() async {
|
Future<void> checkElectrumAdapter() async {
|
||||||
({InternetAddress host, int port})? proxyInfo;
|
({InternetAddress host, int port})? proxyInfo;
|
||||||
|
|
||||||
// If we're supposed to use Tor...
|
// If we're supposed to use Tor...
|
||||||
|
@ -311,9 +311,9 @@ class ElectrumXClient {
|
||||||
|
|
||||||
if (_requireMutex) {
|
if (_requireMutex) {
|
||||||
await _torConnectingLock
|
await _torConnectingLock
|
||||||
.protect(() async => await _checkElectrumAdapter());
|
.protect(() async => await checkElectrumAdapter());
|
||||||
} else {
|
} else {
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -397,9 +397,9 @@ class ElectrumXClient {
|
||||||
|
|
||||||
if (_requireMutex) {
|
if (_requireMutex) {
|
||||||
await _torConnectingLock
|
await _torConnectingLock
|
||||||
.protect(() async => await _checkElectrumAdapter());
|
.protect(() async => await checkElectrumAdapter());
|
||||||
} else {
|
} else {
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -780,7 +780,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch blockchain.transaction.get...",
|
"attempting to fetch blockchain.transaction.get...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final dynamic response = await getElectrumAdapter()!.getTransaction(txHash);
|
final dynamic response = await getElectrumAdapter()!.getTransaction(txHash);
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"Fetching blockchain.transaction.get finished",
|
"Fetching blockchain.transaction.get finished",
|
||||||
|
@ -817,7 +817,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch lelantus.getanonymityset...",
|
"attempting to fetch lelantus.getanonymityset...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final Map<String, dynamic> response =
|
final Map<String, dynamic> response =
|
||||||
await (getElectrumAdapter() as FiroElectrumClient)
|
await (getElectrumAdapter() as FiroElectrumClient)
|
||||||
.getLelantusAnonymitySet(groupId: groupId, blockHash: blockhash);
|
.getLelantusAnonymitySet(groupId: groupId, blockHash: blockhash);
|
||||||
|
@ -840,7 +840,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch lelantus.getmintmetadata...",
|
"attempting to fetch lelantus.getmintmetadata...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final dynamic response = await (getElectrumAdapter() as FiroElectrumClient)
|
final dynamic response = await (getElectrumAdapter() as FiroElectrumClient)
|
||||||
.getLelantusMintData(mints: mints);
|
.getLelantusMintData(mints: mints);
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
|
@ -860,7 +860,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch lelantus.getusedcoinserials...",
|
"attempting to fetch lelantus.getusedcoinserials...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
|
|
||||||
int retryCount = 3;
|
int retryCount = 3;
|
||||||
dynamic response;
|
dynamic response;
|
||||||
|
@ -888,7 +888,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch lelantus.getlatestcoinid...",
|
"attempting to fetch lelantus.getlatestcoinid...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final int response =
|
final int response =
|
||||||
await (getElectrumAdapter() as FiroElectrumClient).getLatestCoinId();
|
await (getElectrumAdapter() as FiroElectrumClient).getLatestCoinId();
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
|
@ -920,7 +920,7 @@ class ElectrumXClient {
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final start = DateTime.now();
|
final start = DateTime.now();
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final Map<String, dynamic> response =
|
final Map<String, dynamic> response =
|
||||||
await (getElectrumAdapter() as FiroElectrumClient)
|
await (getElectrumAdapter() as FiroElectrumClient)
|
||||||
.getSparkAnonymitySet(
|
.getSparkAnonymitySet(
|
||||||
|
@ -995,7 +995,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch spark.getsparkmintmetadata...",
|
"attempting to fetch spark.getsparkmintmetadata...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final List<dynamic> response =
|
final List<dynamic> response =
|
||||||
await (getElectrumAdapter() as FiroElectrumClient)
|
await (getElectrumAdapter() as FiroElectrumClient)
|
||||||
.getSparkMintMetaData(sparkCoinHashes: sparkCoinHashes);
|
.getSparkMintMetaData(sparkCoinHashes: sparkCoinHashes);
|
||||||
|
@ -1021,7 +1021,7 @@ class ElectrumXClient {
|
||||||
"attempting to fetch spark.getsparklatestcoinid...",
|
"attempting to fetch spark.getsparklatestcoinid...",
|
||||||
level: LogLevel.Info,
|
level: LogLevel.Info,
|
||||||
);
|
);
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
final int response = await (getElectrumAdapter() as FiroElectrumClient)
|
final int response = await (getElectrumAdapter() as FiroElectrumClient)
|
||||||
.getSparkLatestCoinId();
|
.getSparkLatestCoinId();
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
|
@ -1150,7 +1150,7 @@ class ElectrumXClient {
|
||||||
/// "rate": 1000,
|
/// "rate": 1000,
|
||||||
/// }
|
/// }
|
||||||
Future<Map<String, dynamic>> getFeeRate({String? requestID}) async {
|
Future<Map<String, dynamic>> getFeeRate({String? requestID}) async {
|
||||||
await _checkElectrumAdapter();
|
await checkElectrumAdapter();
|
||||||
return await getElectrumAdapter()!.getFeeRate();
|
return await getElectrumAdapter()!.getFeeRate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -810,12 +810,17 @@ mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> fetchChainHeight() async {
|
Future<int> fetchChainHeight({int retries = 1}) async {
|
||||||
try {
|
try {
|
||||||
return await ClientManager.sharedInstance.getChainHeightFor(
|
return await ClientManager.sharedInstance.getChainHeightFor(
|
||||||
cryptoCurrency,
|
cryptoCurrency,
|
||||||
);
|
);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
|
if (retries > 0) {
|
||||||
|
retries--;
|
||||||
|
await electrumXClient.checkElectrumAdapter();
|
||||||
|
return await fetchChainHeight(retries: retries);
|
||||||
|
}
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"Exception rethrown in fetchChainHeight\nError: $e\nStack trace: $s",
|
"Exception rethrown in fetchChainHeight\nError: $e\nStack trace: $s",
|
||||||
level: LogLevel.Error,
|
level: LogLevel.Error,
|
||||||
|
|
Loading…
Reference in a new issue