mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-18 02:07:43 +00:00
add some retries to some electrumx calls
This commit is contained in:
parent
430882cb6a
commit
03526d0f5d
1 changed files with 36 additions and 18 deletions
|
@ -581,6 +581,10 @@ class ElectrumXClient {
|
|||
String? requestID,
|
||||
}) async {
|
||||
try {
|
||||
int retryCount = 3;
|
||||
dynamic result;
|
||||
|
||||
while (retryCount > 0 && result is! List) {
|
||||
final response = await request(
|
||||
requestID: requestID,
|
||||
command: 'blockchain.scripthash.get_history',
|
||||
|
@ -589,7 +593,12 @@ class ElectrumXClient {
|
|||
scripthash,
|
||||
],
|
||||
);
|
||||
return List<Map<String, dynamic>>.from(response["result"] as List);
|
||||
|
||||
result = response["result"];
|
||||
retryCount--;
|
||||
}
|
||||
|
||||
return List<Map<String, dynamic>>.from(result as List);
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
|
@ -818,6 +827,10 @@ class ElectrumXClient {
|
|||
required int startNumber,
|
||||
}) async {
|
||||
try {
|
||||
int retryCount = 3;
|
||||
dynamic result;
|
||||
|
||||
while (retryCount > 0 && result is! List) {
|
||||
final response = await request(
|
||||
requestID: requestID,
|
||||
command: 'lelantus.getusedcoinserials',
|
||||
|
@ -826,7 +839,12 @@ class ElectrumXClient {
|
|||
],
|
||||
requestTimeout: const Duration(minutes: 2),
|
||||
);
|
||||
return Map<String, dynamic>.from(response["result"] as Map);
|
||||
|
||||
result = response["result"];
|
||||
retryCount--;
|
||||
}
|
||||
|
||||
return Map<String, dynamic>.from(result as Map);
|
||||
} catch (e) {
|
||||
Logging.instance.log(e, level: LogLevel.Error);
|
||||
rethrow;
|
||||
|
|
Loading…
Reference in a new issue