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

Commit

Permalink
Don't depend on first rpc call not throwing exception
Browse files Browse the repository at this point in the history
  • Loading branch information
icook committed Oct 2, 2014
1 parent 41dd35d commit 3fbbda1
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions powerpool/jobmanagers/monitor_aux_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,25 +101,28 @@ def found_block(self, address, worker, header, coinbase_raw, job, start):
hsh = hexlify(pack.IntType(256, 'big').pack(aux_data['hash']))
self.logger.info("{} BLOCK {}:{} accepted"
.format(self.config['currency'], hsh, new_height))

# A bit of a mess that grabs the required information for
# reporting the new block. Pretty failsafe so at least
# partial information will be reporter regardless
block = None
amount = 0
try:
block = self.call_rpc('getblock', hsh)
except Exception:
self.logger.info("", exc_info=True)
try:
trans = self.call_rpc('gettxout', block['tx'][0], 0)
amount = trans['value']
except Exception:
self.logger.info("", exc_info=True)
amount = -1
else:
try:
trans = self.call_rpc('gettxout', block['tx'][0], 0)
amount = trans['value']
except Exception:
self.logger.info("", exc_info=True)

self.block_stats['last_solve_hash'] = hsh
return dict(address=address,
height=new_height,
total_subsidy=int(amount * 100000000),
fees=-1,
fees=None,
hex_bits="%0.6X" % bitcoin_data.FloatingInteger.from_target_upper_bound(aux_data['target']).bits,
hex_hash=hsh,
currency=self.config['currency'],
Expand Down

0 comments on commit 3fbbda1

Please sign in to comment.