arweave-python-client icon indicating copy to clipboard operation
arweave-python-client copied to clipboard

Variable 'reward' referenced before assignment

Open smacrineanu opened this issue 3 years ago • 0 comments

Describe the bug The get_reward() function from arweave_lib.py fails randomly because of poor variable usage.

My guess is that the following code fails when the status.code is different than 200.

if response.status_code == 200:
            reward = response.text

return reward

Here is the traceback:

File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 192, in sign
  data_to_sign = self.get_signature_data()
File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 204, in get_signature_data
  self.reward = self.get_reward(self.data_size, target_address=self.target if len(self.target) > 0 else None)
File "/home/user/.local/lib/python3.8/site-packages/arweave/arweave_lib.py", line 178, in get_reward
  return reward
UnboundLocalError: local variable 'reward' referenced before assignment

smacrineanu avatar Nov 17 '22 15:11 smacrineanu