add height change notify

This commit is contained in:
julian 2023-01-30 11:06:28 -06:00
parent 6e54ddec86
commit a41f80ac55
8 changed files with 64 additions and 0 deletions

View file

@ -251,6 +251,14 @@ class BitcoinWallet extends CoinServiceAPI
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -217,6 +217,14 @@ class BitcoinCashWallet extends CoinServiceAPI with WalletCache, WalletDB {
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -226,6 +226,14 @@ class DogecoinWallet extends CoinServiceAPI
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -1416,6 +1416,14 @@ class EpicCashWallet extends CoinServiceAPI
});
await updateCachedChainHeight(latestHeight!);
if (latestHeight! > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return latestHeight!;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -4897,6 +4897,14 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -241,6 +241,14 @@ class LitecoinWallet extends CoinServiceAPI
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -236,6 +236,14 @@ class NamecoinWallet extends CoinServiceAPI
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",

View file

@ -231,6 +231,14 @@ class ParticlWallet extends CoinServiceAPI with WalletCache, WalletDB {
final result = await _electrumXClient.getBlockHeadTip();
final height = result["height"] as int;
await updateCachedChainHeight(height);
if (height > storedChainHeight) {
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"Updated current chain height in $walletId $walletName!",
walletId,
),
);
}
return height;
} catch (e, s) {
Logging.instance.log("Exception caught in chainHeight: $e\n$s",