Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Commit

Permalink
Add different workaround for zcoind bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yura-pakhuchiy committed Jun 9, 2018
1 parent 27e784a commit ecc5824
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/dashd_intf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
58 changes: 33 additions & 25 deletions src/main_dlg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit ecc5824

Please sign in to comment.