Skip to content

Commit

Permalink
Small nit in wallet.py add_transaction
Browse files Browse the repository at this point in the history
- One of the nested functions was not using its input param `txin` but
  rather referencing `txi` in the outer scope.  This turned out to be
  equivalent (since it would always get passed a variable named `txi`),
  but the fact that it did this was a code smell.
- Fixed some formatting on a very long line
- Converted triple quoted comment ''' to """
  • Loading branch information
cculianu committed Dec 30, 2020
1 parent cb8ab55 commit bd36910
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions electroncash/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,8 @@ def can_do_work():
def add_transaction(self, tx_hash, tx):
if not tx.inputs():
# bad tx came in off the wire -- all 0's or something, see #987
self.print_error("add_transaction: WARNING a tx came in from the network with 0 inputs! Bad server? Ignoring tx:", tx_hash)
self.print_error("add_transaction: WARNING a tx came in from the network with 0 inputs!"
" Bad server? Ignoring tx:", tx_hash)
return
is_coinbase = tx.inputs()[0]['type'] == 'coinbase'
with self.lock:
Expand All @@ -1274,21 +1275,21 @@ def add_to_self_txi(tx_hash, addr, ser, v):
d[addr] = l = []
l.append((ser, v))
def find_in_self_txo(prevout_hash: str, prevout_n: int) -> tuple:
''' Returns a tuple of the (Address,value) for a given
"""Returns a tuple of the (Address,value) for a given
prevout_hash:prevout_n, or (None, None) if not found. If valid
return, the Address object is found by scanning self.txo. The
lookup below is relatively fast in practice even on pathological
wallets. '''
wallets."""
dd = self.txo.get(prevout_hash, {})
for addr2, item in dd.items():
for n, v, is_cb in item:
if n == prevout_n:
return addr2, v
return (None, None)
def txin_get_info(txin):
def txin_get_info(txi):
prevout_hash = txi['prevout_hash']
prevout_n = txi['prevout_n']
ser = prevout_hash + ':%d'%prevout_n
ser = f'{prevout_hash}:{prevout_n}'
return prevout_hash, prevout_n, ser
def put_pruned_txo(ser, tx_hash):
self.pruned_txo[ser] = tx_hash
Expand Down

0 comments on commit bd36910

Please sign in to comment.