From ecc582489c56cfee9c7e6286f598b1097831c588 Mon Sep 17 00:00:00 2001 From: Yura Pakhuchiy Date: Sat, 9 Jun 2018 17:29:21 +0700 Subject: [PATCH] Add different workaround for zcoind bug --- src/dashd_intf.py | 4 ++-- src/main_dlg.py | 58 +++++++++++++++++++++++++++-------------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/src/dashd_intf.py b/src/dashd_intf.py index 2b834de..bc5428d 100644 --- a/src/dashd_intf.py +++ b/src/dashd_intf.py @@ -869,8 +869,8 @@ def znsync(self): @control_rpc_call def znodebroadcast(self, what, hexto): if self.open(): - if what == 'relay': - # if False: + # if what == 'relay': + if False: # FIXME: relay does not report correct status without 3rd parameter due to bug in zcoind return self.proxy.znodebroadcast(what, hexto, "not-safe") else: diff --git a/src/main_dlg.py b/src/main_dlg.py index bc7a5cb..9252716 100644 --- a/src/main_dlg.py +++ b/src/main_dlg.py @@ -1543,31 +1543,39 @@ def on_btnBroadcastMn_clicked(self): default_button=QMessageBox.Yes, icon=QMessageBox.Information) == QMessageBox.Cancel: return - ret = self.dashd_intf.znodebroadcast("relay", work) - - match = re.search("relayed broadcast messages for (\d+) znodes.*failed to relay (\d+), total 1", - ret['overall']) - - failed_count = 0 - ok_count = 0 - if match and len(match.groups()): - ok_count = int(match.group(1)) - failed_count = int(match.group(2)) - - overall = ret['overall'] - errorMessage = '' - - if failed_count: - del ret['overall'] - keys = list(ret.keys()) - if len(keys): - # get the first (and currently the only) error message - errorMessage = ret[keys[0]].get('errorMessage') - - if failed_count == 0: - self.infoMsg(overall) - else: - self.errorMsg('Failed to start znode.\n\nResponse from Zcoin daemon: %s.' % errorMessage) + retried = False + while True: + ret = self.dashd_intf.znodebroadcast("relay", work) + + match = re.search("relayed broadcast messages for (\d+) znodes.*failed to relay (\d+), total 1", + ret['overall']) + + failed_count = 0 + ok_count = 0 + if match and len(match.groups()): + ok_count = int(match.group(1)) + failed_count = int(match.group(2)) + + overall = ret['overall'] + errorMessage = '' + + if failed_count: + if not retried: + # Due to zcoind bug first `znodebroadcast relay` can report failure while it actually + # succeeded. Re-broadcast it again to check actual result. + retried = True + continue + del ret['overall'] + keys = list(ret.keys()) + if len(keys): + # get the first (and currently the only) error message + errorMessage = ret[keys[0]].get('errorMessage') + + if failed_count == 0: + self.infoMsg(overall) + else: + self.errorMsg('Failed to start znode.\n\nResponse from Zcoin daemon: %s.' % errorMessage) + break else: logging.error('Start MN error: ' + str(ret)) errorMessage = ret[list(ret.keys())[0]].get('errorMessage')