Browse Source

show watchtower db size in GUI

master
ThomasV 5 years ago
parent
commit
a3332dc72a
  1. 6
      electrum/gui/qt/watchtower_dialog.py
  2. 3
      electrum/sql_db.py

6
electrum/gui/qt/watchtower_dialog.py

@ -25,7 +25,7 @@
from PyQt5.QtGui import QStandardItemModel, QStandardItem
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QPushButton)
from PyQt5.QtWidgets import (QDialog, QVBoxLayout, QPushButton, QLabel)
from electrum.i18n import _
from .util import MyTreeView, Buttons
@ -53,6 +53,8 @@ class WatcherList(MyTreeView):
status = lnwatcher.get_channel_status(outpoint)
items = [QStandardItem(e) for e in [outpoint, "%d"%n, status]]
self.model().insertRow(self.model().rowCount(), items)
size = lnwatcher.sweepstore.filesize()
self.parent.size_label.setText('Database size: %.2f Mb'%(size/1024/1024.))
class WatchtowerDialog(QDialog):
@ -66,9 +68,11 @@ class WatchtowerDialog(QDialog):
self.lnwatcher = self.network.local_watchtower
self.setWindowTitle(_('Watchtower'))
self.setMinimumSize(600, 20)
self.size_label = QLabel()
self.watcher_list = WatcherList(self)
vbox = QVBoxLayout(self)
vbox.addWidget(self.size_label)
vbox.addWidget(self.watcher_list)
b = QPushButton(_('Close'))
b.clicked.connect(self.close)

3
electrum/sql_db.py

@ -28,6 +28,9 @@ class SqlDB(Logger):
self.sql_thread = threading.Thread(target=self.run_sql)
self.sql_thread.start()
def filesize(self):
return os.stat(self.path).st_size
def run_sql(self):
self.logger.info("SQL thread started")
self.conn = sqlite3.connect(self.path)

Loading…
Cancel
Save