Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 2 additions & 33 deletions src/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class MainWindow(QWidget):
# signal: UTXO list loading percent (emitted by load_utxos_thread in tabRewards)
sig_UTXOsLoading = pyqtSignal(int)


def __init__(self, parent, imgDir):
super(QWidget, self).__init__(parent)
self.parent = parent
Expand Down Expand Up @@ -145,13 +144,8 @@ def clearHWstatus(self, message=''):
def clearRPCstatus(self):
with self.lock:
self.rpcConnected = False
self.header.lastPingBox.setHidden(False)
self.header.rpcLed.setPixmap(self.ledGrayH_icon)
self.header.lastBlockLabel.setText("<em>Connecting...</em>")
self.header.lastPingIcon.setPixmap(self.connRed_icon)
self.header.responseTimeLabel.setText("--")
self.header.responseTimeLabel.setStyleSheet("color: red")
self.header.lastPingIcon.setStyleSheet("color: red")

def connButtons(self):
self.header.button_checkRpc.clicked.connect(lambda: self.onCheckRpc())
Expand Down Expand Up @@ -355,25 +349,6 @@ def updateLastBlockLabel(self):

self.header.lastBlockLabel.setText(text)

def updateLastBlockPing(self):
if not self.rpcConnected:
self.header.lastPingBox.setHidden(True)
else:
self.header.lastPingBox.setHidden(False)
if self.rpcResponseTime > 2:
color = "red"
self.header.lastPingIcon.setPixmap(self.connRed_icon)
elif self.rpcResponseTime > 1:
color = "orange"
self.header.lastPingIcon.setPixmap(self.connOrange_icon)
else:
color = "green"
self.header.lastPingIcon.setPixmap(self.connGreen_icon)
if self.rpcResponseTime is not None:
self.header.responseTimeLabel.setText("%.3f" % self.rpcResponseTime)
self.header.responseTimeLabel.setStyleSheet("color: %s" % color)
self.header.lastPingIcon.setStyleSheet("color: %s" % color)

def updateRPCled(self, fDebug=False):
if self.rpcConnected:
self.header.rpcLed.setPixmap(self.ledPurpleH_icon)
Expand All @@ -391,7 +366,6 @@ def updateRPCled(self, fDebug=False):

self.header.rpcLed.setToolTip(self.rpcStatusMess)
self.updateLastBlockLabel()
self.updateLastBlockPing()

def updateRPClist(self):
# Clear old stuff
Expand Down Expand Up @@ -432,19 +406,15 @@ def updateRPCstatus(self, ctrl, fDebug=False):

try:
rpcClient = RpcClient(rpc_protocol, rpc_host, rpc_user, rpc_password)
status, statusMess, lastBlock, r_time1, isTestnet = rpcClient.getStatus()
isBlockchainSynced, r_time2 = rpcClient.isBlockchainSynced()
status, statusMess, lastBlock, isTestnet = rpcClient.getStatus()
isBlockchainSynced = rpcClient.isBlockchainSynced()
except Exception as e:
printException(getCallerName(), getFunctionName(), "exception updating RPC status:", str(e))
# clear status
self.rpcClient = None
self.sig_clearRPCstatus.emit()
return

rpcResponseTime = None
if r_time1 is not None and r_time2 != 0:
rpcResponseTime = round((r_time1 + r_time2) / 2, 3)

# Do not update status if the user has selected a different server since the start of updateRPCStatus()
if rpc_index != self.header.rpcClientsBox.currentIndex():
return
Expand All @@ -455,7 +425,6 @@ def updateRPCstatus(self, ctrl, fDebug=False):
self.rpcLastBlock = lastBlock
self.rpcStatusMess = statusMess
self.isBlockchainSynced = isBlockchainSynced
self.rpcResponseTime = rpcResponseTime
# if testnet flag is changed, update api client and persist setting
if isTestnet != self.isTestnetRPC:
self.isTestnetRPC = isTestnet
Expand Down
28 changes: 10 additions & 18 deletions src/qt/guiHeader.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,21 @@ def __init__(self, caller, *args, **kwargs):
self.rpcLed.setToolTip("%s" % caller.rpcStatusMess)
self.rpcLed.setPixmap(caller.ledGrayH_icon)
self.centralBox.addWidget(self.rpcLed, 0, 3)
self.lastPingBox = QWidget()
self.lastBlockBox = QWidget()
sp_retain = QSizePolicy()
sp_retain.setRetainSizeWhenHidden(True)
self.lastPingBox.setSizePolicy(sp_retain)
self.lastPingBox.setContentsMargins(0, 0, 0, 0)
lastPingBoxLayout = QHBoxLayout()
self.lastPingIcon = QLabel()
self.lastPingIcon.setToolTip("Last ping server response time.\n(The lower, the better)")
self.lastPingIcon.setPixmap(caller.connRed_icon)
lastPingBoxLayout.addWidget(self.lastPingIcon)
self.responseTimeLabel = QLabel()
self.responseTimeLabel.setToolTip("Last ping server response time.\n(The lower, the better)")
lastPingBoxLayout.addWidget(self.responseTimeLabel)
lastPingBoxLayout.addSpacing(10)
self.lastBlockBox.setSizePolicy(sp_retain)
self.lastBlockBox.setContentsMargins(0, 0, 0, 0)
lastBlockBoxLayout = QHBoxLayout()
self.lastBlockIcon = QLabel()
self.lastBlockIcon.setToolTip("Last ping block number")
self.lastBlockIcon.setToolTip("Last known block number")
self.lastBlockIcon.setPixmap(caller.lastBlock_icon)
lastPingBoxLayout.addWidget(self.lastBlockIcon)
lastBlockBoxLayout.addWidget(self.lastBlockIcon)
self.lastBlockLabel = QLabel()
self.lastBlockLabel.setToolTip("Last ping block number")
lastPingBoxLayout.addWidget(self.lastBlockLabel)
self.lastPingBox.setLayout(lastPingBoxLayout)
self.centralBox.addWidget(self.lastPingBox, 0, 4)
self.lastBlockLabel.setToolTip("Last known block number / status")
lastBlockBoxLayout.addWidget(self.lastBlockLabel)
self.lastBlockBox.setLayout(lastBlockBoxLayout)
self.centralBox.addWidget(self.lastBlockBox, 0, 4)
# -- 1b) Select & Check hardware
label3 = QLabel("Hardware Device")
self.centralBox.addWidget(label3, 1, 0)
Expand Down
12 changes: 5 additions & 7 deletions src/rpcClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import threading

from constants import DEFAULT_PROTOCOL_VERSION, MINIMUM_FEE
from misc import getCallerName, getFunctionName, printException, printDbg, now, timeThis
from misc import getCallerName, getFunctionName, printException, printDbg, now


def process_RPC_exceptions(func):
Expand Down Expand Up @@ -190,29 +190,27 @@ def getStatus(self):
statusMess = "Unable to connect to a PIVX RPC server.\n"
statusMess += "Either the local PIVX wallet is not open, or the remote RPC server is not responding."
n = 0
response_time = None
with self.lock:
isTestnet = self.conn.getinfo()['testnet']
n, response_time = timeThis(self.conn.getblockcount)
n = self.conn.getblockcount()
if n is None:
n = 0

if n > 0:
status = True
statusMess = "Connected to PIVX Blockchain"

return status, statusMess, n, response_time, isTestnet
return status, statusMess, n, isTestnet

@process_RPC_exceptions
def isBlockchainSynced(self):
res = False
response_time = None
with self.lock:
status, response_time = timeThis(self.conn.mnsync, 'status')
status = self.conn.mnsync('status')
if status is not None:
res = status.get("IsBlockchainSynced")
return res

return res, response_time

@process_RPC_exceptions
def mnBudgetRawVote(self, mn_tx_hash, mn_tx_index, proposal_hash, vote, time, vote_sig):
Expand Down
Loading