no need for class wide htt client property, and close the client before assigning a new one

This commit is contained in:
julian 2024-05-03 15:42:21 -06:00 committed by sneurlax
parent 49dbf5b77f
commit bcb39c3906

View file

@ -46,7 +46,6 @@ class StellarWallet extends Bip39Wallet<Stellar> {
// ============== Private ==================================================== // ============== Private ====================================================
stellar.StellarSDK? _stellarSdk; stellar.StellarSDK? _stellarSdk;
HttpClient? _httpClient;
Future<int> _getBaseFee() async { Future<int> _getBaseFee() async {
final fees = await stellarSdk.feeStats.execute(); final fees = await stellarSdk.feeStats.execute();
@ -55,6 +54,7 @@ class StellarWallet extends Bip39Wallet<Stellar> {
void _updateSdk() { void _updateSdk() {
final currentNode = getCurrentNode(); final currentNode = getCurrentNode();
HttpClient? _httpClient;
// TODO [prio=med]: refactor out and call before requests in case Tor is enabled/disabled, listen to prefs change, or similar. // TODO [prio=med]: refactor out and call before requests in case Tor is enabled/disabled, listen to prefs change, or similar.
if (prefs.useTor) { if (prefs.useTor) {
@ -63,13 +63,21 @@ class StellarWallet extends Bip39Wallet<Stellar> {
_httpClient = HttpClient(); _httpClient = HttpClient();
SocksTCPClient.assignToHttpClient( SocksTCPClient.assignToHttpClient(
_httpClient!, [ProxySettings(proxyInfo.host, proxyInfo.port)]); _httpClient,
} else { [
_httpClient = null; ProxySettings(
proxyInfo.host,
proxyInfo.port,
),
],
);
} }
_stellarSdk = stellar.StellarSDK("${currentNode.host}:${currentNode.port}", _stellarSdk?.httpClient.close();
httpClient: _httpClient); _stellarSdk = stellar.StellarSDK(
"${currentNode.host}:${currentNode.port}",
httpClient: _httpClient,
);
} }
Future<bool> _accountExists(String accountId) async { Future<bool> _accountExists(String accountId) async {