Browse Source
config: abstract away mempool depth format str "%.1f MB from tip"
related: 4dd94172a6
(as that commit introduced depth targets that need more precision to display)
patch-4
SomberNight
3 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
4 changed files with
14 additions and
5 deletions
-
electrum/gui/kivy/uix/dialogs/tx_dialog.py
-
electrum/gui/qt/transaction_dialog.py
-
electrum/simple_config.py
-
electrum/wallet.py
|
|
@ -125,6 +125,7 @@ class TxDialog(Factory.Popup): |
|
|
|
self.app = app # type: ElectrumWindow |
|
|
|
self.wallet = self.app.wallet |
|
|
|
self.tx = tx # type: Transaction |
|
|
|
self.config = self.app.electrum_config |
|
|
|
|
|
|
|
# If the wallet can populate the inputs with more info, do it now. |
|
|
|
# As a result, e.g. we might learn an imported address tx is segwit, |
|
|
@ -154,7 +155,7 @@ class TxDialog(Factory.Popup): |
|
|
|
self.date_str = datetime.fromtimestamp(tx_mined_status.timestamp).isoformat(' ')[:-3] |
|
|
|
elif exp_n is not None: |
|
|
|
self.date_label = _('Mempool depth') |
|
|
|
self.date_str = _('{} from tip').format('%.2f MB'%(exp_n/1000000)) |
|
|
|
self.date_str = self.config.depth_tooltip(exp_n) |
|
|
|
else: |
|
|
|
self.date_label = '' |
|
|
|
self.date_str = '' |
|
|
|
|
|
@ -476,8 +476,10 @@ class BaseTxDialog(QDialog, MessageBoxMixin): |
|
|
|
self.date_label.setText(_("Date: {}").format(time_str)) |
|
|
|
self.date_label.show() |
|
|
|
elif exp_n is not None: |
|
|
|
text = '%.2f MB'%(exp_n/1000000) |
|
|
|
self.date_label.setText(_('Position in mempool: {} from tip').format(text)) |
|
|
|
text = "{}: {}".format( |
|
|
|
_('Position in mempool'), |
|
|
|
self.config.depth_tooltip(exp_n)) |
|
|
|
self.date_label.setText(text) |
|
|
|
self.date_label.show() |
|
|
|
else: |
|
|
|
self.date_label.hide() |
|
|
|
|
|
@ -437,11 +437,17 @@ class SimpleConfig(Logger): |
|
|
|
min_target = -1 |
|
|
|
return min_target |
|
|
|
|
|
|
|
def get_depth_mb_str(self, depth: int) -> str: |
|
|
|
# e.g. 500_000 -> "0.50 MB" |
|
|
|
depth_mb = "{:.2f}".format(depth / 1_000_000) # maybe .rstrip("0") ? |
|
|
|
return f"{depth_mb} MB" |
|
|
|
|
|
|
|
def depth_tooltip(self, depth: Optional[int]) -> str: |
|
|
|
"""Returns text tooltip for given mempool depth (in vbytes).""" |
|
|
|
if depth is None: |
|
|
|
return "unknown from tip" |
|
|
|
return "%.1f MB from tip" % (depth/1_000_000) |
|
|
|
depth_mb = self.get_depth_mb_str(depth) |
|
|
|
return _("{} from tip").format(depth_mb) |
|
|
|
|
|
|
|
def eta_tooltip(self, x): |
|
|
|
if x < 0: |
|
|
|
|
|
@ -1198,7 +1198,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): |
|
|
|
and self.config.has_fee_mempool(): |
|
|
|
exp_n = self.config.fee_to_depth(fee_per_byte) |
|
|
|
if exp_n is not None: |
|
|
|
extra.append('%.2f MB'%(exp_n/1000000)) |
|
|
|
extra.append(self.config.get_depth_mb_str(exp_n)) |
|
|
|
if height == TX_HEIGHT_LOCAL: |
|
|
|
status = 3 |
|
|
|
elif height == TX_HEIGHT_UNCONF_PARENT: |
|
|
|