Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit 3fbbda1

Browse files
committed
Don't depend on first rpc call not throwing exception
1 parent 41dd35d commit 3fbbda1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

powerpool/jobmanagers/monitor_aux_network.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,28 @@ def found_block(self, address, worker, header, coinbase_raw, job, start):
101101
hsh = hexlify(pack.IntType(256, 'big').pack(aux_data['hash']))
102102
self.logger.info("{} BLOCK {}:{} accepted"
103103
.format(self.config['currency'], hsh, new_height))
104+
104105
# A bit of a mess that grabs the required information for
105106
# reporting the new block. Pretty failsafe so at least
106107
# partial information will be reporter regardless
108+
block = None
109+
amount = 0
107110
try:
108111
block = self.call_rpc('getblock', hsh)
109112
except Exception:
110113
self.logger.info("", exc_info=True)
111-
try:
112-
trans = self.call_rpc('gettxout', block['tx'][0], 0)
113-
amount = trans['value']
114-
except Exception:
115-
self.logger.info("", exc_info=True)
116-
amount = -1
114+
else:
115+
try:
116+
trans = self.call_rpc('gettxout', block['tx'][0], 0)
117+
amount = trans['value']
118+
except Exception:
119+
self.logger.info("", exc_info=True)
117120

118121
self.block_stats['last_solve_hash'] = hsh
119122
return dict(address=address,
120123
height=new_height,
121124
total_subsidy=int(amount * 100000000),
122-
fees=-1,
125+
fees=None,
123126
hex_bits="%0.6X" % bitcoin_data.FloatingInteger.from_target_upper_bound(aux_data['target']).bits,
124127
hex_hash=hsh,
125128
currency=self.config['currency'],

0 commit comments

Comments
 (0)