Browse Source

lnworker: better indentation (refactoring only)

patch-4
ThomasV 4 years ago
parent
commit
4ae2717ac7
  1. 54
      electrum/lnworker.py

54
electrum/lnworker.py

@ -945,12 +945,13 @@ class LNWallet(LNWorker):
if not peer: if not peer:
raise Exception('Dropped peer') raise Exception('Dropped peer')
await peer.initialized await peer.initialized
htlc = peer.pay(route=route, htlc = peer.pay(
chan=chan, route=route,
amount_msat=lnaddr.get_amount_msat(), chan=chan,
payment_hash=lnaddr.paymenthash, amount_msat=lnaddr.get_amount_msat(),
min_final_cltv_expiry=lnaddr.get_min_final_cltv_expiry(), payment_hash=lnaddr.paymenthash,
payment_secret=lnaddr.payment_secret) min_final_cltv_expiry=lnaddr.get_min_final_cltv_expiry(),
payment_secret=lnaddr.payment_secret)
util.trigger_callback('htlc_added', chan, htlc, SENT) util.trigger_callback('htlc_added', chan, htlc, SENT)
payment_attempt = await self.await_payment(lnaddr.paymenthash) payment_attempt = await self.await_payment(lnaddr.paymenthash)
if payment_attempt.success: if payment_attempt.success:
@ -1095,13 +1096,15 @@ class LNWallet(LNWorker):
path = full_path[:-len(private_route)] path = full_path[:-len(private_route)]
else: else:
# find path now on public graph, to border node # find path now on public graph, to border node
path = self.network.path_finder.find_path_for_payment(self.node_keypair.pubkey, border_node_pubkey, amount_msat, path = self.network.path_finder.find_path_for_payment(
my_channels=scid_to_my_channels) self.node_keypair.pubkey, border_node_pubkey, amount_msat,
my_channels=scid_to_my_channels)
if not path: if not path:
continue continue
try: try:
route = self.network.path_finder.create_route_from_path(path, self.node_keypair.pubkey, route = self.network.path_finder.create_route_from_path(
my_channels=scid_to_my_channels) path, self.node_keypair.pubkey,
my_channels=scid_to_my_channels)
except NoChannelPolicy: except NoChannelPolicy:
continue continue
# we need to shift the node pubkey by one towards the destination: # we need to shift the node pubkey by one towards the destination:
@ -1113,20 +1116,23 @@ class LNWallet(LNWorker):
short_channel_id = ShortChannelID(short_channel_id) short_channel_id = ShortChannelID(short_channel_id)
# if we have a routing policy for this edge in the db, that takes precedence, # if we have a routing policy for this edge in the db, that takes precedence,
# as it is likely from a previous failure # as it is likely from a previous failure
channel_policy = self.channel_db.get_policy_for_node(short_channel_id=short_channel_id, channel_policy = self.channel_db.get_policy_for_node(
node_id=prev_node_id, short_channel_id=short_channel_id,
my_channels=scid_to_my_channels) node_id=prev_node_id,
my_channels=scid_to_my_channels)
if channel_policy: if channel_policy:
fee_base_msat = channel_policy.fee_base_msat fee_base_msat = channel_policy.fee_base_msat
fee_proportional_millionths = channel_policy.fee_proportional_millionths fee_proportional_millionths = channel_policy.fee_proportional_millionths
cltv_expiry_delta = channel_policy.cltv_expiry_delta cltv_expiry_delta = channel_policy.cltv_expiry_delta
node_info = self.channel_db.get_node_info_for_node_id(node_id=node_pubkey) node_info = self.channel_db.get_node_info_for_node_id(node_id=node_pubkey)
route.append(RouteEdge(node_id=node_pubkey, route.append(
short_channel_id=short_channel_id, RouteEdge(
fee_base_msat=fee_base_msat, node_id=node_pubkey,
fee_proportional_millionths=fee_proportional_millionths, short_channel_id=short_channel_id,
cltv_expiry_delta=cltv_expiry_delta, fee_base_msat=fee_base_msat,
node_features=node_info.features if node_info else 0)) fee_proportional_millionths=fee_proportional_millionths,
cltv_expiry_delta=cltv_expiry_delta,
node_features=node_info.features if node_info else 0))
prev_node_id = node_pubkey prev_node_id = node_pubkey
# test sanity # test sanity
if not is_route_sane_to_use(route, amount_msat, decoded_invoice.get_min_final_cltv_expiry()): if not is_route_sane_to_use(route, amount_msat, decoded_invoice.get_min_final_cltv_expiry()):
@ -1139,12 +1145,14 @@ class LNWallet(LNWorker):
if full_path: # user pre-selected path if full_path: # user pre-selected path
path = full_path path = full_path
else: # find path now else: # find path now
path = self.network.path_finder.find_path_for_payment(self.node_keypair.pubkey, invoice_pubkey, amount_msat, path = self.network.path_finder.find_path_for_payment(
my_channels=scid_to_my_channels) self.node_keypair.pubkey, invoice_pubkey, amount_msat,
my_channels=scid_to_my_channels)
if not path: if not path:
raise NoPathFound() raise NoPathFound()
route = self.network.path_finder.create_route_from_path(path, self.node_keypair.pubkey, route = self.network.path_finder.create_route_from_path(
my_channels=scid_to_my_channels) path, self.node_keypair.pubkey,
my_channels=scid_to_my_channels)
if not is_route_sane_to_use(route, amount_msat, decoded_invoice.get_min_final_cltv_expiry()): if not is_route_sane_to_use(route, amount_msat, decoded_invoice.get_min_final_cltv_expiry()):
self.logger.info(f"rejecting insane route {route}") self.logger.info(f"rejecting insane route {route}")
raise NoPathFound() raise NoPathFound()

Loading…
Cancel
Save