contrib: Fix NameError in signet miner gbt()

The logging.warning call referenced `bci["bestblockhash"]`, a variable
from the calling scope `do_generate()` that is not available inside the
`Generate.gbt()` method. This would crash with a NameError when
getblocktemplate returned a template based on an unexpected previous
block.

Use the `bestblockhash` parameter that was already being passed in and
used correctly in the comparison on the line above.

The bug was introduced in 7b31332370 when the gbt logic was extracted
into its own method — the if-condition was updated but the logging
call was not.

Github-Pull: #35044
Rebased-From: 701bc2dc02
This commit is contained in:
Torkel Rogstad
2026-04-10 10:23:30 +02:00
committed by fanquake
parent 7a97580997
commit 0449061877

View File

@@ -333,7 +333,7 @@ class Generate:
def gbt(self, bcli, bestblockhash, now):
tmpl = json.loads(bcli("getblocktemplate", '{"rules":["signet","segwit"]}'))
if tmpl["previousblockhash"] != bestblockhash:
logging.warning("GBT based off unexpected block (%s not %s), retrying", tmpl["previousblockhash"], bci["bestblockhash"])
logging.warning("GBT based off unexpected block (%s not %s), retrying", tmpl["previousblockhash"], bestblockhash)
time.sleep(1)
return None