def close_all(self, only_receiving=True):
""" Close all channels in the token network.
Note: By default we're just discarding all channels we haven't received anything.
This potentially leaves deposits locked in channels after `closing`. This is "safe"
from an accounting point of view (deposits can not be lost), but may still be
undesirable from a liquidity point of view (deposits will only be freed after
manually closing or after the partner closed the channel).
If only_receiving is False then we close and settle all channels irrespective of them
having received transfers or not.
"""
with self.lock:
self.initial_channel_target = 0
channels_to_close = (
self.receiving_channels[:] if only_receiving else self.open_channels[:]
)
for channel in channels_to_close:
# FIXME: race condition, this can fail if channel was closed externally
self.api.close(self.token_address, channel.partner_address)
return channels_to_close
评论列表
文章目录