Skip to content

Commit

Permalink
Record contract creations in the mapping (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
ESultanik committed Oct 17, 2018
1 parent 432026b commit 7462477
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions etheno/synchronization.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,22 @@ def post(self, data):
self.filter_mapping[self._client.etheno.rpc_client_result['result']] = ret['result']
elif method == 'eth_sendTransaction' or method == 'eth_sendRawTransaction':
# record the transaction hash mapping
if 'result' in ret and ret['result']:
if ret and 'result' in ret and ret['result']:
old_decoded = _decode_value(self._client.etheno.rpc_client_result['result'])
new_decoded = _decode_value(ret['result'])
if old_decoded is not None and new_decoded is not None:
self.mapping[old_decoded] = new_decoded
elif not (old_decoded is None and new_decoded is None):
print("Warning: call to %s returned %s from the master client but %s from %s; ignoring..." % (method, self._client.etheno.rpc_client_result['result'], ret['result'], self._client))
elif method == 'eth_getTransactionReceipt':
# TODO: update the mapping with the address if a new contract was created
pass
# update the mapping with the address if a new contract was created
if ret and 'result' in ret and ret['result'] and 'contractAddress' in ret['result'] and ret['result']['contractAddress']:
master_address = _decode_value(self._client.etheno.rpc_client_result['result']['contractAddress'])
our_address = _decode_value(ret['result']['contractAddress'])
if master_address is not None and our_address is not None:
self.mapping[master_address] = our_address
elif not (master_address is None and our_address is None):
print("Warning: call to %s returned %s from the master client but %s from %s; ignoring..." % (method, self._client.etheno.rpc_client_result['result']['contractAddress'], ret['result']['contractAddress'], self._client))

return ret

Expand Down

0 comments on commit 7462477

Please sign in to comment.