lnrouter: remove blacklist boolean
This commit is contained in:
@@ -180,8 +180,7 @@ class LiquidityHint:
|
|||||||
self._cannot_send_forward = None
|
self._cannot_send_forward = None
|
||||||
self._can_send_backward = None
|
self._can_send_backward = None
|
||||||
self._cannot_send_backward = None
|
self._cannot_send_backward = None
|
||||||
self.is_blacklisted = False
|
self.blacklist_timestamp = 0
|
||||||
self.timestamp = 0
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def can_send_forward(self):
|
def can_send_forward(self):
|
||||||
@@ -267,9 +266,10 @@ class LiquidityHint:
|
|||||||
self.cannot_send_backward = amount
|
self.cannot_send_backward = amount
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return f"forward: can send: {self._can_send_forward}, cannot send: {self._cannot_send_forward}, \n" \
|
is_blacklisted = False if not self.blacklist_timestamp else int(time.time()) - self.blacklist_timestamp < BLACKLIST_DURATION
|
||||||
f"backward: can send: {self._can_send_backward} cannot send: {self._cannot_send_backward}, \n" \
|
return f"forward: can send: {self._can_send_forward} msat, cannot send: {self._cannot_send_forward} msat, \n" \
|
||||||
f"blacklisted: {self.is_blacklisted}"
|
f"backward: can send: {self._can_send_backward} msat, cannot send: {self._cannot_send_backward} msat, \n" \
|
||||||
|
f"blacklisted: {is_blacklisted}"
|
||||||
|
|
||||||
|
|
||||||
class LiquidityHintMgr:
|
class LiquidityHintMgr:
|
||||||
@@ -341,21 +341,20 @@ class LiquidityHintMgr:
|
|||||||
return fee_for_edge_msat(amount, DEFAULT_PENALTY_BASE_MSAT, DEFAULT_PENALTY_PROPORTIONAL_MILLIONTH)
|
return fee_for_edge_msat(amount, DEFAULT_PENALTY_BASE_MSAT, DEFAULT_PENALTY_PROPORTIONAL_MILLIONTH)
|
||||||
|
|
||||||
@with_lock
|
@with_lock
|
||||||
def add_to_blacklist(self, node_from: bytes, node_to: bytes, channel_id: ShortChannelID):
|
def add_to_blacklist(self, channel_id: ShortChannelID):
|
||||||
hint = self.get_hint(channel_id)
|
hint = self.get_hint(channel_id)
|
||||||
hint.is_blacklisted = True
|
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
hint.timestamp = now
|
hint.blacklist_timestamp = now
|
||||||
|
|
||||||
@with_lock
|
@with_lock
|
||||||
def get_blacklist(self) -> Set[ShortChannelID]:
|
def get_blacklist(self) -> Set[ShortChannelID]:
|
||||||
now = int(time.time())
|
now = int(time.time())
|
||||||
return set(k for k, v in self._liquidity_hints.items() if now - v.timestamp < BLACKLIST_DURATION)
|
return set(k for k, v in self._liquidity_hints.items() if now - v.blacklist_timestamp < BLACKLIST_DURATION)
|
||||||
|
|
||||||
@with_lock
|
@with_lock
|
||||||
def clear_blacklist(self):
|
def clear_blacklist(self):
|
||||||
for k, v in self._liquidity_hints.items():
|
for k, v in self._liquidity_hints.items():
|
||||||
v.is_blacklisted = False
|
v.blacklist_timestamp = 0
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
string = "liquidity hints:\n"
|
string = "liquidity hints:\n"
|
||||||
|
|||||||
@@ -1338,7 +1338,7 @@ class LNWallet(LNWorker):
|
|||||||
failing_channel=ShortChannelID(payload['short_channel_id']))
|
failing_channel=ShortChannelID(payload['short_channel_id']))
|
||||||
elif blacklist:
|
elif blacklist:
|
||||||
self.network.path_finder.liquidity_hints.add_to_blacklist(
|
self.network.path_finder.liquidity_hints.add_to_blacklist(
|
||||||
node_from, node_to, payload['short_channel_id'])
|
payload['short_channel_id'])
|
||||||
|
|
||||||
# if we can't decide on some action, we are stuck
|
# if we can't decide on some action, we are stuck
|
||||||
if not (blacklist or update):
|
if not (blacklist or update):
|
||||||
@@ -1346,7 +1346,7 @@ class LNWallet(LNWorker):
|
|||||||
|
|
||||||
# for errors that do not include a channel update
|
# for errors that do not include a channel update
|
||||||
else:
|
else:
|
||||||
self.network.path_finder.liquidity_hints.add_to_blacklist(node_from, node_to, fallback_channel)
|
self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)
|
||||||
|
|
||||||
def _handle_chanupd_from_failed_htlc(self, payload, *, route, sender_idx) -> Tuple[bool, bool]:
|
def _handle_chanupd_from_failed_htlc(self, payload, *, route, sender_idx) -> Tuple[bool, bool]:
|
||||||
blacklist = False
|
blacklist = False
|
||||||
|
|||||||
Reference in New Issue
Block a user