electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 302ce7c15b518886978e30060d57d7865fe3304e
parent 46249f74d3712b84265eddd606c5cdbdc9f96445
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 17 Oct 2015 06:26:37 +0200

simplify exchange_rate hooks

Diffstat:
MRELEASE-NOTES | 6++----
Mgui/qt/main_window.py | 8++++----
Mplugins/exchange_rate.py | 9++-------
3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/RELEASE-NOTES b/RELEASE-NOTES @@ -7,13 +7,11 @@ * The network layer uses select(), so all server communication is handled by a single thread. Moreover, the synchronizer, verifier, and exchange rate plugin now run as separate jobs within the - networking thread instead of as their own threads. The elimination - of so many threads should lead to reduced lock contention and CPU - usage. + networking thread instead of as their own threads. * Plugins are revamped, particularly the exchange rate plugin. # Release 2.4.4 - * fix bug with trustedcoin plugin + * Fix bug with TrustedCoin plugin # Release 2.4.3 * Support for KeepKey hardware wallet diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -492,7 +492,7 @@ class ElectrumWindow(QMainWindow, PrintError): text = self.format_amount(amount) + ' '+ self.base_unit() x = run_hook('format_amount_and_units', amount) if x: - text += ''.join(x) + text += x return text def get_decimal_point(self): @@ -536,9 +536,9 @@ class ElectrumWindow(QMainWindow, PrintError): if x: text += " [%s unmatured]"%(self.format_amount(x, True).strip()) # append fiat balance and price from exchange rate plugin - r = {'text': ''} - run_hook('get_fiat_status_text', c + u + x, r) - text += r['text'] + rate = run_hook('get_fiat_status_text', c + u + x) + if rate: + text += "1 BTC~%s" % rate icon = QIcon(":icons/status_connected.png") else: text = _("Not connected") diff --git a/plugins/exchange_rate.py b/plugins/exchange_rate.py @@ -423,14 +423,9 @@ class Plugin(BasePlugin, ThreadJob): return '' if rate is None else " (%s %s)" % (self.value_str(btc_balance, rate), self.ccy) @hook - def get_fiat_status_text(self, btc_balance, result): - # return status as: (1.23 USD) 1 BTC~123.45 USD + def get_fiat_status_text(self, btc_balance): rate = self.exchange_rate() - if rate is None: - text = _(" (No FX rate available)") - else: - text = "1 BTC~%s %s" % (self.value_str(COIN, rate), self.ccy) - result['text'] = text + return _(" (No FX rate available)") if rate is None else "%s %s" % (self.value_str(COIN, rate), self.ccy) def get_historical_rates(self): if self.show_history():