simplify exchange_rate hooks

This commit is contained in:
ThomasV 2015-10-17 06:26:37 +02:00
parent 46249f74d3
commit 302ce7c15b
3 changed files with 8 additions and 15 deletions

View File

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

View File

@ -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")

View File

@ -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():