Skip to content
Snippets Groups Projects

#397: Replace singletons with @functools.lru_cache() decorator

Merged #397: Replace singletons with @functools.lru_cache() decorator
Merged Moul requested to merge 397_rm_singleton into main
7 files
+ 21
32
Compare changes
  • Side-by-side
  • Inline
Files
7
  • e3e46a29
    [mod] #397: Get rid of UDValue singleton · e3e46a29
    Moul authored
+ 7
18
@@ -79,7 +79,7 @@ def show_amount_from_pubkey(label, inputs_balance):
totalAmountInput = inputs_balance[0]
balance = inputs_balance[1]
currency_symbol = get_currency_symbol()
ud_value = UDValue().ud_value
ud_value = get_ud_value()
average, monetary_mass = get_average()
member = False
@@ -184,23 +184,12 @@ def get_sources(pubkey):
return listinput, amount
class UDValue:
__instance = None
def __new__(cls):
if UDValue.__instance is None:
UDValue.__instance = object.__new__(cls)
return UDValue.__instance
def __init__(self):
self.ud_value = self.get_ud_value()
def get_ud_value(self):
client = ClientInstance().client
blockswithud = client(blockchain.ud)
NBlastUDblock = blockswithud["result"]["blocks"][-1]
lastUDblock = client(blockchain.block, NBlastUDblock)
return lastUDblock["dividend"] * 10 ** lastUDblock["unitbase"]
def get_ud_value():
client = ClientInstance().client
blockswithud = client(blockchain.ud)
NBlastUDblock = blockswithud["result"]["blocks"][-1]
lastUDblock = client(blockchain.block, NBlastUDblock)
return lastUDblock["dividend"] * 10 ** lastUDblock["unitbase"]
def amount_in_current_base(source):
Loading