1
0

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)
This commit is contained in:
SomberNight
2022-03-31 22:50:31 +02:00
parent 2b13576eb3
commit 7268fa55f2
4 changed files with 14 additions and 5 deletions

View File

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