add some retries to some electrumx calls

This commit is contained in:
julian 2023-11-24 13:25:32 -06:00
parent 430882cb6a
commit 03526d0f5d

View file

@ -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;