repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager.connect
def connect( self, funds: typing.TokenAmount, initial_channel_target: int = 3, joinable_funds_target: float = 0.4, ): """Connect to the network. Subsequent calls to `connect` are allowed, but will only affect the spendable funds and the connec...
python
def connect( self, funds: typing.TokenAmount, initial_channel_target: int = 3, joinable_funds_target: float = 0.4, ): """Connect to the network. Subsequent calls to `connect` are allowed, but will only affect the spendable funds and the connec...
[ "def", "connect", "(", "self", ",", "funds", ":", "typing", ".", "TokenAmount", ",", "initial_channel_target", ":", "int", "=", "3", ",", "joinable_funds_target", ":", "float", "=", "0.4", ",", ")", ":", "token", "=", "self", ".", "raiden", ".", "chain",...
Connect to the network. Subsequent calls to `connect` are allowed, but will only affect the spendable funds and the connection strategy parameters for the future. `connect` will not close any channels. Note: the ConnectionManager does not discriminate manually opened channels from ...
[ "Connect", "to", "the", "network", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L101-L166
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager.leave
def leave(self, registry_address): """ Leave the token network. This implies closing all channels and waiting for all channels to be settled. """ with self.lock: self.initial_channel_target = 0 channels_to_close = views.get_channelstate_open( ...
python
def leave(self, registry_address): """ Leave the token network. This implies closing all channels and waiting for all channels to be settled. """ with self.lock: self.initial_channel_target = 0 channels_to_close = views.get_channelstate_open( ...
[ "def", "leave", "(", "self", ",", "registry_address", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "initial_channel_target", "=", "0", "channels_to_close", "=", "views", ".", "get_channelstate_open", "(", "chain_state", "=", "views", ".", "state_fr...
Leave the token network. This implies closing all channels and waiting for all channels to be settled.
[ "Leave", "the", "token", "network", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L168-L206
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager.join_channel
def join_channel(self, partner_address, partner_deposit): """Will be called, when we were selected as channel partner by another node. It will fund the channel with up to the partners deposit, but not more than remaining funds or the initial funding per channel. If the connection manage...
python
def join_channel(self, partner_address, partner_deposit): """Will be called, when we were selected as channel partner by another node. It will fund the channel with up to the partners deposit, but not more than remaining funds or the initial funding per channel. If the connection manage...
[ "def", "join_channel", "(", "self", ",", "partner_address", ",", "partner_deposit", ")", ":", "# Consider this race condition:", "#", "# - Partner opens the channel and starts the deposit.", "# - This nodes learns about the new channel, starts ConnectionManager's", "# retry_connect, wh...
Will be called, when we were selected as channel partner by another node. It will fund the channel with up to the partners deposit, but not more than remaining funds or the initial funding per channel. If the connection manager has no funds, this is a noop.
[ "Will", "be", "called", "when", "we", "were", "selected", "as", "channel", "partner", "by", "another", "node", ".", "It", "will", "fund", "the", "channel", "with", "up", "to", "the", "partners", "deposit", "but", "not", "more", "than", "remaining", "funds"...
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L208-L286
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager.retry_connect
def retry_connect(self): """Will be called when new channels in the token network are detected. If the minimum number of channels was not yet established, it will try to open new channels. If the connection manager has no funds, this is a noop. """ with self.lock: ...
python
def retry_connect(self): """Will be called when new channels in the token network are detected. If the minimum number of channels was not yet established, it will try to open new channels. If the connection manager has no funds, this is a noop. """ with self.lock: ...
[ "def", "retry_connect", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "if", "self", ".", "_funds_remaining", ">", "0", "and", "not", "self", ".", "_leaving_state", ":", "self", ".", "_open_channels", "(", ")" ]
Will be called when new channels in the token network are detected. If the minimum number of channels was not yet established, it will try to open new channels. If the connection manager has no funds, this is a noop.
[ "Will", "be", "called", "when", "new", "channels", "in", "the", "token", "network", "are", "detected", ".", "If", "the", "minimum", "number", "of", "channels", "was", "not", "yet", "established", "it", "will", "try", "to", "open", "new", "channels", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L288-L297
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager._find_new_partners
def _find_new_partners(self): """ Search the token network for potential channel partners. """ open_channels = views.get_channelstate_open( chain_state=views.state_from_raiden(self.raiden), payment_network_id=self.registry_address, token_address=self.token_address, ...
python
def _find_new_partners(self): """ Search the token network for potential channel partners. """ open_channels = views.get_channelstate_open( chain_state=views.state_from_raiden(self.raiden), payment_network_id=self.registry_address, token_address=self.token_address, ...
[ "def", "_find_new_partners", "(", "self", ")", ":", "open_channels", "=", "views", ".", "get_channelstate_open", "(", "chain_state", "=", "views", ".", "state_from_raiden", "(", "self", ".", "raiden", ")", ",", "payment_network_id", "=", "self", ".", "registry_a...
Search the token network for potential channel partners.
[ "Search", "the", "token", "network", "for", "potential", "channel", "partners", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L299-L327
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager._join_partner
def _join_partner(self, partner: Address): """ Ensure a channel exists with partner and is funded in our side """ try: self.api.channel_open( self.registry_address, self.token_address, partner, ) except DuplicatedChannelErro...
python
def _join_partner(self, partner: Address): """ Ensure a channel exists with partner and is funded in our side """ try: self.api.channel_open( self.registry_address, self.token_address, partner, ) except DuplicatedChannelErro...
[ "def", "_join_partner", "(", "self", ",", "partner", ":", "Address", ")", ":", "try", ":", "self", ".", "api", ".", "channel_open", "(", "self", ".", "registry_address", ",", "self", ".", "token_address", ",", "partner", ",", ")", "except", "DuplicatedChan...
Ensure a channel exists with partner and is funded in our side
[ "Ensure", "a", "channel", "exists", "with", "partner", "and", "is", "funded", "in", "our", "side" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L329-L373
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager._open_channels
def _open_channels(self) -> bool: """ Open channels until there are `self.initial_channel_target` channels open. Do nothing if there are enough channels open already. Note: - This method must be called with the lock held. Return: - False if no channels could be o...
python
def _open_channels(self) -> bool: """ Open channels until there are `self.initial_channel_target` channels open. Do nothing if there are enough channels open already. Note: - This method must be called with the lock held. Return: - False if no channels could be o...
[ "def", "_open_channels", "(", "self", ")", "->", "bool", ":", "open_channels", "=", "views", ".", "get_channelstate_open", "(", "chain_state", "=", "views", ".", "state_from_raiden", "(", "self", ".", "raiden", ")", ",", "payment_network_id", "=", "self", ".",...
Open channels until there are `self.initial_channel_target` channels open. Do nothing if there are enough channels open already. Note: - This method must be called with the lock held. Return: - False if no channels could be opened
[ "Open", "channels", "until", "there", "are", "self", ".", "initial_channel_target", "channels", "open", ".", "Do", "nothing", "if", "there", "are", "enough", "channels", "open", "already", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L375-L435
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager._initial_funding_per_partner
def _initial_funding_per_partner(self) -> int: """The calculated funding per partner depending on configuration and overall funding of the ConnectionManager. Note: - This attribute must be accessed with the lock held. """ if self.initial_channel_target: r...
python
def _initial_funding_per_partner(self) -> int: """The calculated funding per partner depending on configuration and overall funding of the ConnectionManager. Note: - This attribute must be accessed with the lock held. """ if self.initial_channel_target: r...
[ "def", "_initial_funding_per_partner", "(", "self", ")", "->", "int", ":", "if", "self", ".", "initial_channel_target", ":", "return", "int", "(", "self", ".", "funds", "*", "(", "1", "-", "self", ".", "joinable_funds_target", ")", "/", "self", ".", "initi...
The calculated funding per partner depending on configuration and overall funding of the ConnectionManager. Note: - This attribute must be accessed with the lock held.
[ "The", "calculated", "funding", "per", "partner", "depending", "on", "configuration", "and", "overall", "funding", "of", "the", "ConnectionManager", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L438-L451
train
raiden-network/raiden
raiden/connection_manager.py
ConnectionManager._funds_remaining
def _funds_remaining(self) -> int: """The remaining funds after subtracting the already deposited amounts. Note: - This attribute must be accessed with the lock held. """ if self.funds > 0: token = self.raiden.chain.token(self.token_address) token_bal...
python
def _funds_remaining(self) -> int: """The remaining funds after subtracting the already deposited amounts. Note: - This attribute must be accessed with the lock held. """ if self.funds > 0: token = self.raiden.chain.token(self.token_address) token_bal...
[ "def", "_funds_remaining", "(", "self", ")", "->", "int", ":", "if", "self", ".", "funds", ">", "0", ":", "token", "=", "self", ".", "raiden", ".", "chain", ".", "token", "(", "self", ".", "token_address", ")", "token_balance", "=", "token", ".", "ba...
The remaining funds after subtracting the already deposited amounts. Note: - This attribute must be accessed with the lock held.
[ "The", "remaining", "funds", "after", "subtracting", "the", "already", "deposited", "amounts", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/connection_manager.py#L454-L471
train
raiden-network/raiden
tools/debugging/replay_wal.py
Translator._make_regex
def _make_regex(self): """ Compile rxp with all keys concatenated. """ rxp = "|".join( map(self._address_rxp, self.keys()), ) self._regex = re.compile( rxp, re.IGNORECASE, )
python
def _make_regex(self): """ Compile rxp with all keys concatenated. """ rxp = "|".join( map(self._address_rxp, self.keys()), ) self._regex = re.compile( rxp, re.IGNORECASE, )
[ "def", "_make_regex", "(", "self", ")", ":", "rxp", "=", "\"|\"", ".", "join", "(", "map", "(", "self", ".", "_address_rxp", ",", "self", ".", "keys", "(", ")", ")", ",", ")", "self", ".", "_regex", "=", "re", ".", "compile", "(", "rxp", ",", "...
Compile rxp with all keys concatenated.
[ "Compile", "rxp", "with", "all", "keys", "concatenated", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/debugging/replay_wal.py#L97-L105
train
raiden-network/raiden
raiden/api/v1/resources.py
TokensResource.get
def get(self): """ this translates to 'get all token addresses we have channels open for' """ return self.rest_api.get_tokens_list( self.rest_api.raiden_api.raiden.default_registry.address, )
python
def get(self): """ this translates to 'get all token addresses we have channels open for' """ return self.rest_api.get_tokens_list( self.rest_api.raiden_api.raiden.default_registry.address, )
[ "def", "get", "(", "self", ")", ":", "return", "self", ".", "rest_api", ".", "get_tokens_list", "(", "self", ".", "rest_api", ".", "raiden_api", ".", "raiden", ".", "default_registry", ".", "address", ",", ")" ]
this translates to 'get all token addresses we have channels open for'
[ "this", "translates", "to", "get", "all", "token", "addresses", "we", "have", "channels", "open", "for" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/v1/resources.py#L88-L94
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
is_safe_to_wait
def is_safe_to_wait( lock_expiration: BlockExpiration, reveal_timeout: BlockTimeout, block_number: BlockNumber, ) -> SuccessOrError: """ True if waiting is safe, i.e. there are more than enough blocks to safely unlock on chain. """ # reveal timeout will not ever be larger than th...
python
def is_safe_to_wait( lock_expiration: BlockExpiration, reveal_timeout: BlockTimeout, block_number: BlockNumber, ) -> SuccessOrError: """ True if waiting is safe, i.e. there are more than enough blocks to safely unlock on chain. """ # reveal timeout will not ever be larger than th...
[ "def", "is_safe_to_wait", "(", "lock_expiration", ":", "BlockExpiration", ",", "reveal_timeout", ":", "BlockTimeout", ",", "block_number", ":", "BlockNumber", ",", ")", "->", "SuccessOrError", ":", "# reveal timeout will not ever be larger than the lock_expiration otherwise", ...
True if waiting is safe, i.e. there are more than enough blocks to safely unlock on chain.
[ "True", "if", "waiting", "is", "safe", "i", ".", "e", ".", "there", "are", "more", "than", "enough", "blocks", "to", "safely", "unlock", "on", "chain", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L103-L129
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
is_send_transfer_almost_equal
def is_send_transfer_almost_equal( send_channel: NettingChannelState, send: LockedTransferUnsignedState, received: LockedTransferSignedState, ) -> bool: """ True if both transfers are for the same mediated transfer. """ # The only thing that may change is the direction of the transfer ...
python
def is_send_transfer_almost_equal( send_channel: NettingChannelState, send: LockedTransferUnsignedState, received: LockedTransferSignedState, ) -> bool: """ True if both transfers are for the same mediated transfer. """ # The only thing that may change is the direction of the transfer ...
[ "def", "is_send_transfer_almost_equal", "(", "send_channel", ":", "NettingChannelState", ",", "send", ":", "LockedTransferUnsignedState", ",", "received", ":", "LockedTransferSignedState", ",", ")", "->", "bool", ":", "# The only thing that may change is the direction of the tr...
True if both transfers are for the same mediated transfer.
[ "True", "if", "both", "transfers", "are", "for", "the", "same", "mediated", "transfer", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L154-L171
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
filter_reachable_routes
def filter_reachable_routes( routes: List[RouteState], nodeaddresses_to_networkstates: NodeNetworkStateMap, ) -> List[RouteState]: """This function makes sure we use reachable routes only.""" reachable_routes = [] for route in routes: node_network_state = nodeaddresses_to_networksta...
python
def filter_reachable_routes( routes: List[RouteState], nodeaddresses_to_networkstates: NodeNetworkStateMap, ) -> List[RouteState]: """This function makes sure we use reachable routes only.""" reachable_routes = [] for route in routes: node_network_state = nodeaddresses_to_networksta...
[ "def", "filter_reachable_routes", "(", "routes", ":", "List", "[", "RouteState", "]", ",", "nodeaddresses_to_networkstates", ":", "NodeNetworkStateMap", ",", ")", "->", "List", "[", "RouteState", "]", ":", "reachable_routes", "=", "[", "]", "for", "route", "in",...
This function makes sure we use reachable routes only.
[ "This", "function", "makes", "sure", "we", "use", "reachable", "routes", "only", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L198-L214
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
filter_used_routes
def filter_used_routes( transfers_pair: List[MediationPairState], routes: List[RouteState], ) -> List[RouteState]: """This function makes sure we filter routes that have already been used. So in a setup like this, we want to make sure that node 2, having tried to route the transfer through ...
python
def filter_used_routes( transfers_pair: List[MediationPairState], routes: List[RouteState], ) -> List[RouteState]: """This function makes sure we filter routes that have already been used. So in a setup like this, we want to make sure that node 2, having tried to route the transfer through ...
[ "def", "filter_used_routes", "(", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", "routes", ":", "List", "[", "RouteState", "]", ",", ")", "->", "List", "[", "RouteState", "]", ":", "channelid_to_route", "=", "{", "r", ".", "channel_ident...
This function makes sure we filter routes that have already been used. So in a setup like this, we want to make sure that node 2, having tried to route the transfer through 3 will also try 5 before sending it backwards to 1 1 -> 2 -> 3 -> 4 v ^ 5 -> 6 -> 7 This function will ...
[ "This", "function", "makes", "sure", "we", "filter", "routes", "that", "have", "already", "been", "used", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L217-L246
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
get_payee_channel
def get_payee_channel( channelidentifiers_to_channels: ChannelMap, transfer_pair: MediationPairState, ) -> Optional[NettingChannelState]: """ Returns the payee channel of a given transfer pair or None if it's not found """ payee_channel_identifier = transfer_pair.payee_transfer.balance_proof.cha...
python
def get_payee_channel( channelidentifiers_to_channels: ChannelMap, transfer_pair: MediationPairState, ) -> Optional[NettingChannelState]: """ Returns the payee channel of a given transfer pair or None if it's not found """ payee_channel_identifier = transfer_pair.payee_transfer.balance_proof.cha...
[ "def", "get_payee_channel", "(", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "transfer_pair", ":", "MediationPairState", ",", ")", "->", "Optional", "[", "NettingChannelState", "]", ":", "payee_channel_identifier", "=", "transfer_pair", ".", "payee_transfer"...
Returns the payee channel of a given transfer pair or None if it's not found
[ "Returns", "the", "payee", "channel", "of", "a", "given", "transfer", "pair", "or", "None", "if", "it", "s", "not", "found" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L249-L255
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
get_payer_channel
def get_payer_channel( channelidentifiers_to_channels: ChannelMap, transfer_pair: MediationPairState, ) -> Optional[NettingChannelState]: """ Returns the payer channel of a given transfer pair or None if it's not found """ payer_channel_identifier = transfer_pair.payer_transfer.balance_proof.cha...
python
def get_payer_channel( channelidentifiers_to_channels: ChannelMap, transfer_pair: MediationPairState, ) -> Optional[NettingChannelState]: """ Returns the payer channel of a given transfer pair or None if it's not found """ payer_channel_identifier = transfer_pair.payer_transfer.balance_proof.cha...
[ "def", "get_payer_channel", "(", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "transfer_pair", ":", "MediationPairState", ",", ")", "->", "Optional", "[", "NettingChannelState", "]", ":", "payer_channel_identifier", "=", "transfer_pair", ".", "payer_transfer"...
Returns the payer channel of a given transfer pair or None if it's not found
[ "Returns", "the", "payer", "channel", "of", "a", "given", "transfer", "pair", "or", "None", "if", "it", "s", "not", "found" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L258-L264
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
get_pending_transfer_pairs
def get_pending_transfer_pairs( transfers_pair: List[MediationPairState], ) -> List[MediationPairState]: """ Return the transfer pairs that are not at a final state. """ pending_pairs = list( pair for pair in transfers_pair if pair.payee_state not in STATE_TRANSFER_FINAL or ...
python
def get_pending_transfer_pairs( transfers_pair: List[MediationPairState], ) -> List[MediationPairState]: """ Return the transfer pairs that are not at a final state. """ pending_pairs = list( pair for pair in transfers_pair if pair.payee_state not in STATE_TRANSFER_FINAL or ...
[ "def", "get_pending_transfer_pairs", "(", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", ")", "->", "List", "[", "MediationPairState", "]", ":", "pending_pairs", "=", "list", "(", "pair", "for", "pair", "in", "transfers_pair", "if", "pair", ...
Return the transfer pairs that are not at a final state.
[ "Return", "the", "transfer", "pairs", "that", "are", "not", "at", "a", "final", "state", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L267-L277
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
get_lock_amount_after_fees
def get_lock_amount_after_fees( lock: HashTimeLockState, payee_channel: NettingChannelState, ) -> PaymentWithFeeAmount: """ Return the lock.amount after fees are taken. Fees are taken only for the outgoing channel, which is the one with collateral locked from this node. """ retu...
python
def get_lock_amount_after_fees( lock: HashTimeLockState, payee_channel: NettingChannelState, ) -> PaymentWithFeeAmount: """ Return the lock.amount after fees are taken. Fees are taken only for the outgoing channel, which is the one with collateral locked from this node. """ retu...
[ "def", "get_lock_amount_after_fees", "(", "lock", ":", "HashTimeLockState", ",", "payee_channel", ":", "NettingChannelState", ",", ")", "->", "PaymentWithFeeAmount", ":", "return", "PaymentWithFeeAmount", "(", "lock", ".", "amount", "-", "payee_channel", ".", "mediati...
Return the lock.amount after fees are taken. Fees are taken only for the outgoing channel, which is the one with collateral locked from this node.
[ "Return", "the", "lock", ".", "amount", "after", "fees", "are", "taken", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L280-L290
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
sanity_check
def sanity_check( state: MediatorTransferState, channelidentifiers_to_channels: ChannelMap, ) -> None: """ Check invariants that must hold. """ # if a transfer is paid we must know the secret all_transfers_states = itertools.chain( (pair.payee_state for pair in state.transfers_pair)...
python
def sanity_check( state: MediatorTransferState, channelidentifiers_to_channels: ChannelMap, ) -> None: """ Check invariants that must hold. """ # if a transfer is paid we must know the secret all_transfers_states = itertools.chain( (pair.payee_state for pair in state.transfers_pair)...
[ "def", "sanity_check", "(", "state", ":", "MediatorTransferState", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", ")", "->", "None", ":", "# if a transfer is paid we must know the secret", "all_transfers_states", "=", "itertools", ".", "chain", "(", "(", ...
Check invariants that must hold.
[ "Check", "invariants", "that", "must", "hold", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L293-L365
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
clear_if_finalized
def clear_if_finalized( iteration: TransitionResult, channelidentifiers_to_channels: ChannelMap, ) -> TransitionResult[MediatorTransferState]: """Clear the mediator task if all the locks have been finalized. A lock is considered finalized if it has been removed from the merkle tree offchain...
python
def clear_if_finalized( iteration: TransitionResult, channelidentifiers_to_channels: ChannelMap, ) -> TransitionResult[MediatorTransferState]: """Clear the mediator task if all the locks have been finalized. A lock is considered finalized if it has been removed from the merkle tree offchain...
[ "def", "clear_if_finalized", "(", "iteration", ":", "TransitionResult", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", ")", "->", "TransitionResult", "[", "MediatorTransferState", "]", ":", "state", "=", "cast", "(", "MediatorTransferState", ",", "iter...
Clear the mediator task if all the locks have been finalized. A lock is considered finalized if it has been removed from the merkle tree offchain, either because the transfer was unlocked or expired, or because the channel was settled on chain and therefore the channel is removed.
[ "Clear", "the", "mediator", "task", "if", "all", "the", "locks", "have", "been", "finalized", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L368-L401
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
forward_transfer_pair
def forward_transfer_pair( payer_transfer: LockedTransferSignedState, available_routes: List['RouteState'], channelidentifiers_to_channels: Dict, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> Tuple[Optional[MediationPairState], List[Event]]: """ Give...
python
def forward_transfer_pair( payer_transfer: LockedTransferSignedState, available_routes: List['RouteState'], channelidentifiers_to_channels: Dict, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> Tuple[Optional[MediationPairState], List[Event]]: """ Give...
[ "def", "forward_transfer_pair", "(", "payer_transfer", ":", "LockedTransferSignedState", ",", "available_routes", ":", "List", "[", "'RouteState'", "]", ",", "channelidentifiers_to_channels", ":", "Dict", ",", "pseudo_random_generator", ":", "random", ".", "Random", ","...
Given a payer transfer tries a new route to proceed with the mediation. Args: payer_transfer: The transfer received from the payer_channel. available_routes: Current available routes that may be used, it's assumed that the routes list is ordered from best to worst. channelidenti...
[ "Given", "a", "payer", "transfer", "tries", "a", "new", "route", "to", "proceed", "with", "the", "mediation", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L438-L496
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
backward_transfer_pair
def backward_transfer_pair( backward_channel: NettingChannelState, payer_transfer: LockedTransferSignedState, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> Tuple[Optional[MediationPairState], List[Event]]: """ Sends a transfer backwards, allowing the previou...
python
def backward_transfer_pair( backward_channel: NettingChannelState, payer_transfer: LockedTransferSignedState, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> Tuple[Optional[MediationPairState], List[Event]]: """ Sends a transfer backwards, allowing the previou...
[ "def", "backward_transfer_pair", "(", "backward_channel", ":", "NettingChannelState", ",", "payer_transfer", ":", "LockedTransferSignedState", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", "block_number", ":", "BlockNumber", ",", ")", "->", "Tuple",...
Sends a transfer backwards, allowing the previous hop to try a new route. When all the routes available for this node failed, send a transfer backwards with the same amount and secrethash, allowing the previous hop to do a retry. Args: backward_channel: The original channel which sent the ...
[ "Sends", "a", "transfer", "backwards", "allowing", "the", "previous", "hop", "to", "try", "a", "new", "route", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L499-L551
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
events_for_expired_pairs
def events_for_expired_pairs( channelidentifiers_to_channels: ChannelMap, transfers_pair: List[MediationPairState], waiting_transfer: Optional[WaitingTransferState], block_number: BlockNumber, ) -> List[Event]: """ Informational events for expired locks. """ pending_transfers_pai...
python
def events_for_expired_pairs( channelidentifiers_to_channels: ChannelMap, transfers_pair: List[MediationPairState], waiting_transfer: Optional[WaitingTransferState], block_number: BlockNumber, ) -> List[Event]: """ Informational events for expired locks. """ pending_transfers_pai...
[ "def", "events_for_expired_pairs", "(", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", "waiting_transfer", ":", "Optional", "[", "WaitingTransferState", "]", ",", "block_number", ":", "BlockN...
Informational events for expired locks.
[ "Informational", "events", "for", "expired", "locks", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L681-L738
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
events_for_secretreveal
def events_for_secretreveal( transfers_pair: List[MediationPairState], secret: Secret, pseudo_random_generator: random.Random, ) -> List[Event]: """ Reveal the secret off-chain. The secret is revealed off-chain even if there is a pending transaction to reveal it on-chain, this allow...
python
def events_for_secretreveal( transfers_pair: List[MediationPairState], secret: Secret, pseudo_random_generator: random.Random, ) -> List[Event]: """ Reveal the secret off-chain. The secret is revealed off-chain even if there is a pending transaction to reveal it on-chain, this allow...
[ "def", "events_for_secretreveal", "(", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", "secret", ":", "Secret", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", ")", "->", "List", "[", "Event", "]", ":", "events", ":", "...
Reveal the secret off-chain. The secret is revealed off-chain even if there is a pending transaction to reveal it on-chain, this allows the unlock to happen off-chain, which is faster. This node is named N, suppose there is a mediated transfer with two refund transfers, one from B and one from C: ...
[ "Reveal", "the", "secret", "off", "-", "chain", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L741-L794
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
events_for_balanceproof
def events_for_balanceproof( channelidentifiers_to_channels: ChannelMap, transfers_pair: List[MediationPairState], pseudo_random_generator: random.Random, block_number: BlockNumber, secret: Secret, secrethash: SecretHash, ) -> List[Event]: """ While it's safe do the o...
python
def events_for_balanceproof( channelidentifiers_to_channels: ChannelMap, transfers_pair: List[MediationPairState], pseudo_random_generator: random.Random, block_number: BlockNumber, secret: Secret, secrethash: SecretHash, ) -> List[Event]: """ While it's safe do the o...
[ "def", "events_for_balanceproof", "(", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", "block_number", ":", "BlockNumber", ",", ...
While it's safe do the off-chain unlock.
[ "While", "it", "s", "safe", "do", "the", "off", "-", "chain", "unlock", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L797-L862
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
events_for_onchain_secretreveal_if_dangerzone
def events_for_onchain_secretreveal_if_dangerzone( channelmap: ChannelMap, secrethash: SecretHash, transfers_pair: List[MediationPairState], block_number: BlockNumber, block_hash: BlockHash, ) -> List[Event]: """ Reveal the secret on-chain if the lock enters the unsafe region...
python
def events_for_onchain_secretreveal_if_dangerzone( channelmap: ChannelMap, secrethash: SecretHash, transfers_pair: List[MediationPairState], block_number: BlockNumber, block_hash: BlockHash, ) -> List[Event]: """ Reveal the secret on-chain if the lock enters the unsafe region...
[ "def", "events_for_onchain_secretreveal_if_dangerzone", "(", "channelmap", ":", "ChannelMap", ",", "secrethash", ":", "SecretHash", ",", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", "block_number", ":", "BlockNumber", ",", "block_hash", ":", "Bl...
Reveal the secret on-chain if the lock enters the unsafe region and the secret is not yet on-chain.
[ "Reveal", "the", "secret", "on", "-", "chain", "if", "the", "lock", "enters", "the", "unsafe", "region", "and", "the", "secret", "is", "not", "yet", "on", "-", "chain", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L865-L933
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
events_for_onchain_secretreveal_if_closed
def events_for_onchain_secretreveal_if_closed( channelmap: ChannelMap, transfers_pair: List[MediationPairState], secret: Secret, secrethash: SecretHash, block_hash: BlockHash, ) -> List[Event]: """ Register the secret on-chain if the payer channel is already closed and th...
python
def events_for_onchain_secretreveal_if_closed( channelmap: ChannelMap, transfers_pair: List[MediationPairState], secret: Secret, secrethash: SecretHash, block_hash: BlockHash, ) -> List[Event]: """ Register the secret on-chain if the payer channel is already closed and th...
[ "def", "events_for_onchain_secretreveal_if_closed", "(", "channelmap", ":", "ChannelMap", ",", "transfers_pair", ":", "List", "[", "MediationPairState", "]", ",", "secret", ":", "Secret", ",", "secrethash", ":", "SecretHash", ",", "block_hash", ":", "BlockHash", ","...
Register the secret on-chain if the payer channel is already closed and the mediator learned the secret off-chain. Balance proofs are not exchanged for closed channels, so there is no reason to wait for the unsafe region to register secret. Note: If the secret is learned before the channel is...
[ "Register", "the", "secret", "on", "-", "chain", "if", "the", "payer", "channel", "is", "already", "closed", "and", "the", "mediator", "learned", "the", "secret", "off", "-", "chain", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L936-L995
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
events_to_remove_expired_locks
def events_to_remove_expired_locks( mediator_state: MediatorTransferState, channelidentifiers_to_channels: ChannelMap, block_number: BlockNumber, pseudo_random_generator: random.Random, ) -> List[Event]: """ Clear the channels which have expired locks. This only considers the *s...
python
def events_to_remove_expired_locks( mediator_state: MediatorTransferState, channelidentifiers_to_channels: ChannelMap, block_number: BlockNumber, pseudo_random_generator: random.Random, ) -> List[Event]: """ Clear the channels which have expired locks. This only considers the *s...
[ "def", "events_to_remove_expired_locks", "(", "mediator_state", ":", "MediatorTransferState", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "block_number", ":", "BlockNumber", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", ")", "->", ...
Clear the channels which have expired locks. This only considers the *sent* transfers, received transfers can only be updated by the partner.
[ "Clear", "the", "channels", "which", "have", "expired", "locks", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L998-L1053
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
secret_learned
def secret_learned( state: MediatorTransferState, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, block_number: BlockNumber, block_hash: BlockHash, secret: Secret, secrethash: SecretHash, payee_address: Address, ) -> Tra...
python
def secret_learned( state: MediatorTransferState, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, block_number: BlockNumber, block_hash: BlockHash, secret: Secret, secrethash: SecretHash, payee_address: Address, ) -> Tra...
[ "def", "secret_learned", "(", "state", ":", "MediatorTransferState", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", "block_number", ":", "BlockNumber", ",", "block_hash", ":", "BlockHash", "...
Unlock the payee lock, reveal the lock to the payer, and if necessary register the secret on-chain.
[ "Unlock", "the", "payee", "lock", "reveal", "the", "lock", "to", "the", "payer", "and", "if", "necessary", "register", "the", "secret", "on", "-", "chain", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L1056-L1107
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
mediate_transfer
def mediate_transfer( state: MediatorTransferState, possible_routes: List['RouteState'], payer_channel: NettingChannelState, channelidentifiers_to_channels: ChannelMap, nodeaddresses_to_networkstates: NodeNetworkStateMap, pseudo_random_generator: random.Random, pa...
python
def mediate_transfer( state: MediatorTransferState, possible_routes: List['RouteState'], payer_channel: NettingChannelState, channelidentifiers_to_channels: ChannelMap, nodeaddresses_to_networkstates: NodeNetworkStateMap, pseudo_random_generator: random.Random, pa...
[ "def", "mediate_transfer", "(", "state", ":", "MediatorTransferState", ",", "possible_routes", ":", "List", "[", "'RouteState'", "]", ",", "payer_channel", ":", "NettingChannelState", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "nodeaddresses_to_network...
Try a new route or fail back to a refund. The mediator can safely try a new route knowing that the tokens from payer_transfer will cover the expenses of the mediation. If there is no route available that may be used at the moment of the call the mediator may send a refund back to the payer, allowing th...
[ "Try", "a", "new", "route", "or", "fail", "back", "to", "a", "refund", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L1110-L1180
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
handle_onchain_secretreveal
def handle_onchain_secretreveal( mediator_state: MediatorTransferState, onchain_secret_reveal: ContractReceiveSecretReveal, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> TransitionResult[MediatorTransferState]:...
python
def handle_onchain_secretreveal( mediator_state: MediatorTransferState, onchain_secret_reveal: ContractReceiveSecretReveal, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> TransitionResult[MediatorTransferState]:...
[ "def", "handle_onchain_secretreveal", "(", "mediator_state", ":", "MediatorTransferState", ",", "onchain_secret_reveal", ":", "ContractReceiveSecretReveal", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "pseudo_random_generator", ":", "random", ".", "Random", ...
The secret was revealed on-chain, set the state of all transfers to secret known.
[ "The", "secret", "was", "revealed", "on", "-", "chain", "set", "the", "state", "of", "all", "transfers", "to", "secret", "known", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L1384-L1426
train
raiden-network/raiden
raiden/transfer/mediated_transfer/mediator.py
handle_unlock
def handle_unlock( mediator_state: MediatorTransferState, state_change: ReceiveUnlock, channelidentifiers_to_channels: ChannelMap, ) -> TransitionResult[MediatorTransferState]: """ Handle a ReceiveUnlock state change. """ events = list() balance_proof_sender = state_change.balance_pr...
python
def handle_unlock( mediator_state: MediatorTransferState, state_change: ReceiveUnlock, channelidentifiers_to_channels: ChannelMap, ) -> TransitionResult[MediatorTransferState]: """ Handle a ReceiveUnlock state change. """ events = list() balance_proof_sender = state_change.balance_pr...
[ "def", "handle_unlock", "(", "mediator_state", ":", "MediatorTransferState", ",", "state_change", ":", "ReceiveUnlock", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", ")", "->", "TransitionResult", "[", "MediatorTransferState", "]", ":", "events", "=", ...
Handle a ReceiveUnlock state change.
[ "Handle", "a", "ReceiveUnlock", "state", "change", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L1429-L1467
train
raiden-network/raiden
raiden/network/proxies/service_registry.py
ServiceRegistry.service_count
def service_count(self, block_identifier: BlockSpecification) -> int: """Get the number of registered services""" result = self.proxy.contract.functions.serviceCount().call( block_identifier=block_identifier, ) return result
python
def service_count(self, block_identifier: BlockSpecification) -> int: """Get the number of registered services""" result = self.proxy.contract.functions.serviceCount().call( block_identifier=block_identifier, ) return result
[ "def", "service_count", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ")", "->", "int", ":", "result", "=", "self", ".", "proxy", ".", "contract", ".", "functions", ".", "serviceCount", "(", ")", ".", "call", "(", "block_identifier", "=", ...
Get the number of registered services
[ "Get", "the", "number", "of", "registered", "services" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/service_registry.py#L46-L51
train
raiden-network/raiden
raiden/network/proxies/service_registry.py
ServiceRegistry.get_service_address
def get_service_address( self, block_identifier: BlockSpecification, index: int, ) -> Optional[AddressHex]: """Gets the address of a service by index. If index is out of range return None""" try: result = self.proxy.contract.functions.service_addresses...
python
def get_service_address( self, block_identifier: BlockSpecification, index: int, ) -> Optional[AddressHex]: """Gets the address of a service by index. If index is out of range return None""" try: result = self.proxy.contract.functions.service_addresses...
[ "def", "get_service_address", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ",", "index", ":", "int", ",", ")", "->", "Optional", "[", "AddressHex", "]", ":", "try", ":", "result", "=", "self", ".", "proxy", ".", "contract", ".", "functi...
Gets the address of a service by index. If index is out of range return None
[ "Gets", "the", "address", "of", "a", "service", "by", "index", ".", "If", "index", "is", "out", "of", "range", "return", "None" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/service_registry.py#L53-L65
train
raiden-network/raiden
raiden/network/proxies/service_registry.py
ServiceRegistry.get_service_url
def get_service_url( self, block_identifier: BlockSpecification, service_hex_address: AddressHex, ) -> Optional[str]: """Gets the URL of a service by address. If does not exist return None""" result = self.proxy.contract.functions.urls(service_hex_address).call( ...
python
def get_service_url( self, block_identifier: BlockSpecification, service_hex_address: AddressHex, ) -> Optional[str]: """Gets the URL of a service by address. If does not exist return None""" result = self.proxy.contract.functions.urls(service_hex_address).call( ...
[ "def", "get_service_url", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ",", "service_hex_address", ":", "AddressHex", ",", ")", "->", "Optional", "[", "str", "]", ":", "result", "=", "self", ".", "proxy", ".", "contract", ".", "functions", ...
Gets the URL of a service by address. If does not exist return None
[ "Gets", "the", "URL", "of", "a", "service", "by", "address", ".", "If", "does", "not", "exist", "return", "None" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/service_registry.py#L67-L78
train
raiden-network/raiden
raiden/network/proxies/service_registry.py
ServiceRegistry.set_url
def set_url(self, url: str): """Sets the url needed to access the service via HTTP for the caller""" gas_limit = self.proxy.estimate_gas('latest', 'setURL', url) transaction_hash = self.proxy.transact('setURL', gas_limit, url) self.client.poll(transaction_hash) assert not check_t...
python
def set_url(self, url: str): """Sets the url needed to access the service via HTTP for the caller""" gas_limit = self.proxy.estimate_gas('latest', 'setURL', url) transaction_hash = self.proxy.transact('setURL', gas_limit, url) self.client.poll(transaction_hash) assert not check_t...
[ "def", "set_url", "(", "self", ",", "url", ":", "str", ")", ":", "gas_limit", "=", "self", ".", "proxy", ".", "estimate_gas", "(", "'latest'", ",", "'setURL'", ",", "url", ")", "transaction_hash", "=", "self", ".", "proxy", ".", "transact", "(", "'setU...
Sets the url needed to access the service via HTTP for the caller
[ "Sets", "the", "url", "needed", "to", "access", "the", "service", "via", "HTTP", "for", "the", "caller" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/service_registry.py#L80-L85
train
raiden-network/raiden
raiden/utils/signer.py
recover
def recover( data: bytes, signature: Signature, hasher: Callable[[bytes], bytes] = eth_sign_sha3, ) -> Address: """ eth_recover address from data hash and signature """ _hash = hasher(data) # ecdsa_recover accepts only standard [0,1] v's so we add support also for [27,28] here #...
python
def recover( data: bytes, signature: Signature, hasher: Callable[[bytes], bytes] = eth_sign_sha3, ) -> Address: """ eth_recover address from data hash and signature """ _hash = hasher(data) # ecdsa_recover accepts only standard [0,1] v's so we add support also for [27,28] here #...
[ "def", "recover", "(", "data", ":", "bytes", ",", "signature", ":", "Signature", ",", "hasher", ":", "Callable", "[", "[", "bytes", "]", ",", "bytes", "]", "=", "eth_sign_sha3", ",", ")", "->", "Address", ":", "_hash", "=", "hasher", "(", "data", ")"...
eth_recover address from data hash and signature
[ "eth_recover", "address", "from", "data", "hash", "and", "signature" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/signer.py#L23-L41
train
raiden-network/raiden
raiden/utils/signer.py
LocalSigner.sign
def sign(self, data: bytes, v: int = 27) -> Signature: """ Sign data hash with local private key """ assert v in (0, 27), 'Raiden is only signing messages with v in (0, 27)' _hash = eth_sign_sha3(data) signature = self.private_key.sign_msg_hash(message_hash=_hash) sig_bytes = sig...
python
def sign(self, data: bytes, v: int = 27) -> Signature: """ Sign data hash with local private key """ assert v in (0, 27), 'Raiden is only signing messages with v in (0, 27)' _hash = eth_sign_sha3(data) signature = self.private_key.sign_msg_hash(message_hash=_hash) sig_bytes = sig...
[ "def", "sign", "(", "self", ",", "data", ":", "bytes", ",", "v", ":", "int", "=", "27", ")", "->", "Signature", ":", "assert", "v", "in", "(", "0", ",", "27", ")", ",", "'Raiden is only signing messages with v in (0, 27)'", "_hash", "=", "eth_sign_sha3", ...
Sign data hash with local private key
[ "Sign", "data", "hash", "with", "local", "private", "key" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/signer.py#L83-L90
train
raiden-network/raiden
raiden/network/proxies/token.py
Token.approve
def approve( self, allowed_address: Address, allowance: TokenAmount, ): """ Aprove `allowed_address` to transfer up to `deposit` amount of token. Note: For channel deposit please use the channel proxy, since it does additional validations...
python
def approve( self, allowed_address: Address, allowance: TokenAmount, ): """ Aprove `allowed_address` to transfer up to `deposit` amount of token. Note: For channel deposit please use the channel proxy, since it does additional validations...
[ "def", "approve", "(", "self", ",", "allowed_address", ":", "Address", ",", "allowance", ":", "TokenAmount", ",", ")", ":", "# Note that given_block_identifier is not used here as there", "# are no preconditions to check before sending the transaction", "log_details", "=", "{",...
Aprove `allowed_address` to transfer up to `deposit` amount of token. Note: For channel deposit please use the channel proxy, since it does additional validations.
[ "Aprove", "allowed_address", "to", "transfer", "up", "to", "deposit", "amount", "of", "token", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token.py#L49-L112
train
raiden-network/raiden
raiden/network/proxies/token.py
Token.balance_of
def balance_of(self, address, block_identifier='latest'): """ Return the balance of `address`. """ return self.proxy.contract.functions.balanceOf( to_checksum_address(address), ).call(block_identifier=block_identifier)
python
def balance_of(self, address, block_identifier='latest'): """ Return the balance of `address`. """ return self.proxy.contract.functions.balanceOf( to_checksum_address(address), ).call(block_identifier=block_identifier)
[ "def", "balance_of", "(", "self", ",", "address", ",", "block_identifier", "=", "'latest'", ")", ":", "return", "self", ".", "proxy", ".", "contract", ".", "functions", ".", "balanceOf", "(", "to_checksum_address", "(", "address", ")", ",", ")", ".", "call...
Return the balance of `address`.
[ "Return", "the", "balance", "of", "address", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token.py#L158-L162
train
raiden-network/raiden
raiden/network/proxies/token.py
Token.total_supply
def total_supply(self, block_identifier='latest'): """ Return the total supply of the token at the given block identifier. """ return self.proxy.contract.functions.totalSupply().call(block_identifier=block_identifier)
python
def total_supply(self, block_identifier='latest'): """ Return the total supply of the token at the given block identifier. """ return self.proxy.contract.functions.totalSupply().call(block_identifier=block_identifier)
[ "def", "total_supply", "(", "self", ",", "block_identifier", "=", "'latest'", ")", ":", "return", "self", ".", "proxy", ".", "contract", ".", "functions", ".", "totalSupply", "(", ")", ".", "call", "(", "block_identifier", "=", "block_identifier", ")" ]
Return the total supply of the token at the given block identifier.
[ "Return", "the", "total", "supply", "of", "the", "token", "at", "the", "given", "block", "identifier", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token.py#L164-L166
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator_manager.py
clear_if_finalized
def clear_if_finalized( iteration: TransitionResult, ) -> TransitionResult[InitiatorPaymentState]: """ Clear the initiator payment task if all transfers have been finalized or expired. """ state = cast(InitiatorPaymentState, iteration.new_state) if state is None: return iteration i...
python
def clear_if_finalized( iteration: TransitionResult, ) -> TransitionResult[InitiatorPaymentState]: """ Clear the initiator payment task if all transfers have been finalized or expired. """ state = cast(InitiatorPaymentState, iteration.new_state) if state is None: return iteration i...
[ "def", "clear_if_finalized", "(", "iteration", ":", "TransitionResult", ",", ")", "->", "TransitionResult", "[", "InitiatorPaymentState", "]", ":", "state", "=", "cast", "(", "InitiatorPaymentState", ",", "iteration", ".", "new_state", ")", "if", "state", "is", ...
Clear the initiator payment task if all transfers have been finalized or expired.
[ "Clear", "the", "initiator", "payment", "task", "if", "all", "transfers", "have", "been", "finalized", "or", "expired", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator_manager.py#L34-L47
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator_manager.py
cancel_current_route
def cancel_current_route( payment_state: InitiatorPaymentState, initiator_state: InitiatorTransferState, ) -> List[Event]: """ Cancel current route. This allows a new route to be tried. """ assert can_cancel(initiator_state), 'Cannot cancel a route after the secret is revealed' tra...
python
def cancel_current_route( payment_state: InitiatorPaymentState, initiator_state: InitiatorTransferState, ) -> List[Event]: """ Cancel current route. This allows a new route to be tried. """ assert can_cancel(initiator_state), 'Cannot cancel a route after the secret is revealed' tra...
[ "def", "cancel_current_route", "(", "payment_state", ":", "InitiatorPaymentState", ",", "initiator_state", ":", "InitiatorTransferState", ",", ")", "->", "List", "[", "Event", "]", ":", "assert", "can_cancel", "(", "initiator_state", ")", ",", "'Cannot cancel a route ...
Cancel current route. This allows a new route to be tried.
[ "Cancel", "current", "route", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator_manager.py#L81-L95
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator_manager.py
subdispatch_to_all_initiatortransfer
def subdispatch_to_all_initiatortransfer( payment_state: InitiatorPaymentState, state_change: StateChange, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, ) -> TransitionResult[InitiatorPaymentState]: events = list() ''' Copy and iterate over t...
python
def subdispatch_to_all_initiatortransfer( payment_state: InitiatorPaymentState, state_change: StateChange, channelidentifiers_to_channels: ChannelMap, pseudo_random_generator: random.Random, ) -> TransitionResult[InitiatorPaymentState]: events = list() ''' Copy and iterate over t...
[ "def", "subdispatch_to_all_initiatortransfer", "(", "payment_state", ":", "InitiatorPaymentState", ",", "state_change", ":", "StateChange", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", ")", "-...
Copy and iterate over the list of keys because this loop will alter the `initiator_transfers` list and this is not allowed if iterating over the original list.
[ "Copy", "and", "iterate", "over", "the", "list", "of", "keys", "because", "this", "loop", "will", "alter", "the", "initiator_transfers", "list", "and", "this", "is", "not", "allowed", "if", "iterating", "over", "the", "original", "list", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator_manager.py#L163-L184
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator_manager.py
handle_cancelpayment
def handle_cancelpayment( payment_state: InitiatorPaymentState, channelidentifiers_to_channels: ChannelMap, ) -> TransitionResult[InitiatorPaymentState]: """ Cancel the payment and all related transfers. """ # Cannot cancel a transfer after the secret is revealed events = list() for init...
python
def handle_cancelpayment( payment_state: InitiatorPaymentState, channelidentifiers_to_channels: ChannelMap, ) -> TransitionResult[InitiatorPaymentState]: """ Cancel the payment and all related transfers. """ # Cannot cancel a transfer after the secret is revealed events = list() for init...
[ "def", "handle_cancelpayment", "(", "payment_state", ":", "InitiatorPaymentState", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", ")", "->", "TransitionResult", "[", "InitiatorPaymentState", "]", ":", "# Cannot cancel a transfer after the secret is revealed", "e...
Cancel the payment and all related transfers.
[ "Cancel", "the", "payment", "and", "all", "related", "transfers", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator_manager.py#L232-L263
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator_manager.py
handle_lock_expired
def handle_lock_expired( payment_state: InitiatorPaymentState, state_change: ReceiveLockExpired, channelidentifiers_to_channels: ChannelMap, block_number: BlockNumber, ) -> TransitionResult[InitiatorPaymentState]: """Initiator also needs to handle LockExpired messages when refund tra...
python
def handle_lock_expired( payment_state: InitiatorPaymentState, state_change: ReceiveLockExpired, channelidentifiers_to_channels: ChannelMap, block_number: BlockNumber, ) -> TransitionResult[InitiatorPaymentState]: """Initiator also needs to handle LockExpired messages when refund tra...
[ "def", "handle_lock_expired", "(", "payment_state", ":", "InitiatorPaymentState", ",", "state_change", ":", "ReceiveLockExpired", ",", "channelidentifiers_to_channels", ":", "ChannelMap", ",", "block_number", ":", "BlockNumber", ",", ")", "->", "TransitionResult", "[", ...
Initiator also needs to handle LockExpired messages when refund transfers are involved. A -> B -> C - A sends locked transfer to B - B attempted to forward to C but has not enough capacity - B sends a refund transfer with the same secrethash back to A - When the lock expires B will also send a Loc...
[ "Initiator", "also", "needs", "to", "handle", "LockExpired", "messages", "when", "refund", "transfers", "are", "involved", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator_manager.py#L340-L385
train
raiden-network/raiden
raiden/network/rpc/middleware.py
http_retry_with_backoff_middleware
def http_retry_with_backoff_middleware( make_request, web3, # pylint: disable=unused-argument errors: Tuple = ( exceptions.ConnectionError, exceptions.HTTPError, exceptions.Timeout, exceptions.TooManyRedirects, ), retries: int = 10...
python
def http_retry_with_backoff_middleware( make_request, web3, # pylint: disable=unused-argument errors: Tuple = ( exceptions.ConnectionError, exceptions.HTTPError, exceptions.Timeout, exceptions.TooManyRedirects, ), retries: int = 10...
[ "def", "http_retry_with_backoff_middleware", "(", "make_request", ",", "web3", ",", "# pylint: disable=unused-argument", "errors", ":", "Tuple", "=", "(", "exceptions", ".", "ConnectionError", ",", "exceptions", ".", "HTTPError", ",", "exceptions", ".", "Timeout", ","...
Retry requests with exponential backoff Creates middleware that retries failed HTTP requests and exponentially increases the backoff between retries. Meant to replace the default middleware `http_retry_request_middleware` for HTTPProvider.
[ "Retry", "requests", "with", "exponential", "backoff", "Creates", "middleware", "that", "retries", "failed", "HTTP", "requests", "and", "exponentially", "increases", "the", "backoff", "between", "retries", ".", "Meant", "to", "replace", "the", "default", "middleware...
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/middleware.py#L52-L86
train
raiden-network/raiden
raiden/network/pathfinding.py
get_random_service
def get_random_service( service_registry: ServiceRegistry, block_identifier: BlockSpecification, ) -> Tuple[Optional[str], Optional[str]]: """Selects a random PFS from service_registry. Returns a tuple of the chosen services url and eth address. If there are no PFS in the given registry, it...
python
def get_random_service( service_registry: ServiceRegistry, block_identifier: BlockSpecification, ) -> Tuple[Optional[str], Optional[str]]: """Selects a random PFS from service_registry. Returns a tuple of the chosen services url and eth address. If there are no PFS in the given registry, it...
[ "def", "get_random_service", "(", "service_registry", ":", "ServiceRegistry", ",", "block_identifier", ":", "BlockSpecification", ",", ")", "->", "Tuple", "[", "Optional", "[", "str", "]", ",", "Optional", "[", "str", "]", "]", ":", "count", "=", "service_regi...
Selects a random PFS from service_registry. Returns a tuple of the chosen services url and eth address. If there are no PFS in the given registry, it returns (None, None).
[ "Selects", "a", "random", "PFS", "from", "service_registry", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/pathfinding.py#L81-L106
train
raiden-network/raiden
raiden/network/pathfinding.py
configure_pfs_or_exit
def configure_pfs_or_exit( pfs_address: Optional[str], pfs_eth_address: Optional[str], routing_mode: RoutingMode, service_registry, ) -> Optional[PFSConfiguration]: """ Take in the given pfs_address argument, the service registry and find out a pfs address to use. If pfs...
python
def configure_pfs_or_exit( pfs_address: Optional[str], pfs_eth_address: Optional[str], routing_mode: RoutingMode, service_registry, ) -> Optional[PFSConfiguration]: """ Take in the given pfs_address argument, the service registry and find out a pfs address to use. If pfs...
[ "def", "configure_pfs_or_exit", "(", "pfs_address", ":", "Optional", "[", "str", "]", ",", "pfs_eth_address", ":", "Optional", "[", "str", "]", ",", "routing_mode", ":", "RoutingMode", ",", "service_registry", ",", ")", "->", "Optional", "[", "PFSConfiguration",...
Take in the given pfs_address argument, the service registry and find out a pfs address to use. If pfs_address is None then basic routing must have been requested. If pfs_address is provided we use that. If pfs_address is 'auto' then we randomly choose a PFS address from the registry Returns a Nam...
[ "Take", "in", "the", "given", "pfs_address", "argument", "the", "service", "registry", "and", "find", "out", "a", "pfs", "address", "to", "use", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/pathfinding.py#L132-L192
train
raiden-network/raiden
raiden/network/pathfinding.py
query_paths
def query_paths( service_config: Dict[str, Any], our_address: Address, privkey: bytes, current_block_number: BlockNumber, token_network_address: Union[TokenNetworkAddress, TokenNetworkID], route_from: InitiatorAddress, route_to: TargetAddress, value: Payme...
python
def query_paths( service_config: Dict[str, Any], our_address: Address, privkey: bytes, current_block_number: BlockNumber, token_network_address: Union[TokenNetworkAddress, TokenNetworkID], route_from: InitiatorAddress, route_to: TargetAddress, value: Payme...
[ "def", "query_paths", "(", "service_config", ":", "Dict", "[", "str", ",", "Any", "]", ",", "our_address", ":", "Address", ",", "privkey", ":", "bytes", ",", "current_block_number", ":", "BlockNumber", ",", "token_network_address", ":", "Union", "[", "TokenNet...
Query paths from the PFS. Send a request to the /paths endpoint of the PFS specified in service_config, and retry in case of a failed request if it makes sense.
[ "Query", "paths", "from", "the", "PFS", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/pathfinding.py#L362-L421
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
single_queue_send
def single_queue_send( transport: 'UDPTransport', recipient: Address, queue: Queue_T, queue_identifier: QueueIdentifier, event_stop: Event, event_healthy: Event, event_unhealthy: Event, message_retries: int, message_retry_timeout: int, mess...
python
def single_queue_send( transport: 'UDPTransport', recipient: Address, queue: Queue_T, queue_identifier: QueueIdentifier, event_stop: Event, event_healthy: Event, event_unhealthy: Event, message_retries: int, message_retry_timeout: int, mess...
[ "def", "single_queue_send", "(", "transport", ":", "'UDPTransport'", ",", "recipient", ":", "Address", ",", "queue", ":", "Queue_T", ",", "queue_identifier", ":", "QueueIdentifier", ",", "event_stop", ":", "Event", ",", "event_healthy", ":", "Event", ",", "event...
Handles a single message queue for `recipient`. Notes: - This task must be the only consumer of queue. - This task can be killed at any time, but the intended usage is to stop it with the event_stop. - If there are many queues for the same recipient, it is the caller's responsibility to not...
[ "Handles", "a", "single", "message", "queue", "for", "recipient", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L57-L163
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.get_health_events
def get_health_events(self, recipient): """ Starts a healthcheck task for `recipient` and returns a HealthEvents with locks to react on its current state. """ if recipient not in self.addresses_events: self.start_health_check(recipient) return self.addresses_events[r...
python
def get_health_events(self, recipient): """ Starts a healthcheck task for `recipient` and returns a HealthEvents with locks to react on its current state. """ if recipient not in self.addresses_events: self.start_health_check(recipient) return self.addresses_events[r...
[ "def", "get_health_events", "(", "self", ",", "recipient", ")", ":", "if", "recipient", "not", "in", "self", ".", "addresses_events", ":", "self", ".", "start_health_check", "(", "recipient", ")", "return", "self", ".", "addresses_events", "[", "recipient", "]...
Starts a healthcheck task for `recipient` and returns a HealthEvents with locks to react on its current state.
[ "Starts", "a", "healthcheck", "task", "for", "recipient", "and", "returns", "a", "HealthEvents", "with", "locks", "to", "react", "on", "its", "current", "state", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L287-L294
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.start_health_check
def start_health_check(self, recipient): """ Starts a task for healthchecking `recipient` if there is not one yet. It also whitelists the address """ if recipient not in self.addresses_events: self.whitelist(recipient) # noop for now, for compatibility p...
python
def start_health_check(self, recipient): """ Starts a task for healthchecking `recipient` if there is not one yet. It also whitelists the address """ if recipient not in self.addresses_events: self.whitelist(recipient) # noop for now, for compatibility p...
[ "def", "start_health_check", "(", "self", ",", "recipient", ")", ":", "if", "recipient", "not", "in", "self", ".", "addresses_events", ":", "self", ".", "whitelist", "(", "recipient", ")", "# noop for now, for compatibility", "ping_nonce", "=", "self", ".", "nod...
Starts a task for healthchecking `recipient` if there is not one yet. It also whitelists the address
[ "Starts", "a", "task", "for", "healthchecking", "recipient", "if", "there", "is", "not", "one", "yet", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L305-L339
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.init_queue_for
def init_queue_for( self, queue_identifier: QueueIdentifier, items: List[QueueItem_T], ) -> NotifyingQueue: """ Create the queue identified by the queue_identifier and initialize it with `items`. """ recipient = queue_identifier.recipient q...
python
def init_queue_for( self, queue_identifier: QueueIdentifier, items: List[QueueItem_T], ) -> NotifyingQueue: """ Create the queue identified by the queue_identifier and initialize it with `items`. """ recipient = queue_identifier.recipient q...
[ "def", "init_queue_for", "(", "self", ",", "queue_identifier", ":", "QueueIdentifier", ",", "items", ":", "List", "[", "QueueItem_T", "]", ",", ")", "->", "NotifyingQueue", ":", "recipient", "=", "queue_identifier", ".", "recipient", "queue", "=", "self", ".",...
Create the queue identified by the queue_identifier and initialize it with `items`.
[ "Create", "the", "queue", "identified", "by", "the", "queue_identifier", "and", "initialize", "it", "with", "items", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L341-L388
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.get_queue_for
def get_queue_for( self, queue_identifier: QueueIdentifier, ) -> NotifyingQueue: """ Return the queue identified by the given queue identifier. If the queue doesn't exist it will be instantiated. """ queue = self.queueids_to_queues.get(queue_identifier) ...
python
def get_queue_for( self, queue_identifier: QueueIdentifier, ) -> NotifyingQueue: """ Return the queue identified by the given queue identifier. If the queue doesn't exist it will be instantiated. """ queue = self.queueids_to_queues.get(queue_identifier) ...
[ "def", "get_queue_for", "(", "self", ",", "queue_identifier", ":", "QueueIdentifier", ",", ")", "->", "NotifyingQueue", ":", "queue", "=", "self", ".", "queueids_to_queues", ".", "get", "(", "queue_identifier", ")", "if", "queue", "is", "None", ":", "items", ...
Return the queue identified by the given queue identifier. If the queue doesn't exist it will be instantiated.
[ "Return", "the", "queue", "identified", "by", "the", "given", "queue", "identifier", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L390-L404
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.send_async
def send_async( self, queue_identifier: QueueIdentifier, message: Message, ): """ Send a new ordered message to recipient. Messages that use the same `queue_identifier` are ordered. """ recipient = queue_identifier.recipient if not is_bina...
python
def send_async( self, queue_identifier: QueueIdentifier, message: Message, ): """ Send a new ordered message to recipient. Messages that use the same `queue_identifier` are ordered. """ recipient = queue_identifier.recipient if not is_bina...
[ "def", "send_async", "(", "self", ",", "queue_identifier", ":", "QueueIdentifier", ",", "message", ":", "Message", ",", ")", ":", "recipient", "=", "queue_identifier", ".", "recipient", "if", "not", "is_binary_address", "(", "recipient", ")", ":", "raise", "Va...
Send a new ordered message to recipient. Messages that use the same `queue_identifier` are ordered.
[ "Send", "a", "new", "ordered", "message", "to", "recipient", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L406-L445
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.receive
def receive( self, messagedata: bytes, host_port: Tuple[str, int], # pylint: disable=unused-argument ) -> bool: """ Handle an UDP packet. """ # pylint: disable=unidiomatic-typecheck if len(messagedata) > self.UDP_MAX_MESSAGE_SIZE: self.log.wa...
python
def receive( self, messagedata: bytes, host_port: Tuple[str, int], # pylint: disable=unused-argument ) -> bool: """ Handle an UDP packet. """ # pylint: disable=unidiomatic-typecheck if len(messagedata) > self.UDP_MAX_MESSAGE_SIZE: self.log.wa...
[ "def", "receive", "(", "self", ",", "messagedata", ":", "bytes", ",", "host_port", ":", "Tuple", "[", "str", ",", "int", "]", ",", "# pylint: disable=unused-argument", ")", "->", "bool", ":", "# pylint: disable=unidiomatic-typecheck", "if", "len", "(", "messaged...
Handle an UDP packet.
[ "Handle", "an", "UDP", "packet", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L506-L550
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.receive_message
def receive_message(self, message: Message): """ Handle a Raiden protocol message. The protocol requires durability of the messages. The UDP transport relies on the node's WAL for durability. The message will be converted to a state change, saved to the WAL, and *processed* before the ...
python
def receive_message(self, message: Message): """ Handle a Raiden protocol message. The protocol requires durability of the messages. The UDP transport relies on the node's WAL for durability. The message will be converted to a state change, saved to the WAL, and *processed* before the ...
[ "def", "receive_message", "(", "self", ",", "message", ":", "Message", ")", ":", "self", ".", "raiden", ".", "on_message", "(", "message", ")", "# Sending Delivered after the message is decoded and *processed*", "# gives a stronger guarantee than what is required from a", "# ...
Handle a Raiden protocol message. The protocol requires durability of the messages. The UDP transport relies on the node's WAL for durability. The message will be converted to a state change, saved to the WAL, and *processed* before the durability is confirmed, which is a stronger prope...
[ "Handle", "a", "Raiden", "protocol", "message", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L552-L579
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.receive_delivered
def receive_delivered(self, delivered: Delivered): """ Handle a Delivered message. The Delivered message is how the UDP transport guarantees persistence by the partner node. The message itself is not part of the raiden protocol, but it's required by this transport to provide the require...
python
def receive_delivered(self, delivered: Delivered): """ Handle a Delivered message. The Delivered message is how the UDP transport guarantees persistence by the partner node. The message itself is not part of the raiden protocol, but it's required by this transport to provide the require...
[ "def", "receive_delivered", "(", "self", ",", "delivered", ":", "Delivered", ")", ":", "self", ".", "raiden", ".", "on_message", "(", "delivered", ")", "message_id", "=", "delivered", ".", "delivered_message_identifier", "async_result", "=", "self", ".", "raiden...
Handle a Delivered message. The Delivered message is how the UDP transport guarantees persistence by the partner node. The message itself is not part of the raiden protocol, but it's required by this transport to provide the required properties.
[ "Handle", "a", "Delivered", "message", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L581-L602
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.receive_ping
def receive_ping(self, ping: Ping): """ Handle a Ping message by answering with a Pong. """ self.log_healthcheck.debug( 'Ping received', message_id=ping.nonce, message=ping, sender=pex(ping.sender), ) pong = Pong(nonce=ping.nonce) ...
python
def receive_ping(self, ping: Ping): """ Handle a Ping message by answering with a Pong. """ self.log_healthcheck.debug( 'Ping received', message_id=ping.nonce, message=ping, sender=pex(ping.sender), ) pong = Pong(nonce=ping.nonce) ...
[ "def", "receive_ping", "(", "self", ",", "ping", ":", "Ping", ")", ":", "self", ".", "log_healthcheck", ".", "debug", "(", "'Ping received'", ",", "message_id", "=", "ping", ".", "nonce", ",", "message", "=", "ping", ",", "sender", "=", "pex", "(", "pi...
Handle a Ping message by answering with a Pong.
[ "Handle", "a", "Ping", "message", "by", "answering", "with", "a", "Pong", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L607-L623
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.receive_pong
def receive_pong(self, pong: Pong): """ Handles a Pong message. """ message_id = ('ping', pong.nonce, pong.sender) async_result = self.messageids_to_asyncresults.get(message_id) if async_result is not None: self.log_healthcheck.debug( 'Pong received', ...
python
def receive_pong(self, pong: Pong): """ Handles a Pong message. """ message_id = ('ping', pong.nonce, pong.sender) async_result = self.messageids_to_asyncresults.get(message_id) if async_result is not None: self.log_healthcheck.debug( 'Pong received', ...
[ "def", "receive_pong", "(", "self", ",", "pong", ":", "Pong", ")", ":", "message_id", "=", "(", "'ping'", ",", "pong", ".", "nonce", ",", "pong", ".", "sender", ")", "async_result", "=", "self", ".", "messageids_to_asyncresults", ".", "get", "(", "messag...
Handles a Pong message.
[ "Handles", "a", "Pong", "message", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L625-L644
train
raiden-network/raiden
raiden/network/transport/udp/udp_transport.py
UDPTransport.get_ping
def get_ping(self, nonce: Nonce) -> bytes: """ Returns a signed Ping message. Note: Ping messages don't have an enforced ordering, so a Ping message with a higher nonce may be acknowledged first. """ message = Ping( nonce=nonce, current_protocol_version=c...
python
def get_ping(self, nonce: Nonce) -> bytes: """ Returns a signed Ping message. Note: Ping messages don't have an enforced ordering, so a Ping message with a higher nonce may be acknowledged first. """ message = Ping( nonce=nonce, current_protocol_version=c...
[ "def", "get_ping", "(", "self", ",", "nonce", ":", "Nonce", ")", "->", "bytes", ":", "message", "=", "Ping", "(", "nonce", "=", "nonce", ",", "current_protocol_version", "=", "constants", ".", "PROTOCOL_VERSION", ",", ")", "self", ".", "raiden", ".", "si...
Returns a signed Ping message. Note: Ping messages don't have an enforced ordering, so a Ping message with a higher nonce may be acknowledged first.
[ "Returns", "a", "signed", "Ping", "message", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_transport.py#L646-L657
train
raiden-network/raiden
raiden/utils/cli.py
apply_config_file
def apply_config_file( command_function: Union[click.Command, click.Group], cli_params: Dict[str, Any], ctx, config_file_option_name='config_file', ): """ Applies all options set in the config file to `cli_params` """ paramname_to_param = {param.name: param for param in command_f...
python
def apply_config_file( command_function: Union[click.Command, click.Group], cli_params: Dict[str, Any], ctx, config_file_option_name='config_file', ): """ Applies all options set in the config file to `cli_params` """ paramname_to_param = {param.name: param for param in command_f...
[ "def", "apply_config_file", "(", "command_function", ":", "Union", "[", "click", ".", "Command", ",", "click", ".", "Group", "]", ",", "cli_params", ":", "Dict", "[", "str", ",", "Any", "]", ",", "ctx", ",", "config_file_option_name", "=", "'config_file'", ...
Applies all options set in the config file to `cli_params`
[ "Applies", "all", "options", "set", "in", "the", "config", "file", "to", "cli_params" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/cli.py#L354-L424
train
raiden-network/raiden
raiden/utils/cli.py
get_matrix_servers
def get_matrix_servers(url: str) -> List[str]: """Fetch a list of matrix servers from a text url '-' prefixes (YAML list) are cleaned. Comment lines /^\\s*#/ are ignored url: url of a text file returns: list of urls, default schema is https """ try: response = requests.get(url) ...
python
def get_matrix_servers(url: str) -> List[str]: """Fetch a list of matrix servers from a text url '-' prefixes (YAML list) are cleaned. Comment lines /^\\s*#/ are ignored url: url of a text file returns: list of urls, default schema is https """ try: response = requests.get(url) ...
[ "def", "get_matrix_servers", "(", "url", ":", "str", ")", "->", "List", "[", "str", "]", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ")", "if", "response", ".", "status_code", "!=", "200", ":", "raise", "requests", ".", "Req...
Fetch a list of matrix servers from a text url '-' prefixes (YAML list) are cleaned. Comment lines /^\\s*#/ are ignored url: url of a text file returns: list of urls, default schema is https
[ "Fetch", "a", "list", "of", "matrix", "servers", "from", "a", "text", "url" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/cli.py#L427-L450
train
raiden-network/raiden
raiden/raiden_service.py
_redact_secret
def _redact_secret( data: Union[Dict, List], ) -> Union[Dict, List]: """ Modify `data` in-place and replace keys named `secret`. """ if isinstance(data, dict): stack = [data] else: stack = [] while stack: current = stack.pop() if 'secret' in current: ...
python
def _redact_secret( data: Union[Dict, List], ) -> Union[Dict, List]: """ Modify `data` in-place and replace keys named `secret`. """ if isinstance(data, dict): stack = [data] else: stack = [] while stack: current = stack.pop() if 'secret' in current: ...
[ "def", "_redact_secret", "(", "data", ":", "Union", "[", "Dict", ",", "List", "]", ",", ")", "->", "Union", "[", "Dict", ",", "List", "]", ":", "if", "isinstance", "(", "data", ",", "dict", ")", ":", "stack", "=", "[", "data", "]", "else", ":", ...
Modify `data` in-place and replace keys named `secret`.
[ "Modify", "data", "in", "-", "place", "and", "replace", "keys", "named", "secret", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L98-L120
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.stop
def stop(self): """ Stop the node gracefully. Raise if any stop-time error occurred on any subtask """ if self.stop_event.ready(): # not started return # Needs to come before any greenlets joining self.stop_event.set() # Filters must be uninstalled after the alarm ...
python
def stop(self): """ Stop the node gracefully. Raise if any stop-time error occurred on any subtask """ if self.stop_event.ready(): # not started return # Needs to come before any greenlets joining self.stop_event.set() # Filters must be uninstalled after the alarm ...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "stop_event", ".", "ready", "(", ")", ":", "# not started", "return", "# Needs to come before any greenlets joining", "self", ".", "stop_event", ".", "set", "(", ")", "# Filters must be uninstalled after the a...
Stop the node gracefully. Raise if any stop-time error occurred on any subtask
[ "Stop", "the", "node", "gracefully", ".", "Raise", "if", "any", "stop", "-", "time", "error", "occurred", "on", "any", "subtask" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L576-L605
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._start_transport
def _start_transport(self, chain_state: ChainState): """ Initialize the transport and related facilities. Note: The transport must not be started before the node has caught up with the blockchain through `AlarmTask.first_run()`. This synchronization includes the on-c...
python
def _start_transport(self, chain_state: ChainState): """ Initialize the transport and related facilities. Note: The transport must not be started before the node has caught up with the blockchain through `AlarmTask.first_run()`. This synchronization includes the on-c...
[ "def", "_start_transport", "(", "self", ",", "chain_state", ":", "ChainState", ")", ":", "assert", "self", ".", "alarm", ".", "is_primed", "(", ")", ",", "f'AlarmTask not primed. node:{self!r}'", "assert", "self", ".", "ready_to_process_events", ",", "f'Event procos...
Initialize the transport and related facilities. Note: The transport must not be started before the node has caught up with the blockchain through `AlarmTask.first_run()`. This synchronization includes the on-chain channel state and is necessary to reject new mes...
[ "Initialize", "the", "transport", "and", "related", "facilities", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L628-L648
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.handle_and_track_state_change
def handle_and_track_state_change(self, state_change: StateChange): """ Dispatch the state change and does not handle the exceptions. When the method is used the exceptions are tracked and re-raised in the raiden service thread. """ for greenlet in self.handle_state_change(state...
python
def handle_and_track_state_change(self, state_change: StateChange): """ Dispatch the state change and does not handle the exceptions. When the method is used the exceptions are tracked and re-raised in the raiden service thread. """ for greenlet in self.handle_state_change(state...
[ "def", "handle_and_track_state_change", "(", "self", ",", "state_change", ":", "StateChange", ")", ":", "for", "greenlet", "in", "self", ".", "handle_state_change", "(", "state_change", ")", ":", "self", ".", "add_pending_greenlet", "(", "greenlet", ")" ]
Dispatch the state change and does not handle the exceptions. When the method is used the exceptions are tracked and re-raised in the raiden service thread.
[ "Dispatch", "the", "state", "change", "and", "does", "not", "handle", "the", "exceptions", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L675-L682
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.handle_state_change
def handle_state_change(self, state_change: StateChange) -> List[Greenlet]: """ Dispatch the state change and return the processing threads. Use this for error reporting, failures in the returned greenlets, should be re-raised using `gevent.joinall` with `raise_error=True`. """ ...
python
def handle_state_change(self, state_change: StateChange) -> List[Greenlet]: """ Dispatch the state change and return the processing threads. Use this for error reporting, failures in the returned greenlets, should be re-raised using `gevent.joinall` with `raise_error=True`. """ ...
[ "def", "handle_state_change", "(", "self", ",", "state_change", ":", "StateChange", ")", "->", "List", "[", "Greenlet", "]", ":", "assert", "self", ".", "wal", ",", "f'WAL not restored. node:{self!r}'", "log", ".", "debug", "(", "'State change'", ",", "node", ...
Dispatch the state change and return the processing threads. Use this for error reporting, failures in the returned greenlets, should be re-raised using `gevent.joinall` with `raise_error=True`.
[ "Dispatch", "the", "state", "change", "and", "return", "the", "processing", "threads", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L684-L730
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.handle_event
def handle_event(self, raiden_event: RaidenEvent) -> Greenlet: """Spawn a new thread to handle a Raiden event. This will spawn a new greenlet to handle each event, which is important for two reasons: - Blockchain transactions can be queued without interfering with each other....
python
def handle_event(self, raiden_event: RaidenEvent) -> Greenlet: """Spawn a new thread to handle a Raiden event. This will spawn a new greenlet to handle each event, which is important for two reasons: - Blockchain transactions can be queued without interfering with each other....
[ "def", "handle_event", "(", "self", ",", "raiden_event", ":", "RaidenEvent", ")", "->", "Greenlet", ":", "return", "gevent", ".", "spawn", "(", "self", ".", "_handle_event", ",", "raiden_event", ")" ]
Spawn a new thread to handle a Raiden event. This will spawn a new greenlet to handle each event, which is important for two reasons: - Blockchain transactions can be queued without interfering with each other. - The calling thread is free to do more work. This is specially ...
[ "Spawn", "a", "new", "thread", "to", "handle", "a", "Raiden", "event", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L732-L750
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.start_health_check_for
def start_health_check_for(self, node_address: Address): """Start health checking `node_address`. This function is a noop during initialization, because health checking can be started as a side effect of some events (e.g. new channel). For these cases the healthcheck will be started by ...
python
def start_health_check_for(self, node_address: Address): """Start health checking `node_address`. This function is a noop during initialization, because health checking can be started as a side effect of some events (e.g. new channel). For these cases the healthcheck will be started by ...
[ "def", "start_health_check_for", "(", "self", ",", "node_address", ":", "Address", ")", ":", "if", "self", ".", "transport", ":", "self", ".", "transport", ".", "start_health_check", "(", "node_address", ")" ]
Start health checking `node_address`. This function is a noop during initialization, because health checking can be started as a side effect of some events (e.g. new channel). For these cases the healthcheck will be started by `start_neighbours_healthcheck`.
[ "Start", "health", "checking", "node_address", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L777-L786
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._callback_new_block
def _callback_new_block(self, latest_block: Dict): """Called once a new block is detected by the alarm task. Note: This should be called only once per block, otherwise there will be duplicated `Block` state changes in the log. Therefore this method should be called ...
python
def _callback_new_block(self, latest_block: Dict): """Called once a new block is detected by the alarm task. Note: This should be called only once per block, otherwise there will be duplicated `Block` state changes in the log. Therefore this method should be called ...
[ "def", "_callback_new_block", "(", "self", ",", "latest_block", ":", "Dict", ")", ":", "# User facing APIs, which have on-chain side-effects, force polled the", "# blockchain to update the node's state. This force poll is used to", "# provide a consistent view to the user, e.g. a channel ope...
Called once a new block is detected by the alarm task. Note: This should be called only once per block, otherwise there will be duplicated `Block` state changes in the log. Therefore this method should be called only once a new block is mined with the correspond...
[ "Called", "once", "a", "new", "block", "is", "detected", "by", "the", "alarm", "task", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L788-L842
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._initialize_transactions_queues
def _initialize_transactions_queues(self, chain_state: ChainState): """Initialize the pending transaction queue from the previous run. Note: This will only send the transactions which don't have their side-effects applied. Transactions which another node may have sent ...
python
def _initialize_transactions_queues(self, chain_state: ChainState): """Initialize the pending transaction queue from the previous run. Note: This will only send the transactions which don't have their side-effects applied. Transactions which another node may have sent ...
[ "def", "_initialize_transactions_queues", "(", "self", ",", "chain_state", ":", "ChainState", ")", ":", "assert", "self", ".", "alarm", ".", "is_primed", "(", ")", ",", "f'AlarmTask not primed. node:{self!r}'", "pending_transactions", "=", "views", ".", "get_pending_t...
Initialize the pending transaction queue from the previous run. Note: This will only send the transactions which don't have their side-effects applied. Transactions which another node may have sent already will be detected by the alarm task's first run and cleared ...
[ "Initialize", "the", "pending", "transaction", "queue", "from", "the", "previous", "run", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L844-L878
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._initialize_payment_statuses
def _initialize_payment_statuses(self, chain_state: ChainState): """ Re-initialize targets_to_identifiers_to_statuses. Restore the PaymentStatus for any pending payment. This is not tied to a specific protocol message but to the lifecycle of a payment, i.e. the status is re-created if a...
python
def _initialize_payment_statuses(self, chain_state: ChainState): """ Re-initialize targets_to_identifiers_to_statuses. Restore the PaymentStatus for any pending payment. This is not tied to a specific protocol message but to the lifecycle of a payment, i.e. the status is re-created if a...
[ "def", "_initialize_payment_statuses", "(", "self", ",", "chain_state", ":", "ChainState", ")", ":", "with", "self", ".", "payment_identifier_lock", ":", "for", "task", "in", "chain_state", ".", "payment_mapping", ".", "secrethashes_to_task", ".", "values", "(", "...
Re-initialize targets_to_identifiers_to_statuses. Restore the PaymentStatus for any pending payment. This is not tied to a specific protocol message but to the lifecycle of a payment, i.e. the status is re-created if a payment itself has not completed.
[ "Re", "-", "initialize", "targets_to_identifiers_to_statuses", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L880-L909
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._initialize_messages_queues
def _initialize_messages_queues(self, chain_state: ChainState): """Initialize all the message queues with the transport. Note: All messages from the state queues must be pushed to the transport before it's started. This is necessary to avoid a race where the transpor...
python
def _initialize_messages_queues(self, chain_state: ChainState): """Initialize all the message queues with the transport. Note: All messages from the state queues must be pushed to the transport before it's started. This is necessary to avoid a race where the transpor...
[ "def", "_initialize_messages_queues", "(", "self", ",", "chain_state", ":", "ChainState", ")", ":", "assert", "not", "self", ".", "transport", ",", "f'Transport is running. node:{self!r}'", "assert", "self", ".", "alarm", ".", "is_primed", "(", ")", ",", "f'AlarmT...
Initialize all the message queues with the transport. Note: All messages from the state queues must be pushed to the transport before it's started. This is necessary to avoid a race where the transport processes network messages too quickly, queueing new messages...
[ "Initialize", "all", "the", "message", "queues", "with", "the", "transport", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L911-L936
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._initialize_monitoring_services_queue
def _initialize_monitoring_services_queue(self, chain_state: ChainState): """Send the monitoring requests for all current balance proofs. Note: The node must always send the *received* balance proof to the monitoring service, *before* sending its own locked transfer ...
python
def _initialize_monitoring_services_queue(self, chain_state: ChainState): """Send the monitoring requests for all current balance proofs. Note: The node must always send the *received* balance proof to the monitoring service, *before* sending its own locked transfer ...
[ "def", "_initialize_monitoring_services_queue", "(", "self", ",", "chain_state", ":", "ChainState", ")", ":", "msg", "=", "(", "'Transport was started before the monitoring service queue was updated. '", "'This can lead to safety issue. node:{self!r}'", ")", "assert", "not", "sel...
Send the monitoring requests for all current balance proofs. Note: The node must always send the *received* balance proof to the monitoring service, *before* sending its own locked transfer forward. If the monitoring service is updated after, then the following c...
[ "Send", "the", "monitoring", "requests", "for", "all", "current", "balance", "proofs", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L938-L985
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService._initialize_whitelists
def _initialize_whitelists(self, chain_state: ChainState): """ Whitelist neighbors and mediated transfer targets on transport """ for neighbour in views.all_neighbour_nodes(chain_state): if neighbour == ConnectionManager.BOOTSTRAP_ADDR: continue self.transport.wh...
python
def _initialize_whitelists(self, chain_state: ChainState): """ Whitelist neighbors and mediated transfer targets on transport """ for neighbour in views.all_neighbour_nodes(chain_state): if neighbour == ConnectionManager.BOOTSTRAP_ADDR: continue self.transport.wh...
[ "def", "_initialize_whitelists", "(", "self", ",", "chain_state", ":", "ChainState", ")", ":", "for", "neighbour", "in", "views", ".", "all_neighbour_nodes", "(", "chain_state", ")", ":", "if", "neighbour", "==", "ConnectionManager", ".", "BOOTSTRAP_ADDR", ":", ...
Whitelist neighbors and mediated transfer targets on transport
[ "Whitelist", "neighbors", "and", "mediated", "transfer", "targets", "on", "transport" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L987-L1002
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.sign
def sign(self, message: Message): """ Sign message inplace. """ if not isinstance(message, SignedMessage): raise ValueError('{} is not signable.'.format(repr(message))) message.sign(self.signer)
python
def sign(self, message: Message): """ Sign message inplace. """ if not isinstance(message, SignedMessage): raise ValueError('{} is not signable.'.format(repr(message))) message.sign(self.signer)
[ "def", "sign", "(", "self", ",", "message", ":", "Message", ")", ":", "if", "not", "isinstance", "(", "message", ",", "SignedMessage", ")", ":", "raise", "ValueError", "(", "'{} is not signable.'", ".", "format", "(", "repr", "(", "message", ")", ")", ")...
Sign message inplace.
[ "Sign", "message", "inplace", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L1004-L1009
train
raiden-network/raiden
raiden/raiden_service.py
RaidenService.mediated_transfer_async
def mediated_transfer_async( self, token_network_identifier: TokenNetworkID, amount: PaymentAmount, target: TargetAddress, identifier: PaymentID, fee: FeeAmount = MEDIATION_FEE, secret: Secret = None, secret_hash: SecretHash...
python
def mediated_transfer_async( self, token_network_identifier: TokenNetworkID, amount: PaymentAmount, target: TargetAddress, identifier: PaymentID, fee: FeeAmount = MEDIATION_FEE, secret: Secret = None, secret_hash: SecretHash...
[ "def", "mediated_transfer_async", "(", "self", ",", "token_network_identifier", ":", "TokenNetworkID", ",", "amount", ":", "PaymentAmount", ",", "target", ":", "TargetAddress", ",", "identifier", ":", "PaymentID", ",", "fee", ":", "FeeAmount", "=", "MEDIATION_FEE", ...
Transfer `amount` between this node and `target`. This method will start an asynchronous transfer, the transfer might fail or succeed depending on a couple of factors: - Existence of a path that can be used, through the usage of direct or intermediary channels. - ...
[ "Transfer", "amount", "between", "this", "node", "and", "target", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/raiden_service.py#L1068-L1104
train
raiden-network/raiden
raiden/storage/serialize.py
from_dict_hook
def from_dict_hook(data): """Decode internal objects encoded using `to_dict_hook`. This automatically imports the class defined in the `_type` metadata field, and calls the `from_dict` method hook to instantiate an object of that class. Note: Because this function will do automatic module ...
python
def from_dict_hook(data): """Decode internal objects encoded using `to_dict_hook`. This automatically imports the class defined in the `_type` metadata field, and calls the `from_dict` method hook to instantiate an object of that class. Note: Because this function will do automatic module ...
[ "def", "from_dict_hook", "(", "data", ")", ":", "type_", "=", "data", ".", "get", "(", "'_type'", ",", "None", ")", "if", "type_", "is", "not", "None", ":", "klass", "=", "_import_type", "(", "type_", ")", "msg", "=", "'_type must point to a class with `fr...
Decode internal objects encoded using `to_dict_hook`. This automatically imports the class defined in the `_type` metadata field, and calls the `from_dict` method hook to instantiate an object of that class. Note: Because this function will do automatic module loading it's really impor...
[ "Decode", "internal", "objects", "encoded", "using", "to_dict_hook", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/serialize.py#L27-L48
train
raiden-network/raiden
raiden/storage/serialize.py
to_dict_hook
def to_dict_hook(obj): """Convert internal objects to a serializable representation. During serialization if the object has the hook method `to_dict` it will be automatically called and metadata for decoding will be added. This allows for the translation of objects trees of arbitrary depth. E.g.: ...
python
def to_dict_hook(obj): """Convert internal objects to a serializable representation. During serialization if the object has the hook method `to_dict` it will be automatically called and metadata for decoding will be added. This allows for the translation of objects trees of arbitrary depth. E.g.: ...
[ "def", "to_dict_hook", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'to_dict'", ")", ":", "result", "=", "obj", ".", "to_dict", "(", ")", "assert", "isinstance", "(", "result", ",", "dict", ")", ",", "'to_dict must return a dictionary'", "resul...
Convert internal objects to a serializable representation. During serialization if the object has the hook method `to_dict` it will be automatically called and metadata for decoding will be added. This allows for the translation of objects trees of arbitrary depth. E.g.: >>> class Root: >>> de...
[ "Convert", "internal", "objects", "to", "a", "serializable", "representation", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/serialize.py#L51-L87
train
raiden-network/raiden
tools/debugging/json-log-to-html.py
rgb_color_picker
def rgb_color_picker(obj, min_luminance=None, max_luminance=None): """Modified version of colour.RGB_color_picker""" color_value = int.from_bytes( hashlib.md5(str(obj).encode('utf-8')).digest(), 'little', ) % 0xffffff color = Color(f'#{color_value:06x}') if min_luminance and color.ge...
python
def rgb_color_picker(obj, min_luminance=None, max_luminance=None): """Modified version of colour.RGB_color_picker""" color_value = int.from_bytes( hashlib.md5(str(obj).encode('utf-8')).digest(), 'little', ) % 0xffffff color = Color(f'#{color_value:06x}') if min_luminance and color.ge...
[ "def", "rgb_color_picker", "(", "obj", ",", "min_luminance", "=", "None", ",", "max_luminance", "=", "None", ")", ":", "color_value", "=", "int", ".", "from_bytes", "(", "hashlib", ".", "md5", "(", "str", "(", "obj", ")", ".", "encode", "(", "'utf-8'", ...
Modified version of colour.RGB_color_picker
[ "Modified", "version", "of", "colour", ".", "RGB_color_picker" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/debugging/json-log-to-html.py#L100-L111
train
raiden-network/raiden
raiden/utils/__init__.py
random_secret
def random_secret() -> Secret: """ Return a random 32 byte secret except the 0 secret since it's not accepted in the contracts """ while True: secret = os.urandom(32) if secret != constants.EMPTY_HASH: return Secret(secret)
python
def random_secret() -> Secret: """ Return a random 32 byte secret except the 0 secret since it's not accepted in the contracts """ while True: secret = os.urandom(32) if secret != constants.EMPTY_HASH: return Secret(secret)
[ "def", "random_secret", "(", ")", "->", "Secret", ":", "while", "True", ":", "secret", "=", "os", ".", "urandom", "(", "32", ")", "if", "secret", "!=", "constants", ".", "EMPTY_HASH", ":", "return", "Secret", "(", "secret", ")" ]
Return a random 32 byte secret except the 0 secret since it's not accepted in the contracts
[ "Return", "a", "random", "32", "byte", "secret", "except", "the", "0", "secret", "since", "it", "s", "not", "accepted", "in", "the", "contracts" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/__init__.py#L46-L52
train
raiden-network/raiden
raiden/utils/__init__.py
address_checksum_and_decode
def address_checksum_and_decode(addr: str) -> Address: """ Accepts a string address and turns it into binary. Makes sure that the string address provided starts is 0x prefixed and checksummed according to EIP55 specification """ if not is_0x_prefixed(addr): raise InvalidAddress('Add...
python
def address_checksum_and_decode(addr: str) -> Address: """ Accepts a string address and turns it into binary. Makes sure that the string address provided starts is 0x prefixed and checksummed according to EIP55 specification """ if not is_0x_prefixed(addr): raise InvalidAddress('Add...
[ "def", "address_checksum_and_decode", "(", "addr", ":", "str", ")", "->", "Address", ":", "if", "not", "is_0x_prefixed", "(", "addr", ")", ":", "raise", "InvalidAddress", "(", "'Address must be 0x prefixed'", ")", "if", "not", "is_checksum_address", "(", "addr", ...
Accepts a string address and turns it into binary. Makes sure that the string address provided starts is 0x prefixed and checksummed according to EIP55 specification
[ "Accepts", "a", "string", "address", "and", "turns", "it", "into", "binary", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/__init__.py#L63-L77
train
raiden-network/raiden
raiden/utils/__init__.py
privatekey_to_publickey
def privatekey_to_publickey(private_key_bin: bytes) -> bytes: """ Returns public key in bitcoins 'bin' encoding. """ if not ishash(private_key_bin): raise ValueError('private_key_bin format mismatch. maybe hex encoded?') return keys.PrivateKey(private_key_bin).public_key.to_bytes()
python
def privatekey_to_publickey(private_key_bin: bytes) -> bytes: """ Returns public key in bitcoins 'bin' encoding. """ if not ishash(private_key_bin): raise ValueError('private_key_bin format mismatch. maybe hex encoded?') return keys.PrivateKey(private_key_bin).public_key.to_bytes()
[ "def", "privatekey_to_publickey", "(", "private_key_bin", ":", "bytes", ")", "->", "bytes", ":", "if", "not", "ishash", "(", "private_key_bin", ")", ":", "raise", "ValueError", "(", "'private_key_bin format mismatch. maybe hex encoded?'", ")", "return", "keys", ".", ...
Returns public key in bitcoins 'bin' encoding.
[ "Returns", "public", "key", "in", "bitcoins", "bin", "encoding", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/__init__.py#L120-L124
train
raiden-network/raiden
raiden/utils/__init__.py
get_system_spec
def get_system_spec() -> Dict[str, str]: """Collect information about the system and installation. """ import pkg_resources import platform if sys.platform == 'darwin': system_info = 'macOS {} {}'.format( platform.mac_ver()[0], platform.architecture()[0], ) ...
python
def get_system_spec() -> Dict[str, str]: """Collect information about the system and installation. """ import pkg_resources import platform if sys.platform == 'darwin': system_info = 'macOS {} {}'.format( platform.mac_ver()[0], platform.architecture()[0], ) ...
[ "def", "get_system_spec", "(", ")", "->", "Dict", "[", "str", ",", "str", "]", ":", "import", "pkg_resources", "import", "platform", "if", "sys", ".", "platform", "==", "'darwin'", ":", "system_info", "=", "'macOS {} {}'", ".", "format", "(", "platform", "...
Collect information about the system and installation.
[ "Collect", "information", "about", "the", "system", "and", "installation", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/__init__.py#L143-L178
train
raiden-network/raiden
raiden/utils/__init__.py
safe_gas_limit
def safe_gas_limit(*estimates: int) -> int: """ Calculates a safe gas limit for a number of gas estimates including a security margin """ assert None not in estimates, 'if estimateGas returned None it should not reach here' calculated_limit = max(estimates) return int(calculated_limit * constant...
python
def safe_gas_limit(*estimates: int) -> int: """ Calculates a safe gas limit for a number of gas estimates including a security margin """ assert None not in estimates, 'if estimateGas returned None it should not reach here' calculated_limit = max(estimates) return int(calculated_limit * constant...
[ "def", "safe_gas_limit", "(", "*", "estimates", ":", "int", ")", "->", "int", ":", "assert", "None", "not", "in", "estimates", ",", "'if estimateGas returned None it should not reach here'", "calculated_limit", "=", "max", "(", "estimates", ")", "return", "int", "...
Calculates a safe gas limit for a number of gas estimates including a security margin
[ "Calculates", "a", "safe", "gas", "limit", "for", "a", "number", "of", "gas", "estimates", "including", "a", "security", "margin" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/__init__.py#L253-L259
train
raiden-network/raiden
raiden/utils/__init__.py
block_specification_to_number
def block_specification_to_number(block: BlockSpecification, web3: Web3) -> BlockNumber: """ Converts a block specification to an actual block number """ if isinstance(block, str): msg = f"string block specification can't contain {block}" assert block in ('latest', 'pending'), msg number...
python
def block_specification_to_number(block: BlockSpecification, web3: Web3) -> BlockNumber: """ Converts a block specification to an actual block number """ if isinstance(block, str): msg = f"string block specification can't contain {block}" assert block in ('latest', 'pending'), msg number...
[ "def", "block_specification_to_number", "(", "block", ":", "BlockSpecification", ",", "web3", ":", "Web3", ")", "->", "BlockNumber", ":", "if", "isinstance", "(", "block", ",", "str", ")", ":", "msg", "=", "f\"string block specification can't contain {block}\"", "as...
Converts a block specification to an actual block number
[ "Converts", "a", "block", "specification", "to", "an", "actual", "block", "number" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/__init__.py#L267-L281
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.detail
def detail(self, block_identifier: BlockSpecification) -> ChannelDetails: """ Returns the channel details. """ return self.token_network.detail( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, channel_iden...
python
def detail(self, block_identifier: BlockSpecification) -> ChannelDetails: """ Returns the channel details. """ return self.token_network.detail( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, channel_iden...
[ "def", "detail", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ")", "->", "ChannelDetails", ":", "return", "self", ".", "token_network", ".", "detail", "(", "participant1", "=", "self", ".", "participant1", ",", "participant2", "=", "self", ...
Returns the channel details.
[ "Returns", "the", "channel", "details", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L71-L78
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.settle_timeout
def settle_timeout(self) -> int: """ Returns the channels settle_timeout. """ # There is no way to get the settle timeout after the channel has been closed as # we're saving gas. Therefore get the ChannelOpened event and get the timeout there. filter_args = get_filter_args_for_specific_...
python
def settle_timeout(self) -> int: """ Returns the channels settle_timeout. """ # There is no way to get the settle timeout after the channel has been closed as # we're saving gas. Therefore get the ChannelOpened event and get the timeout there. filter_args = get_filter_args_for_specific_...
[ "def", "settle_timeout", "(", "self", ")", "->", "int", ":", "# There is no way to get the settle timeout after the channel has been closed as", "# we're saving gas. Therefore get the ChannelOpened event and get the timeout there.", "filter_args", "=", "get_filter_args_for_specific_event_fro...
Returns the channels settle_timeout.
[ "Returns", "the", "channels", "settle_timeout", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L80-L100
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.opened
def opened(self, block_identifier: BlockSpecification) -> bool: """ Returns if the channel is opened. """ return self.token_network.channel_is_opened( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, channe...
python
def opened(self, block_identifier: BlockSpecification) -> bool: """ Returns if the channel is opened. """ return self.token_network.channel_is_opened( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, channe...
[ "def", "opened", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ")", "->", "bool", ":", "return", "self", ".", "token_network", ".", "channel_is_opened", "(", "participant1", "=", "self", ".", "participant1", ",", "participant2", "=", "self", ...
Returns if the channel is opened.
[ "Returns", "if", "the", "channel", "is", "opened", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L125-L132
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.closed
def closed(self, block_identifier: BlockSpecification) -> bool: """ Returns if the channel is closed. """ return self.token_network.channel_is_closed( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, channe...
python
def closed(self, block_identifier: BlockSpecification) -> bool: """ Returns if the channel is closed. """ return self.token_network.channel_is_closed( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, channe...
[ "def", "closed", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ")", "->", "bool", ":", "return", "self", ".", "token_network", ".", "channel_is_closed", "(", "participant1", "=", "self", ".", "participant1", ",", "participant2", "=", "self", ...
Returns if the channel is closed.
[ "Returns", "if", "the", "channel", "is", "closed", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L134-L141
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.settled
def settled(self, block_identifier: BlockSpecification) -> bool: """ Returns if the channel is settled. """ return self.token_network.channel_is_settled( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, cha...
python
def settled(self, block_identifier: BlockSpecification) -> bool: """ Returns if the channel is settled. """ return self.token_network.channel_is_settled( participant1=self.participant1, participant2=self.participant2, block_identifier=block_identifier, cha...
[ "def", "settled", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ")", "->", "bool", ":", "return", "self", ".", "token_network", ".", "channel_is_settled", "(", "participant1", "=", "self", ".", "participant1", ",", "participant2", "=", "self",...
Returns if the channel is settled.
[ "Returns", "if", "the", "channel", "is", "settled", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L143-L150
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.closing_address
def closing_address(self, block_identifier: BlockSpecification) -> Optional[Address]: """ Returns the address of the closer of the channel. """ return self.token_network.closing_address( participant1=self.participant1, participant2=self.participant2, block_identifier=...
python
def closing_address(self, block_identifier: BlockSpecification) -> Optional[Address]: """ Returns the address of the closer of the channel. """ return self.token_network.closing_address( participant1=self.participant1, participant2=self.participant2, block_identifier=...
[ "def", "closing_address", "(", "self", ",", "block_identifier", ":", "BlockSpecification", ")", "->", "Optional", "[", "Address", "]", ":", "return", "self", ".", "token_network", ".", "closing_address", "(", "participant1", "=", "self", ".", "participant1", ","...
Returns the address of the closer of the channel.
[ "Returns", "the", "address", "of", "the", "closer", "of", "the", "channel", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L152-L159
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.close
def close( self, nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, signature: Signature, block_identifier: BlockSpecification, ): """ Closes the channel using the provided balance proof. """ self.token_ne...
python
def close( self, nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, signature: Signature, block_identifier: BlockSpecification, ): """ Closes the channel using the provided balance proof. """ self.token_ne...
[ "def", "close", "(", "self", ",", "nonce", ":", "Nonce", ",", "balance_hash", ":", "BalanceHash", ",", "additional_hash", ":", "AdditionalHash", ",", "signature", ":", "Signature", ",", "block_identifier", ":", "BlockSpecification", ",", ")", ":", "self", ".",...
Closes the channel using the provided balance proof.
[ "Closes", "the", "channel", "using", "the", "provided", "balance", "proof", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L178-L195
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.update_transfer
def update_transfer( self, nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, partner_signature: Signature, signature: Signature, block_identifier: BlockSpecification, ): """ Updates the channel using ...
python
def update_transfer( self, nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, partner_signature: Signature, signature: Signature, block_identifier: BlockSpecification, ): """ Updates the channel using ...
[ "def", "update_transfer", "(", "self", ",", "nonce", ":", "Nonce", ",", "balance_hash", ":", "BalanceHash", ",", "additional_hash", ":", "AdditionalHash", ",", "partner_signature", ":", "Signature", ",", "signature", ":", "Signature", ",", "block_identifier", ":",...
Updates the channel using the provided balance proof.
[ "Updates", "the", "channel", "using", "the", "provided", "balance", "proof", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L197-L216
train
raiden-network/raiden
raiden/network/proxies/payment_channel.py
PaymentChannel.settle
def settle( self, transferred_amount: TokenAmount, locked_amount: TokenAmount, locksroot: Locksroot, partner_transferred_amount: TokenAmount, partner_locked_amount: TokenAmount, partner_locksroot: Locksroot, block_identifier...
python
def settle( self, transferred_amount: TokenAmount, locked_amount: TokenAmount, locksroot: Locksroot, partner_transferred_amount: TokenAmount, partner_locked_amount: TokenAmount, partner_locksroot: Locksroot, block_identifier...
[ "def", "settle", "(", "self", ",", "transferred_amount", ":", "TokenAmount", ",", "locked_amount", ":", "TokenAmount", ",", "locksroot", ":", "Locksroot", ",", "partner_transferred_amount", ":", "TokenAmount", ",", "partner_locked_amount", ":", "TokenAmount", ",", "...
Settles the channel.
[ "Settles", "the", "channel", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/payment_channel.py#L231-L252
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator.py
events_for_unlock_lock
def events_for_unlock_lock( initiator_state: InitiatorTransferState, channel_state: NettingChannelState, secret: Secret, secrethash: SecretHash, pseudo_random_generator: random.Random, ) -> List[Event]: """ Unlocks the lock offchain, and emits the events for the successful pa...
python
def events_for_unlock_lock( initiator_state: InitiatorTransferState, channel_state: NettingChannelState, secret: Secret, secrethash: SecretHash, pseudo_random_generator: random.Random, ) -> List[Event]: """ Unlocks the lock offchain, and emits the events for the successful pa...
[ "def", "events_for_unlock_lock", "(", "initiator_state", ":", "InitiatorTransferState", ",", "channel_state", ":", "NettingChannelState", ",", "secret", ":", "Secret", ",", "secrethash", ":", "SecretHash", ",", "pseudo_random_generator", ":", "random", ".", "Random", ...
Unlocks the lock offchain, and emits the events for the successful payment.
[ "Unlocks", "the", "lock", "offchain", "and", "emits", "the", "events", "for", "the", "successful", "payment", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator.py#L49-L84
train
raiden-network/raiden
raiden/transfer/mediated_transfer/initiator.py
handle_block
def handle_block( initiator_state: InitiatorTransferState, state_change: Block, channel_state: NettingChannelState, pseudo_random_generator: random.Random, ) -> TransitionResult[InitiatorTransferState]: """ Checks if the lock has expired, and if it has sends a remove expired lock...
python
def handle_block( initiator_state: InitiatorTransferState, state_change: Block, channel_state: NettingChannelState, pseudo_random_generator: random.Random, ) -> TransitionResult[InitiatorTransferState]: """ Checks if the lock has expired, and if it has sends a remove expired lock...
[ "def", "handle_block", "(", "initiator_state", ":", "InitiatorTransferState", ",", "state_change", ":", "Block", ",", "channel_state", ":", "NettingChannelState", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", ")", "->", "TransitionResult", "[", ...
Checks if the lock has expired, and if it has sends a remove expired lock and emits the failing events.
[ "Checks", "if", "the", "lock", "has", "expired", "and", "if", "it", "has", "sends", "a", "remove", "expired", "lock", "and", "emits", "the", "failing", "events", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/initiator.py#L87-L167
train