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 | tools/genesis_builder.py | mk_genesis | def mk_genesis(accounts, initial_alloc=denoms.ether * 100000000):
"""
Create a genesis-block dict with allocation for all `accounts`.
:param accounts: list of account addresses (hex)
:param initial_alloc: the amount to allocate for the `accounts`
:return: genesis dict
"""
genesis = GENESIS_... | python | def mk_genesis(accounts, initial_alloc=denoms.ether * 100000000):
"""
Create a genesis-block dict with allocation for all `accounts`.
:param accounts: list of account addresses (hex)
:param initial_alloc: the amount to allocate for the `accounts`
:return: genesis dict
"""
genesis = GENESIS_... | [
"def",
"mk_genesis",
"(",
"accounts",
",",
"initial_alloc",
"=",
"denoms",
".",
"ether",
"*",
"100000000",
")",
":",
"genesis",
"=",
"GENESIS_STUB",
".",
"copy",
"(",
")",
"genesis",
"[",
"'extraData'",
"]",
"=",
"encode_hex",
"(",
"CLUSTER_NAME",
")",
"ge... | Create a genesis-block dict with allocation for all `accounts`.
:param accounts: list of account addresses (hex)
:param initial_alloc: the amount to allocate for the `accounts`
:return: genesis dict | [
"Create",
"a",
"genesis",
"-",
"block",
"dict",
"with",
"allocation",
"for",
"all",
"accounts",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/genesis_builder.py#L21-L39 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.token_address | def token_address(self) -> Address:
""" Return the token of this manager. """
return to_canonical_address(self.proxy.contract.functions.token().call()) | python | def token_address(self) -> Address:
""" Return the token of this manager. """
return to_canonical_address(self.proxy.contract.functions.token().call()) | [
"def",
"token_address",
"(",
"self",
")",
"->",
"Address",
":",
"return",
"to_canonical_address",
"(",
"self",
".",
"proxy",
".",
"contract",
".",
"functions",
".",
"token",
"(",
")",
".",
"call",
"(",
")",
")"
] | Return the token of this manager. | [
"Return",
"the",
"token",
"of",
"this",
"manager",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L155-L157 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.new_netting_channel | def new_netting_channel(
self,
partner: Address,
settle_timeout: int,
given_block_identifier: BlockSpecification,
) -> ChannelID:
""" Creates a new channel in the TokenNetwork contract.
Args:
partner: The peer to open the channel with.
... | python | def new_netting_channel(
self,
partner: Address,
settle_timeout: int,
given_block_identifier: BlockSpecification,
) -> ChannelID:
""" Creates a new channel in the TokenNetwork contract.
Args:
partner: The peer to open the channel with.
... | [
"def",
"new_netting_channel",
"(",
"self",
",",
"partner",
":",
"Address",
",",
"settle_timeout",
":",
"int",
",",
"given_block_identifier",
":",
"BlockSpecification",
",",
")",
"->",
"ChannelID",
":",
"checking_block",
"=",
"self",
".",
"client",
".",
"get_chec... | Creates a new channel in the TokenNetwork contract.
Args:
partner: The peer to open the channel with.
settle_timeout: The settle timeout to use for this channel.
given_block_identifier: The block identifier of the state change that
prompte... | [
"Creates",
"a",
"new",
"channel",
"in",
"the",
"TokenNetwork",
"contract",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L209-L303 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork._channel_exists_and_not_settled | def _channel_exists_and_not_settled(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> bool:
"""Returns if the channel exists and is in a non-settled state"""
... | python | def _channel_exists_and_not_settled(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> bool:
"""Returns if the channel exists and is in a non-settled state"""
... | [
"def",
"_channel_exists_and_not_settled",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
"=",
"None",
",",
")",
"->",
"bool",
"... | Returns if the channel exists and is in a non-settled state | [
"Returns",
"if",
"the",
"channel",
"exists",
"and",
"is",
"in",
"a",
"non",
"-",
"settled",
"state"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L332-L353 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork._detail_participant | def _detail_participant(
self,
channel_identifier: ChannelID,
participant: Address,
partner: Address,
block_identifier: BlockSpecification,
) -> ParticipantDetails:
""" Returns a dictionary with the channel participant information. """
dat... | python | def _detail_participant(
self,
channel_identifier: ChannelID,
participant: Address,
partner: Address,
block_identifier: BlockSpecification,
) -> ParticipantDetails:
""" Returns a dictionary with the channel participant information. """
dat... | [
"def",
"_detail_participant",
"(",
"self",
",",
"channel_identifier",
":",
"ChannelID",
",",
"participant",
":",
"Address",
",",
"partner",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
"->",
"ParticipantDetails",
":",
"data",
"=",
... | Returns a dictionary with the channel participant information. | [
"Returns",
"a",
"dictionary",
"with",
"the",
"channel",
"participant",
"information",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L355-L380 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork._detail_channel | def _detail_channel(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> ChannelData:
""" Returns a ChannelData instance with the channel specific information.
... | python | def _detail_channel(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> ChannelData:
""" Returns a ChannelData instance with the channel specific information.
... | [
"def",
"_detail_channel",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
"=",
"None",
",",
")",
"->",
"ChannelData",
":",
"ch... | Returns a ChannelData instance with the channel specific information.
If no specific channel_identifier is given then it tries to see if there
is a currently open channel and uses that identifier. | [
"Returns",
"a",
"ChannelData",
"instance",
"with",
"the",
"channel",
"specific",
"information",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L382-L415 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.detail_participants | def detail_participants(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> ParticipantsDetails:
""" Returns a ParticipantsDetails instance with the participants'
... | python | def detail_participants(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> ParticipantsDetails:
""" Returns a ParticipantsDetails instance with the participants'
... | [
"def",
"detail_participants",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
"=",
"None",
",",
")",
"->",
"ParticipantsDetails",
... | Returns a ParticipantsDetails instance with the participants'
channel information.
Note:
For now one of the participants has to be the node_address | [
"Returns",
"a",
"ParticipantsDetails",
"instance",
"with",
"the",
"participants",
"channel",
"information",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L417-L456 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.detail | def detail(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> ChannelDetails:
""" Returns a ChannelDetails instance with all the details of the
channel a... | python | def detail(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> ChannelDetails:
""" Returns a ChannelDetails instance with all the details of the
channel a... | [
"def",
"detail",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
"=",
"None",
",",
")",
"->",
"ChannelDetails",
":",
"if",
"... | Returns a ChannelDetails instance with all the details of the
channel and the channel participants.
Note:
For now one of the participants has to be the node_address | [
"Returns",
"a",
"ChannelDetails",
"instance",
"with",
"all",
"the",
"details",
"of",
"the",
"channel",
"and",
"the",
"channel",
"participants",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L458-L495 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.channel_is_opened | def channel_is_opened(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
""" Returns true if the channel is in an open state, false otherwise. """
try:
... | python | def channel_is_opened(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
""" Returns true if the channel is in an open state, false otherwise. """
try:
... | [
"def",
"channel_is_opened",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
",",
")",
"->",
"bool",
":",
"try",
":",
"channel_... | Returns true if the channel is in an open state, false otherwise. | [
"Returns",
"true",
"if",
"the",
"channel",
"is",
"in",
"an",
"open",
"state",
"false",
"otherwise",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L505-L522 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.channel_is_closed | def channel_is_closed(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
""" Returns true if the channel is in a closed state, false otherwise. """
try:
... | python | def channel_is_closed(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
""" Returns true if the channel is in a closed state, false otherwise. """
try:
... | [
"def",
"channel_is_closed",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
",",
")",
"->",
"bool",
":",
"try",
":",
"channel_... | Returns true if the channel is in a closed state, false otherwise. | [
"Returns",
"true",
"if",
"the",
"channel",
"is",
"in",
"a",
"closed",
"state",
"false",
"otherwise",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L524-L541 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.channel_is_settled | def channel_is_settled(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
""" Returns true if the channel is in a settled state, false otherwise. """
try:
... | python | def channel_is_settled(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> bool:
""" Returns true if the channel is in a settled state, false otherwise. """
try:
... | [
"def",
"channel_is_settled",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
",",
")",
"->",
"bool",
":",
"try",
":",
"channel... | Returns true if the channel is in a settled state, false otherwise. | [
"Returns",
"true",
"if",
"the",
"channel",
"is",
"in",
"a",
"settled",
"state",
"false",
"otherwise",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L543-L560 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.closing_address | def closing_address(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> Optional[Address]:
""" Returns the address of the closer, if the channel is closed and not set... | python | def closing_address(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID = None,
) -> Optional[Address]:
""" Returns the address of the closer, if the channel is closed and not set... | [
"def",
"closing_address",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
"=",
"None",
",",
")",
"->",
"Optional",
"[",
"Addre... | Returns the address of the closer, if the channel is closed and not settled. None
otherwise. | [
"Returns",
"the",
"address",
"of",
"the",
"closer",
"if",
"the",
"channel",
"is",
"closed",
"and",
"not",
"settled",
".",
"None",
"otherwise",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L562-L597 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.set_total_deposit | def set_total_deposit(
self,
given_block_identifier: BlockSpecification,
channel_identifier: ChannelID,
total_deposit: TokenAmount,
partner: Address,
):
""" Set channel's total deposit.
`total_deposit` has to be monotonically increasing, t... | python | def set_total_deposit(
self,
given_block_identifier: BlockSpecification,
channel_identifier: ChannelID,
total_deposit: TokenAmount,
partner: Address,
):
""" Set channel's total deposit.
`total_deposit` has to be monotonically increasing, t... | [
"def",
"set_total_deposit",
"(",
"self",
",",
"given_block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
",",
"total_deposit",
":",
"TokenAmount",
",",
"partner",
":",
"Address",
",",
")",
":",
"if",
"not",
"isinstance",
"(",... | Set channel's total deposit.
`total_deposit` has to be monotonically increasing, this is enforced by
the `TokenNetwork` smart contract. This is done for the same reason why
the balance proofs have a monotonically increasing transferred amount,
it simplifies the analysis of bad behavior ... | [
"Set",
"channel",
"s",
"total",
"deposit",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L681-L837 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.close | def close(
self,
channel_identifier: ChannelID,
partner: Address,
balance_hash: BalanceHash,
nonce: Nonce,
additional_hash: AdditionalHash,
signature: Signature,
given_block_identifier: BlockSpecification,
):
"""... | python | def close(
self,
channel_identifier: ChannelID,
partner: Address,
balance_hash: BalanceHash,
nonce: Nonce,
additional_hash: AdditionalHash,
signature: Signature,
given_block_identifier: BlockSpecification,
):
"""... | [
"def",
"close",
"(",
"self",
",",
"channel_identifier",
":",
"ChannelID",
",",
"partner",
":",
"Address",
",",
"balance_hash",
":",
"BalanceHash",
",",
"nonce",
":",
"Nonce",
",",
"additional_hash",
":",
"AdditionalHash",
",",
"signature",
":",
"Signature",
",... | Close the channel using the provided balance proof.
Note:
This method must *not* be called without updating the application
state, otherwise the node may accept new transfers which cannot be
used, because the closer is not allowed to update the balance proof
subm... | [
"Close",
"the",
"channel",
"using",
"the",
"provided",
"balance",
"proof",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L928-L1033 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.settle | def settle(
self,
channel_identifier: ChannelID,
transferred_amount: TokenAmount,
locked_amount: TokenAmount,
locksroot: Locksroot,
partner: Address,
partner_transferred_amount: TokenAmount,
partner_locked_amount: TokenAmoun... | python | def settle(
self,
channel_identifier: ChannelID,
transferred_amount: TokenAmount,
locked_amount: TokenAmount,
locksroot: Locksroot,
partner: Address,
partner_transferred_amount: TokenAmount,
partner_locked_amount: TokenAmoun... | [
"def",
"settle",
"(",
"self",
",",
"channel_identifier",
":",
"ChannelID",
",",
"transferred_amount",
":",
"TokenAmount",
",",
"locked_amount",
":",
"TokenAmount",
",",
"locksroot",
":",
"Locksroot",
",",
"partner",
":",
"Address",
",",
"partner_transferred_amount",... | Settle the channel. | [
"Settle",
"the",
"channel",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L1337-L1449 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.events_filter | def events_filter(
self,
topics: List[str] = None,
from_block: BlockSpecification = None,
to_block: BlockSpecification = None,
) -> StatelessFilter:
""" Install a new filter for an array of topics emitted by the contract.
Args:
topics: A l... | python | def events_filter(
self,
topics: List[str] = None,
from_block: BlockSpecification = None,
to_block: BlockSpecification = None,
) -> StatelessFilter:
""" Install a new filter for an array of topics emitted by the contract.
Args:
topics: A l... | [
"def",
"events_filter",
"(",
"self",
",",
"topics",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"from_block",
":",
"BlockSpecification",
"=",
"None",
",",
"to_block",
":",
"BlockSpecification",
"=",
"None",
",",
")",
"->",
"StatelessFilter",
":",
"retu... | Install a new filter for an array of topics emitted by the contract.
Args:
topics: A list of event ids to filter for. Can also be None,
in which case all events are queried.
from_block: The block number at which to start looking for events.
to_block: The ... | [
"Install",
"a",
"new",
"filter",
"for",
"an",
"array",
"of",
"topics",
"emitted",
"by",
"the",
"contract",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L1451-L1472 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork.all_events_filter | def all_events_filter(
self,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
) -> StatelessFilter:
""" Install a new filter for all the events emitted by the current token network contract
Args:
from_blo... | python | def all_events_filter(
self,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
) -> StatelessFilter:
""" Install a new filter for all the events emitted by the current token network contract
Args:
from_blo... | [
"def",
"all_events_filter",
"(",
"self",
",",
"from_block",
":",
"BlockSpecification",
"=",
"GENESIS_BLOCK_NUMBER",
",",
"to_block",
":",
"BlockSpecification",
"=",
"'latest'",
",",
")",
"->",
"StatelessFilter",
":",
"return",
"self",
".",
"events_filter",
"(",
"N... | Install a new filter for all the events emitted by the current token network contract
Args:
from_block: Create filter starting from this block number (default: 0).
to_block: Create filter stopping at this block number (default: 'latest').
Return:
The filter instance... | [
"Install",
"a",
"new",
"filter",
"for",
"all",
"the",
"events",
"emitted",
"by",
"the",
"current",
"token",
"network",
"contract"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L1474-L1488 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork._check_for_outdated_channel | def _check_for_outdated_channel(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> None:
"""
Checks whether an operation is being executed on a channel
betw... | python | def _check_for_outdated_channel(
self,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
channel_identifier: ChannelID,
) -> None:
"""
Checks whether an operation is being executed on a channel
betw... | [
"def",
"_check_for_outdated_channel",
"(",
"self",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
"channel_identifier",
":",
"ChannelID",
",",
")",
"->",
"None",
":",
"try",
":",
... | Checks whether an operation is being executed on a channel
between two participants using an old channel identifier | [
"Checks",
"whether",
"an",
"operation",
"is",
"being",
"executed",
"on",
"a",
"channel",
"between",
"two",
"participants",
"using",
"an",
"old",
"channel",
"identifier"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L1490-L1517 | train |
raiden-network/raiden | raiden/network/proxies/token_network.py | TokenNetwork._check_channel_state_for_update | def _check_channel_state_for_update(
self,
channel_identifier: ChannelID,
closer: Address,
update_nonce: Nonce,
block_identifier: BlockSpecification,
) -> Optional[str]:
"""Check the channel state on chain to see if it has been updated.
Co... | python | def _check_channel_state_for_update(
self,
channel_identifier: ChannelID,
closer: Address,
update_nonce: Nonce,
block_identifier: BlockSpecification,
) -> Optional[str]:
"""Check the channel state on chain to see if it has been updated.
Co... | [
"def",
"_check_channel_state_for_update",
"(",
"self",
",",
"channel_identifier",
":",
"ChannelID",
",",
"closer",
":",
"Address",
",",
"update_nonce",
":",
"Nonce",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
"->",
"Optional",
"[",
"str",
"]",
... | Check the channel state on chain to see if it has been updated.
Compare the nonce, we are about to update the contract with, with the
updated nonce in the onchain state and, if it's the same, return a
message with which the caller should raise a RaidenRecoverableError.
If all is okay r... | [
"Check",
"the",
"channel",
"state",
"on",
"chain",
"to",
"see",
"if",
"it",
"has",
"been",
"updated",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network.py#L1624-L1652 | train |
raiden-network/raiden | raiden/network/transport/udp/udp_utils.py | event_first_of | def event_first_of(*events: _AbstractLinkable) -> Event:
""" Waits until one of `events` is set.
The event returned is /not/ cleared with any of the `events`, this value
must not be reused if the clearing behavior is used.
"""
first_finished = Event()
if not all(isinstance(e, _AbstractLinkable... | python | def event_first_of(*events: _AbstractLinkable) -> Event:
""" Waits until one of `events` is set.
The event returned is /not/ cleared with any of the `events`, this value
must not be reused if the clearing behavior is used.
"""
first_finished = Event()
if not all(isinstance(e, _AbstractLinkable... | [
"def",
"event_first_of",
"(",
"*",
"events",
":",
"_AbstractLinkable",
")",
"->",
"Event",
":",
"first_finished",
"=",
"Event",
"(",
")",
"if",
"not",
"all",
"(",
"isinstance",
"(",
"e",
",",
"_AbstractLinkable",
")",
"for",
"e",
"in",
"events",
")",
":"... | Waits until one of `events` is set.
The event returned is /not/ cleared with any of the `events`, this value
must not be reused if the clearing behavior is used. | [
"Waits",
"until",
"one",
"of",
"events",
"is",
"set",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_utils.py#L18-L32 | train |
raiden-network/raiden | raiden/network/transport/udp/udp_utils.py | timeout_exponential_backoff | def timeout_exponential_backoff(
retries: int,
timeout: int,
maximum: int,
) -> Iterator[int]:
""" Timeouts generator with an exponential backoff strategy.
Timeouts start spaced by `timeout`, after `retries` exponentially increase
the retry delays until `maximum`, then maximum is re... | python | def timeout_exponential_backoff(
retries: int,
timeout: int,
maximum: int,
) -> Iterator[int]:
""" Timeouts generator with an exponential backoff strategy.
Timeouts start spaced by `timeout`, after `retries` exponentially increase
the retry delays until `maximum`, then maximum is re... | [
"def",
"timeout_exponential_backoff",
"(",
"retries",
":",
"int",
",",
"timeout",
":",
"int",
",",
"maximum",
":",
"int",
",",
")",
"->",
"Iterator",
"[",
"int",
"]",
":",
"yield",
"timeout",
"tries",
"=",
"1",
"while",
"tries",
"<",
"retries",
":",
"t... | Timeouts generator with an exponential backoff strategy.
Timeouts start spaced by `timeout`, after `retries` exponentially increase
the retry delays until `maximum`, then maximum is returned indefinitely. | [
"Timeouts",
"generator",
"with",
"an",
"exponential",
"backoff",
"strategy",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_utils.py#L35-L57 | train |
raiden-network/raiden | raiden/network/transport/udp/udp_utils.py | timeout_two_stage | def timeout_two_stage(
retries: int,
timeout1: int,
timeout2: int,
) -> Iterable[int]:
""" Timeouts generator with a two stage strategy
Timeouts start spaced by `timeout1`, after `retries` increase
to `timeout2` which is repeated indefinitely.
"""
for _ in range(retries):
... | python | def timeout_two_stage(
retries: int,
timeout1: int,
timeout2: int,
) -> Iterable[int]:
""" Timeouts generator with a two stage strategy
Timeouts start spaced by `timeout1`, after `retries` increase
to `timeout2` which is repeated indefinitely.
"""
for _ in range(retries):
... | [
"def",
"timeout_two_stage",
"(",
"retries",
":",
"int",
",",
"timeout1",
":",
"int",
",",
"timeout2",
":",
"int",
",",
")",
"->",
"Iterable",
"[",
"int",
"]",
":",
"for",
"_",
"in",
"range",
"(",
"retries",
")",
":",
"yield",
"timeout1",
"while",
"Tr... | Timeouts generator with a two stage strategy
Timeouts start spaced by `timeout1`, after `retries` increase
to `timeout2` which is repeated indefinitely. | [
"Timeouts",
"generator",
"with",
"a",
"two",
"stage",
"strategy"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_utils.py#L60-L73 | train |
raiden-network/raiden | raiden/network/transport/udp/udp_utils.py | retry | def retry(
transport: 'UDPTransport',
messagedata: bytes,
message_id: UDPMessageID,
recipient: Address,
stop_event: Event,
timeout_backoff: Iterable[int],
) -> bool:
""" Send messagedata until it's acknowledged.
Exit when:
- The message is delivered.
- E... | python | def retry(
transport: 'UDPTransport',
messagedata: bytes,
message_id: UDPMessageID,
recipient: Address,
stop_event: Event,
timeout_backoff: Iterable[int],
) -> bool:
""" Send messagedata until it's acknowledged.
Exit when:
- The message is delivered.
- E... | [
"def",
"retry",
"(",
"transport",
":",
"'UDPTransport'",
",",
"messagedata",
":",
"bytes",
",",
"message_id",
":",
"UDPMessageID",
",",
"recipient",
":",
"Address",
",",
"stop_event",
":",
"Event",
",",
"timeout_backoff",
":",
"Iterable",
"[",
"int",
"]",
",... | Send messagedata until it's acknowledged.
Exit when:
- The message is delivered.
- Event_stop is set.
- The iterator timeout_backoff runs out.
Returns:
bool: True if the message was acknowledged, False otherwise. | [
"Send",
"messagedata",
"until",
"it",
"s",
"acknowledged",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_utils.py#L76-L125 | train |
raiden-network/raiden | raiden/network/transport/udp/udp_utils.py | retry_with_recovery | def retry_with_recovery(
transport: 'UDPTransport',
messagedata: bytes,
message_id: UDPMessageID,
recipient: Address,
stop_event: Event,
event_healthy: Event,
event_unhealthy: Event,
backoff: Iterable[int],
) -> bool:
""" Send messagedata while the nod... | python | def retry_with_recovery(
transport: 'UDPTransport',
messagedata: bytes,
message_id: UDPMessageID,
recipient: Address,
stop_event: Event,
event_healthy: Event,
event_unhealthy: Event,
backoff: Iterable[int],
) -> bool:
""" Send messagedata while the nod... | [
"def",
"retry_with_recovery",
"(",
"transport",
":",
"'UDPTransport'",
",",
"messagedata",
":",
"bytes",
",",
"message_id",
":",
"UDPMessageID",
",",
"recipient",
":",
"Address",
",",
"stop_event",
":",
"Event",
",",
"event_healthy",
":",
"Event",
",",
"event_un... | Send messagedata while the node is healthy until it's acknowledged.
Note:
backoff must be an infinite iterator, otherwise this task will
become a hot loop. | [
"Send",
"messagedata",
"while",
"the",
"node",
"is",
"healthy",
"until",
"it",
"s",
"acknowledged",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/udp_utils.py#L142-L206 | train |
raiden-network/raiden | raiden/network/proxies/secret_registry.py | SecretRegistry.get_secret_registration_block_by_secrethash | def get_secret_registration_block_by_secrethash(
self,
secrethash: SecretHash,
block_identifier: BlockSpecification,
) -> Optional[BlockNumber]:
"""Return the block number at which the secret for `secrethash` was
registered, None if the secret was never registered... | python | def get_secret_registration_block_by_secrethash(
self,
secrethash: SecretHash,
block_identifier: BlockSpecification,
) -> Optional[BlockNumber]:
"""Return the block number at which the secret for `secrethash` was
registered, None if the secret was never registered... | [
"def",
"get_secret_registration_block_by_secrethash",
"(",
"self",
",",
"secrethash",
":",
"SecretHash",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
"->",
"Optional",
"[",
"BlockNumber",
"]",
":",
"result",
"=",
"self",
".",
"proxy",
".",
"contra... | Return the block number at which the secret for `secrethash` was
registered, None if the secret was never registered. | [
"Return",
"the",
"block",
"number",
"at",
"which",
"the",
"secret",
"for",
"secrethash",
"was",
"registered",
"None",
"if",
"the",
"secret",
"was",
"never",
"registered",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/secret_registry.py#L303-L323 | train |
raiden-network/raiden | raiden/network/proxies/secret_registry.py | SecretRegistry.is_secret_registered | def is_secret_registered(
self,
secrethash: SecretHash,
block_identifier: BlockSpecification,
) -> bool:
"""True if the secret for `secrethash` is registered at `block_identifier`.
Throws NoStateForBlockIdentifier if the given block_identifier
is older th... | python | def is_secret_registered(
self,
secrethash: SecretHash,
block_identifier: BlockSpecification,
) -> bool:
"""True if the secret for `secrethash` is registered at `block_identifier`.
Throws NoStateForBlockIdentifier if the given block_identifier
is older th... | [
"def",
"is_secret_registered",
"(",
"self",
",",
"secrethash",
":",
"SecretHash",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"client",
".",
"can_query_state_for_block",
"(",
"block_identifier",
")",
... | True if the secret for `secrethash` is registered at `block_identifier`.
Throws NoStateForBlockIdentifier if the given block_identifier
is older than the pruning limit | [
"True",
"if",
"the",
"secret",
"for",
"secrethash",
"is",
"registered",
"at",
"block_identifier",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/secret_registry.py#L325-L342 | train |
raiden-network/raiden | raiden/ui/console.py | ConsoleTools.register_token | def register_token(
self,
registry_address_hex: typing.AddressHex,
token_address_hex: typing.AddressHex,
retry_timeout: typing.NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
) -> TokenNetwork:
""" Register a token with the raiden token manager.
Args:
... | python | def register_token(
self,
registry_address_hex: typing.AddressHex,
token_address_hex: typing.AddressHex,
retry_timeout: typing.NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
) -> TokenNetwork:
""" Register a token with the raiden token manager.
Args:
... | [
"def",
"register_token",
"(",
"self",
",",
"registry_address_hex",
":",
"typing",
".",
"AddressHex",
",",
"token_address_hex",
":",
"typing",
".",
"AddressHex",
",",
"retry_timeout",
":",
"typing",
".",
"NetworkTimeout",
"=",
"DEFAULT_RETRY_TIMEOUT",
",",
")",
"->... | Register a token with the raiden token manager.
Args:
registry_address: registry address
token_address_hex (string): a hex encoded token address.
Returns:
The token network proxy. | [
"Register",
"a",
"token",
"with",
"the",
"raiden",
"token",
"manager",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/ui/console.py#L219-L260 | train |
raiden-network/raiden | raiden/ui/console.py | ConsoleTools.open_channel_with_funding | def open_channel_with_funding(
self,
registry_address_hex,
token_address_hex,
peer_address_hex,
total_deposit,
settle_timeout=None,
):
""" Convenience method to open a channel.
Args:
registry_address_hex (str): hex ... | python | def open_channel_with_funding(
self,
registry_address_hex,
token_address_hex,
peer_address_hex,
total_deposit,
settle_timeout=None,
):
""" Convenience method to open a channel.
Args:
registry_address_hex (str): hex ... | [
"def",
"open_channel_with_funding",
"(",
"self",
",",
"registry_address_hex",
",",
"token_address_hex",
",",
"peer_address_hex",
",",
"total_deposit",
",",
"settle_timeout",
"=",
"None",
",",
")",
":",
"# Check, if peer is discoverable",
"registry_address",
"=",
"decode_h... | Convenience method to open a channel.
Args:
registry_address_hex (str): hex encoded address of the registry for the channel.
token_address_hex (str): hex encoded address of the token for the channel.
peer_address_hex (str): hex encoded address of the channel peer.
... | [
"Convenience",
"method",
"to",
"open",
"a",
"channel",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/ui/console.py#L262-L304 | train |
raiden-network/raiden | raiden/ui/console.py | ConsoleTools.wait_for_contract | def wait_for_contract(self, contract_address_hex, timeout=None):
""" Wait until a contract is mined
Args:
contract_address_hex (string): hex encoded address of the contract
timeout (int): time to wait for the contract to get mined
Returns:
True if the contra... | python | def wait_for_contract(self, contract_address_hex, timeout=None):
""" Wait until a contract is mined
Args:
contract_address_hex (string): hex encoded address of the contract
timeout (int): time to wait for the contract to get mined
Returns:
True if the contra... | [
"def",
"wait_for_contract",
"(",
"self",
",",
"contract_address_hex",
",",
"timeout",
"=",
"None",
")",
":",
"contract_address",
"=",
"decode_hex",
"(",
"contract_address_hex",
")",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"result",
"=",
"self",
".",
... | Wait until a contract is mined
Args:
contract_address_hex (string): hex encoded address of the contract
timeout (int): time to wait for the contract to get mined
Returns:
True if the contract got mined, false otherwise | [
"Wait",
"until",
"a",
"contract",
"is",
"mined"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/ui/console.py#L306-L334 | train |
raiden-network/raiden | raiden/storage/sqlite.py | _filter_from_dict | def _filter_from_dict(current: Dict[str, Any]) -> Dict[str, Any]:
"""Takes in a nested dictionary as a filter and returns a flattened filter dictionary"""
filter_ = dict()
for k, v in current.items():
if isinstance(v, dict):
for sub, v2 in _filter_from_dict(v).items():
f... | python | def _filter_from_dict(current: Dict[str, Any]) -> Dict[str, Any]:
"""Takes in a nested dictionary as a filter and returns a flattened filter dictionary"""
filter_ = dict()
for k, v in current.items():
if isinstance(v, dict):
for sub, v2 in _filter_from_dict(v).items():
f... | [
"def",
"_filter_from_dict",
"(",
"current",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"filter_",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"current",
".",
"items",
"(",
")",
":",
"if... | Takes in a nested dictionary as a filter and returns a flattened filter dictionary | [
"Takes",
"in",
"a",
"nested",
"dictionary",
"as",
"a",
"filter",
"and",
"returns",
"a",
"flattened",
"filter",
"dictionary"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L52-L63 | train |
raiden-network/raiden | raiden/storage/sqlite.py | SQLiteStorage.log_run | def log_run(self):
""" Log timestamp and raiden version to help with debugging """
version = get_system_spec()['raiden']
cursor = self.conn.cursor()
cursor.execute('INSERT INTO runs(raiden_version) VALUES (?)', [version])
self.maybe_commit() | python | def log_run(self):
""" Log timestamp and raiden version to help with debugging """
version = get_system_spec()['raiden']
cursor = self.conn.cursor()
cursor.execute('INSERT INTO runs(raiden_version) VALUES (?)', [version])
self.maybe_commit() | [
"def",
"log_run",
"(",
"self",
")",
":",
"version",
"=",
"get_system_spec",
"(",
")",
"[",
"'raiden'",
"]",
"cursor",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"'INSERT INTO runs(raiden_version) VALUES (?)'",
",",
"[",... | Log timestamp and raiden version to help with debugging | [
"Log",
"timestamp",
"and",
"raiden",
"version",
"to",
"help",
"with",
"debugging"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L117-L122 | train |
raiden-network/raiden | raiden/storage/sqlite.py | SQLiteStorage.delete_state_changes | def delete_state_changes(self, state_changes_to_delete: List[int]) -> None:
""" Delete state changes.
Args:
state_changes_to_delete: List of ids to delete.
"""
with self.write_lock, self.conn:
self.conn.executemany(
'DELETE FROM state_events WHERE... | python | def delete_state_changes(self, state_changes_to_delete: List[int]) -> None:
""" Delete state changes.
Args:
state_changes_to_delete: List of ids to delete.
"""
with self.write_lock, self.conn:
self.conn.executemany(
'DELETE FROM state_events WHERE... | [
"def",
"delete_state_changes",
"(",
"self",
",",
"state_changes_to_delete",
":",
"List",
"[",
"int",
"]",
")",
"->",
"None",
":",
"with",
"self",
".",
"write_lock",
",",
"self",
".",
"conn",
":",
"self",
".",
"conn",
".",
"executemany",
"(",
"'DELETE FROM ... | Delete state changes.
Args:
state_changes_to_delete: List of ids to delete. | [
"Delete",
"state",
"changes",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L181-L191 | train |
raiden-network/raiden | raiden/storage/sqlite.py | SQLiteStorage.batch_query_state_changes | def batch_query_state_changes(
self,
batch_size: int,
filters: List[Tuple[str, Any]] = None,
logical_and: bool = True,
) -> Iterator[List[StateChangeRecord]]:
"""Batch query state change records with a given batch size and an optional filter
This is a... | python | def batch_query_state_changes(
self,
batch_size: int,
filters: List[Tuple[str, Any]] = None,
logical_and: bool = True,
) -> Iterator[List[StateChangeRecord]]:
"""Batch query state change records with a given batch size and an optional filter
This is a... | [
"def",
"batch_query_state_changes",
"(",
"self",
",",
"batch_size",
":",
"int",
",",
"filters",
":",
"List",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"logical_and",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Iterator",
"[",
"... | Batch query state change records with a given batch size and an optional filter
This is a generator function returning each batch to the caller to work with. | [
"Batch",
"query",
"state",
"change",
"records",
"with",
"a",
"given",
"batch",
"size",
"and",
"an",
"optional",
"filter"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L390-L413 | train |
raiden-network/raiden | raiden/storage/sqlite.py | SQLiteStorage._get_event_records | def _get_event_records(
self,
limit: int = None,
offset: int = None,
filters: List[Tuple[str, Any]] = None,
logical_and: bool = True,
) -> List[EventRecord]:
""" Return a batch of event records
The batch size can be tweaked with the `limit... | python | def _get_event_records(
self,
limit: int = None,
offset: int = None,
filters: List[Tuple[str, Any]] = None,
logical_and: bool = True,
) -> List[EventRecord]:
""" Return a batch of event records
The batch size can be tweaked with the `limit... | [
"def",
"_get_event_records",
"(",
"self",
",",
"limit",
":",
"int",
"=",
"None",
",",
"offset",
":",
"int",
"=",
"None",
",",
"filters",
":",
"List",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"logical_and",
":",
"bool",
"=",... | Return a batch of event records
The batch size can be tweaked with the `limit` and `offset` arguments.
Additionally the returned events can be optionally filtered with
the `filters` parameter to search for specific data in the event data. | [
"Return",
"a",
"batch",
"of",
"event",
"records"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L469-L498 | train |
raiden-network/raiden | raiden/storage/sqlite.py | SQLiteStorage.batch_query_event_records | def batch_query_event_records(
self,
batch_size: int,
filters: List[Tuple[str, Any]] = None,
logical_and: bool = True,
) -> Iterator[List[EventRecord]]:
"""Batch query event records with a given batch size and an optional filter
This is a generator fu... | python | def batch_query_event_records(
self,
batch_size: int,
filters: List[Tuple[str, Any]] = None,
logical_and: bool = True,
) -> Iterator[List[EventRecord]]:
"""Batch query event records with a given batch size and an optional filter
This is a generator fu... | [
"def",
"batch_query_event_records",
"(",
"self",
",",
"batch_size",
":",
"int",
",",
"filters",
":",
"List",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"None",
",",
"logical_and",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Iterator",
"[",
"... | Batch query event records with a given batch size and an optional filter
This is a generator function returning each batch to the caller to work with. | [
"Batch",
"query",
"event",
"records",
"with",
"a",
"given",
"batch",
"size",
"and",
"an",
"optional",
"filter"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L500-L523 | train |
raiden-network/raiden | raiden/storage/sqlite.py | SQLiteStorage.update_snapshots | def update_snapshots(self, snapshots_data: List[Tuple[str, int]]):
"""Given a list of snapshot data, update them in the DB
The snapshots_data should be a list of tuples of snapshots data
and identifiers in that order.
"""
cursor = self.conn.cursor()
cursor.executemany(
... | python | def update_snapshots(self, snapshots_data: List[Tuple[str, int]]):
"""Given a list of snapshot data, update them in the DB
The snapshots_data should be a list of tuples of snapshots data
and identifiers in that order.
"""
cursor = self.conn.cursor()
cursor.executemany(
... | [
"def",
"update_snapshots",
"(",
"self",
",",
"snapshots_data",
":",
"List",
"[",
"Tuple",
"[",
"str",
",",
"int",
"]",
"]",
")",
":",
"cursor",
"=",
"self",
".",
"conn",
".",
"cursor",
"(",
")",
"cursor",
".",
"executemany",
"(",
"'UPDATE state_snapshot ... | Given a list of snapshot data, update them in the DB
The snapshots_data should be a list of tuples of snapshots data
and identifiers in that order. | [
"Given",
"a",
"list",
"of",
"snapshot",
"data",
"update",
"them",
"in",
"the",
"DB"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/sqlite.py#L566-L577 | train |
raiden-network/raiden | raiden/transfer/views.py | all_neighbour_nodes | def all_neighbour_nodes(chain_state: ChainState) -> Set[Address]:
""" Return the identifiers for all nodes accross all payment networks which
have a channel open with this one.
"""
addresses = set()
for payment_network in chain_state.identifiers_to_paymentnetworks.values():
for token_networ... | python | def all_neighbour_nodes(chain_state: ChainState) -> Set[Address]:
""" Return the identifiers for all nodes accross all payment networks which
have a channel open with this one.
"""
addresses = set()
for payment_network in chain_state.identifiers_to_paymentnetworks.values():
for token_networ... | [
"def",
"all_neighbour_nodes",
"(",
"chain_state",
":",
"ChainState",
")",
"->",
"Set",
"[",
"Address",
"]",
":",
"addresses",
"=",
"set",
"(",
")",
"for",
"payment_network",
"in",
"chain_state",
".",
"identifiers_to_paymentnetworks",
".",
"values",
"(",
")",
"... | Return the identifiers for all nodes accross all payment networks which
have a channel open with this one. | [
"Return",
"the",
"identifiers",
"for",
"all",
"nodes",
"accross",
"all",
"payment",
"networks",
"which",
"have",
"a",
"channel",
"open",
"with",
"this",
"one",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L46-L58 | train |
raiden-network/raiden | raiden/transfer/views.py | get_token_network_identifiers | def get_token_network_identifiers(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
) -> List[TokenNetworkID]:
""" Return the list of token networks registered with the given payment network. """
payment_network = chain_state.identifiers_to_paymentnetworks.get(payment_network_id)
... | python | def get_token_network_identifiers(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
) -> List[TokenNetworkID]:
""" Return the list of token networks registered with the given payment network. """
payment_network = chain_state.identifiers_to_paymentnetworks.get(payment_network_id)
... | [
"def",
"get_token_network_identifiers",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
")",
"->",
"List",
"[",
"TokenNetworkID",
"]",
":",
"payment_network",
"=",
"chain_state",
".",
"identifiers_to_paymentnetworks",
".",... | Return the list of token networks registered with the given payment network. | [
"Return",
"the",
"list",
"of",
"token",
"networks",
"registered",
"with",
"the",
"given",
"payment",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L187-L200 | train |
raiden-network/raiden | raiden/transfer/views.py | get_token_identifiers | def get_token_identifiers(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
) -> List[TokenAddress]:
""" Return the list of tokens registered with the given payment network. """
payment_network = chain_state.identifiers_to_paymentnetworks.get(payment_network_id)
if payment_net... | python | def get_token_identifiers(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
) -> List[TokenAddress]:
""" Return the list of tokens registered with the given payment network. """
payment_network = chain_state.identifiers_to_paymentnetworks.get(payment_network_id)
if payment_net... | [
"def",
"get_token_identifiers",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
")",
"->",
"List",
"[",
"TokenAddress",
"]",
":",
"payment_network",
"=",
"chain_state",
".",
"identifiers_to_paymentnetworks",
".",
"get",
... | Return the list of tokens registered with the given payment network. | [
"Return",
"the",
"list",
"of",
"tokens",
"registered",
"with",
"the",
"given",
"payment",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L203-L216 | train |
raiden-network/raiden | raiden/transfer/views.py | get_channelstate_filter | def get_channelstate_filter(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
filter_fn: Callable,
) -> List[NettingChannelState]:
""" Return the state of channels that match the condition in `filter_fn` """
token_network = get_token_net... | python | def get_channelstate_filter(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
filter_fn: Callable,
) -> List[NettingChannelState]:
""" Return the state of channels that match the condition in `filter_fn` """
token_network = get_token_net... | [
"def",
"get_channelstate_filter",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"filter_fn",
":",
"Callable",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
... | Return the state of channels that match the condition in `filter_fn` | [
"Return",
"the",
"state",
"of",
"channels",
"that",
"match",
"the",
"condition",
"in",
"filter_fn"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L347-L368 | train |
raiden-network/raiden | raiden/transfer/views.py | get_channelstate_open | def get_channelstate_open(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of open channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_network_... | python | def get_channelstate_open(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of open channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_network_... | [
"def",
"get_channelstate_open",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"return",
"get_channelstate_filter",
"("... | Return the state of open channels in a token network. | [
"Return",
"the",
"state",
"of",
"open",
"channels",
"in",
"a",
"token",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L371-L382 | train |
raiden-network/raiden | raiden/transfer/views.py | get_channelstate_closing | def get_channelstate_closing(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of closing channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_ne... | python | def get_channelstate_closing(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of closing channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_ne... | [
"def",
"get_channelstate_closing",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"return",
"get_channelstate_filter",
... | Return the state of closing channels in a token network. | [
"Return",
"the",
"state",
"of",
"closing",
"channels",
"in",
"a",
"token",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L385-L396 | train |
raiden-network/raiden | raiden/transfer/views.py | get_channelstate_closed | def get_channelstate_closed(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of closed channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_netw... | python | def get_channelstate_closed(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of closed channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_netw... | [
"def",
"get_channelstate_closed",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"return",
"get_channelstate_filter",
"... | Return the state of closed channels in a token network. | [
"Return",
"the",
"state",
"of",
"closed",
"channels",
"in",
"a",
"token",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L399-L410 | train |
raiden-network/raiden | raiden/transfer/views.py | get_channelstate_settling | def get_channelstate_settling(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of settling channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_... | python | def get_channelstate_settling(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of settling channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_... | [
"def",
"get_channelstate_settling",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"return",
"get_channelstate_filter",
... | Return the state of settling channels in a token network. | [
"Return",
"the",
"state",
"of",
"settling",
"channels",
"in",
"a",
"token",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L413-L424 | train |
raiden-network/raiden | raiden/transfer/views.py | get_channelstate_settled | def get_channelstate_settled(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of settled channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_ne... | python | def get_channelstate_settled(
chain_state: ChainState,
payment_network_id: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
"""Return the state of settled channels in a token network."""
return get_channelstate_filter(
chain_state,
payment_ne... | [
"def",
"get_channelstate_settled",
"(",
"chain_state",
":",
"ChainState",
",",
"payment_network_id",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"return",
"get_channelstate_filter",
... | Return the state of settled channels in a token network. | [
"Return",
"the",
"state",
"of",
"settled",
"channels",
"in",
"a",
"token",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L427-L438 | train |
raiden-network/raiden | raiden/transfer/views.py | role_from_transfer_task | def role_from_transfer_task(transfer_task: TransferTask) -> str:
"""Return the role and type for the transfer. Throws an exception on error"""
if isinstance(transfer_task, InitiatorTask):
return 'initiator'
if isinstance(transfer_task, MediatorTask):
return 'mediator'
if isinstance(trans... | python | def role_from_transfer_task(transfer_task: TransferTask) -> str:
"""Return the role and type for the transfer. Throws an exception on error"""
if isinstance(transfer_task, InitiatorTask):
return 'initiator'
if isinstance(transfer_task, MediatorTask):
return 'mediator'
if isinstance(trans... | [
"def",
"role_from_transfer_task",
"(",
"transfer_task",
":",
"TransferTask",
")",
"->",
"str",
":",
"if",
"isinstance",
"(",
"transfer_task",
",",
"InitiatorTask",
")",
":",
"return",
"'initiator'",
"if",
"isinstance",
"(",
"transfer_task",
",",
"MediatorTask",
")... | Return the role and type for the transfer. Throws an exception on error | [
"Return",
"the",
"role",
"and",
"type",
"for",
"the",
"transfer",
".",
"Throws",
"an",
"exception",
"on",
"error"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L441-L450 | train |
raiden-network/raiden | raiden/transfer/views.py | secret_from_transfer_task | def secret_from_transfer_task(
transfer_task: Optional[TransferTask],
secrethash: SecretHash,
) -> Optional[Secret]:
"""Return the secret for the transfer, None on EMPTY_SECRET."""
assert isinstance(transfer_task, InitiatorTask)
transfer_state = transfer_task.manager_state.initiator_transfe... | python | def secret_from_transfer_task(
transfer_task: Optional[TransferTask],
secrethash: SecretHash,
) -> Optional[Secret]:
"""Return the secret for the transfer, None on EMPTY_SECRET."""
assert isinstance(transfer_task, InitiatorTask)
transfer_state = transfer_task.manager_state.initiator_transfe... | [
"def",
"secret_from_transfer_task",
"(",
"transfer_task",
":",
"Optional",
"[",
"TransferTask",
"]",
",",
"secrethash",
":",
"SecretHash",
",",
")",
"->",
"Optional",
"[",
"Secret",
"]",
":",
"assert",
"isinstance",
"(",
"transfer_task",
",",
"InitiatorTask",
")... | Return the secret for the transfer, None on EMPTY_SECRET. | [
"Return",
"the",
"secret",
"for",
"the",
"transfer",
"None",
"on",
"EMPTY_SECRET",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L453-L465 | train |
raiden-network/raiden | raiden/transfer/views.py | get_transfer_role | def get_transfer_role(chain_state: ChainState, secrethash: SecretHash) -> Optional[str]:
"""
Returns 'initiator', 'mediator' or 'target' to signify the role the node has
in a transfer. If a transfer task is not found for the secrethash then the
function returns None
"""
task = chain_state.paymen... | python | def get_transfer_role(chain_state: ChainState, secrethash: SecretHash) -> Optional[str]:
"""
Returns 'initiator', 'mediator' or 'target' to signify the role the node has
in a transfer. If a transfer task is not found for the secrethash then the
function returns None
"""
task = chain_state.paymen... | [
"def",
"get_transfer_role",
"(",
"chain_state",
":",
"ChainState",
",",
"secrethash",
":",
"SecretHash",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"task",
"=",
"chain_state",
".",
"payment_mapping",
".",
"secrethashes_to_task",
".",
"get",
"(",
"secrethash",
... | Returns 'initiator', 'mediator' or 'target' to signify the role the node has
in a transfer. If a transfer task is not found for the secrethash then the
function returns None | [
"Returns",
"initiator",
"mediator",
"or",
"target",
"to",
"signify",
"the",
"role",
"the",
"node",
"has",
"in",
"a",
"transfer",
".",
"If",
"a",
"transfer",
"task",
"is",
"not",
"found",
"for",
"the",
"secrethash",
"then",
"the",
"function",
"returns",
"No... | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L468-L477 | train |
raiden-network/raiden | raiden/transfer/views.py | filter_channels_by_status | def filter_channels_by_status(
channel_states: List[NettingChannelState],
exclude_states: Optional[List[str]] = None,
) -> List[NettingChannelState]:
""" Filter the list of channels by excluding ones
for which the state exists in `exclude_states`. """
if exclude_states is None:
excl... | python | def filter_channels_by_status(
channel_states: List[NettingChannelState],
exclude_states: Optional[List[str]] = None,
) -> List[NettingChannelState]:
""" Filter the list of channels by excluding ones
for which the state exists in `exclude_states`. """
if exclude_states is None:
excl... | [
"def",
"filter_channels_by_status",
"(",
"channel_states",
":",
"List",
"[",
"NettingChannelState",
"]",
",",
"exclude_states",
":",
"Optional",
"[",
"List",
"[",
"str",
"]",
"]",
"=",
"None",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"if... | Filter the list of channels by excluding ones
for which the state exists in `exclude_states`. | [
"Filter",
"the",
"list",
"of",
"channels",
"by",
"excluding",
"ones",
"for",
"which",
"the",
"state",
"exists",
"in",
"exclude_states",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L558-L573 | train |
raiden-network/raiden | raiden/transfer/views.py | detect_balance_proof_change | def detect_balance_proof_change(
old_state: ChainState,
current_state: ChainState,
) -> Iterator[Union[BalanceProofSignedState, BalanceProofUnsignedState]]:
""" Compare two states for any received balance_proofs that are not in `old_state`. """
if old_state == current_state:
return
f... | python | def detect_balance_proof_change(
old_state: ChainState,
current_state: ChainState,
) -> Iterator[Union[BalanceProofSignedState, BalanceProofUnsignedState]]:
""" Compare two states for any received balance_proofs that are not in `old_state`. """
if old_state == current_state:
return
f... | [
"def",
"detect_balance_proof_change",
"(",
"old_state",
":",
"ChainState",
",",
"current_state",
":",
"ChainState",
",",
")",
"->",
"Iterator",
"[",
"Union",
"[",
"BalanceProofSignedState",
",",
"BalanceProofUnsignedState",
"]",
"]",
":",
"if",
"old_state",
"==",
... | Compare two states for any received balance_proofs that are not in `old_state`. | [
"Compare",
"two",
"states",
"for",
"any",
"received",
"balance_proofs",
"that",
"are",
"not",
"in",
"old_state",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/views.py#L576-L650 | train |
raiden-network/raiden | raiden/network/upnpsock.py | connect | def connect():
"""Try to connect to the router.
Returns:
u (miniupnc.UPnP): the connected upnp-instance
router (string): the connection information
"""
upnp = miniupnpc.UPnP()
upnp.discoverdelay = 200
providers = upnp.discover()
if providers > 1:
log.debug('multiple ... | python | def connect():
"""Try to connect to the router.
Returns:
u (miniupnc.UPnP): the connected upnp-instance
router (string): the connection information
"""
upnp = miniupnpc.UPnP()
upnp.discoverdelay = 200
providers = upnp.discover()
if providers > 1:
log.debug('multiple ... | [
"def",
"connect",
"(",
")",
":",
"upnp",
"=",
"miniupnpc",
".",
"UPnP",
"(",
")",
"upnp",
".",
"discoverdelay",
"=",
"200",
"providers",
"=",
"upnp",
".",
"discover",
"(",
")",
"if",
"providers",
">",
"1",
":",
"log",
".",
"debug",
"(",
"'multiple up... | Try to connect to the router.
Returns:
u (miniupnc.UPnP): the connected upnp-instance
router (string): the connection information | [
"Try",
"to",
"connect",
"to",
"the",
"router",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/upnpsock.py#L37-L70 | train |
raiden-network/raiden | raiden/network/upnpsock.py | release_port | def release_port(upnp, external_port):
"""Try to release the port mapping for `external_port`.
Args:
external_port (int): the port that was previously forwarded to.
Returns:
success (boolean): if the release was successful.
"""
mapping = upnp.getspecificportmapping(external_port, '... | python | def release_port(upnp, external_port):
"""Try to release the port mapping for `external_port`.
Args:
external_port (int): the port that was previously forwarded to.
Returns:
success (boolean): if the release was successful.
"""
mapping = upnp.getspecificportmapping(external_port, '... | [
"def",
"release_port",
"(",
"upnp",
",",
"external_port",
")",
":",
"mapping",
"=",
"upnp",
".",
"getspecificportmapping",
"(",
"external_port",
",",
"'UDP'",
")",
"if",
"mapping",
"is",
"None",
":",
"log",
".",
"error",
"(",
"'could not find a port mapping'",
... | Try to release the port mapping for `external_port`.
Args:
external_port (int): the port that was previously forwarded to.
Returns:
success (boolean): if the release was successful. | [
"Try",
"to",
"release",
"the",
"port",
"mapping",
"for",
"external_port",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/upnpsock.py#L170-L194 | train |
raiden-network/raiden | raiden/network/blockchain_service.py | BlockChainService.token | def token(self, token_address: Address) -> Token:
""" Return a proxy to interact with a token. """
if not is_binary_address(token_address):
raise ValueError('token_address must be a valid address')
with self._token_creation_lock:
if token_address not in self.address_to_t... | python | def token(self, token_address: Address) -> Token:
""" Return a proxy to interact with a token. """
if not is_binary_address(token_address):
raise ValueError('token_address must be a valid address')
with self._token_creation_lock:
if token_address not in self.address_to_t... | [
"def",
"token",
"(",
"self",
",",
"token_address",
":",
"Address",
")",
"->",
"Token",
":",
"if",
"not",
"is_binary_address",
"(",
"token_address",
")",
":",
"raise",
"ValueError",
"(",
"'token_address must be a valid address'",
")",
"with",
"self",
".",
"_token... | Return a proxy to interact with a token. | [
"Return",
"a",
"proxy",
"to",
"interact",
"with",
"a",
"token",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/blockchain_service.py#L132-L145 | train |
raiden-network/raiden | raiden/network/blockchain_service.py | BlockChainService.discovery | def discovery(self, discovery_address: Address) -> Discovery:
""" Return a proxy to interact with the discovery. """
if not is_binary_address(discovery_address):
raise ValueError('discovery_address must be a valid address')
with self._discovery_creation_lock:
if discover... | python | def discovery(self, discovery_address: Address) -> Discovery:
""" Return a proxy to interact with the discovery. """
if not is_binary_address(discovery_address):
raise ValueError('discovery_address must be a valid address')
with self._discovery_creation_lock:
if discover... | [
"def",
"discovery",
"(",
"self",
",",
"discovery_address",
":",
"Address",
")",
"->",
"Discovery",
":",
"if",
"not",
"is_binary_address",
"(",
"discovery_address",
")",
":",
"raise",
"ValueError",
"(",
"'discovery_address must be a valid address'",
")",
"with",
"sel... | Return a proxy to interact with the discovery. | [
"Return",
"a",
"proxy",
"to",
"interact",
"with",
"the",
"discovery",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/blockchain_service.py#L147-L160 | train |
raiden-network/raiden | raiden/network/rpc/client.py | check_address_has_code | def check_address_has_code(
client: 'JSONRPCClient',
address: Address,
contract_name: str = '',
):
""" Checks that the given address contains code. """
result = client.web3.eth.getCode(to_checksum_address(address), 'latest')
if not result:
if contract_name:
forma... | python | def check_address_has_code(
client: 'JSONRPCClient',
address: Address,
contract_name: str = '',
):
""" Checks that the given address contains code. """
result = client.web3.eth.getCode(to_checksum_address(address), 'latest')
if not result:
if contract_name:
forma... | [
"def",
"check_address_has_code",
"(",
"client",
":",
"'JSONRPCClient'",
",",
"address",
":",
"Address",
",",
"contract_name",
":",
"str",
"=",
"''",
",",
")",
":",
"result",
"=",
"client",
".",
"web3",
".",
"eth",
".",
"getCode",
"(",
"to_checksum_address",
... | Checks that the given address contains code. | [
"Checks",
"that",
"the",
"given",
"address",
"contains",
"code",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L188-L207 | train |
raiden-network/raiden | raiden/network/rpc/client.py | dependencies_order_of_build | def dependencies_order_of_build(target_contract, dependencies_map):
""" Return an ordered list of contracts that is sufficient to successfully
deploy the target contract.
Note:
This function assumes that the `dependencies_map` is an acyclic graph.
"""
if not dependencies_map:
return... | python | def dependencies_order_of_build(target_contract, dependencies_map):
""" Return an ordered list of contracts that is sufficient to successfully
deploy the target contract.
Note:
This function assumes that the `dependencies_map` is an acyclic graph.
"""
if not dependencies_map:
return... | [
"def",
"dependencies_order_of_build",
"(",
"target_contract",
",",
"dependencies_map",
")",
":",
"if",
"not",
"dependencies_map",
":",
"return",
"[",
"target_contract",
"]",
"if",
"target_contract",
"not",
"in",
"dependencies_map",
":",
"raise",
"ValueError",
"(",
"... | Return an ordered list of contracts that is sufficient to successfully
deploy the target contract.
Note:
This function assumes that the `dependencies_map` is an acyclic graph. | [
"Return",
"an",
"ordered",
"list",
"of",
"contracts",
"that",
"is",
"sufficient",
"to",
"successfully",
"deploy",
"the",
"target",
"contract",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L232-L262 | train |
raiden-network/raiden | raiden/network/rpc/client.py | check_value_error_for_parity | def check_value_error_for_parity(value_error: ValueError, call_type: ParityCallType) -> bool:
"""
For parity failing calls and functions do not return None if the transaction
will fail but instead throw a ValueError exception.
This function checks the thrown exception to see if it's the correct one and... | python | def check_value_error_for_parity(value_error: ValueError, call_type: ParityCallType) -> bool:
"""
For parity failing calls and functions do not return None if the transaction
will fail but instead throw a ValueError exception.
This function checks the thrown exception to see if it's the correct one and... | [
"def",
"check_value_error_for_parity",
"(",
"value_error",
":",
"ValueError",
",",
"call_type",
":",
"ParityCallType",
")",
"->",
"bool",
":",
"try",
":",
"error_data",
"=",
"json",
".",
"loads",
"(",
"str",
"(",
"value_error",
")",
".",
"replace",
"(",
"\"'... | For parity failing calls and functions do not return None if the transaction
will fail but instead throw a ValueError exception.
This function checks the thrown exception to see if it's the correct one and
if yes returns True, if not returns False | [
"For",
"parity",
"failing",
"calls",
"and",
"functions",
"do",
"not",
"return",
"None",
"if",
"the",
"transaction",
"will",
"fail",
"but",
"instead",
"throw",
"a",
"ValueError",
"exception",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L270-L295 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.get_confirmed_blockhash | def get_confirmed_blockhash(self):
""" Gets the block CONFIRMATION_BLOCKS in the past and returns its block hash """
confirmed_block_number = self.web3.eth.blockNumber - self.default_block_num_confirmations
if confirmed_block_number < 0:
confirmed_block_number = 0
return sel... | python | def get_confirmed_blockhash(self):
""" Gets the block CONFIRMATION_BLOCKS in the past and returns its block hash """
confirmed_block_number = self.web3.eth.blockNumber - self.default_block_num_confirmations
if confirmed_block_number < 0:
confirmed_block_number = 0
return sel... | [
"def",
"get_confirmed_blockhash",
"(",
"self",
")",
":",
"confirmed_block_number",
"=",
"self",
".",
"web3",
".",
"eth",
".",
"blockNumber",
"-",
"self",
".",
"default_block_num_confirmations",
"if",
"confirmed_block_number",
"<",
"0",
":",
"confirmed_block_number",
... | Gets the block CONFIRMATION_BLOCKS in the past and returns its block hash | [
"Gets",
"the",
"block",
"CONFIRMATION_BLOCKS",
"in",
"the",
"past",
"and",
"returns",
"its",
"block",
"hash"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L559-L565 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.balance | def balance(self, account: Address):
""" Return the balance of the account of the given address. """
return self.web3.eth.getBalance(to_checksum_address(account), 'pending') | python | def balance(self, account: Address):
""" Return the balance of the account of the given address. """
return self.web3.eth.getBalance(to_checksum_address(account), 'pending') | [
"def",
"balance",
"(",
"self",
",",
"account",
":",
"Address",
")",
":",
"return",
"self",
".",
"web3",
".",
"eth",
".",
"getBalance",
"(",
"to_checksum_address",
"(",
"account",
")",
",",
"'pending'",
")"
] | Return the balance of the account of the given address. | [
"Return",
"the",
"balance",
"of",
"the",
"account",
"of",
"the",
"given",
"address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L585-L587 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.parity_get_pending_transaction_hash_by_nonce | def parity_get_pending_transaction_hash_by_nonce(
self,
address: AddressHex,
nonce: Nonce,
) -> Optional[TransactionHash]:
"""Queries the local parity transaction pool and searches for a transaction.
Checks the local tx pool for a transaction from a particular ad... | python | def parity_get_pending_transaction_hash_by_nonce(
self,
address: AddressHex,
nonce: Nonce,
) -> Optional[TransactionHash]:
"""Queries the local parity transaction pool and searches for a transaction.
Checks the local tx pool for a transaction from a particular ad... | [
"def",
"parity_get_pending_transaction_hash_by_nonce",
"(",
"self",
",",
"address",
":",
"AddressHex",
",",
"nonce",
":",
"Nonce",
",",
")",
"->",
"Optional",
"[",
"TransactionHash",
"]",
":",
"assert",
"self",
".",
"eth_node",
"is",
"constants",
".",
"EthClient... | Queries the local parity transaction pool and searches for a transaction.
Checks the local tx pool for a transaction from a particular address and for
a given nonce. If it exists it returns the transaction hash. | [
"Queries",
"the",
"local",
"parity",
"transaction",
"pool",
"and",
"searches",
"for",
"a",
"transaction",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L589-L607 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.new_contract_proxy | def new_contract_proxy(self, contract_interface, contract_address: Address):
""" Return a proxy for interacting with a smart contract.
Args:
contract_interface: The contract interface as defined by the json.
address: The contract's address.
"""
return ContractPro... | python | def new_contract_proxy(self, contract_interface, contract_address: Address):
""" Return a proxy for interacting with a smart contract.
Args:
contract_interface: The contract interface as defined by the json.
address: The contract's address.
"""
return ContractPro... | [
"def",
"new_contract_proxy",
"(",
"self",
",",
"contract_interface",
",",
"contract_address",
":",
"Address",
")",
":",
"return",
"ContractProxy",
"(",
"self",
",",
"contract",
"=",
"self",
".",
"new_contract",
"(",
"contract_interface",
",",
"contract_address",
"... | Return a proxy for interacting with a smart contract.
Args:
contract_interface: The contract interface as defined by the json.
address: The contract's address. | [
"Return",
"a",
"proxy",
"for",
"interacting",
"with",
"a",
"smart",
"contract",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L628-L638 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.send_transaction | def send_transaction(
self,
to: Address,
startgas: int,
value: int = 0,
data: bytes = b'',
) -> bytes:
""" Helper to send signed messages.
This method will use the `privkey` provided in the constructor to
locally sign the transacti... | python | def send_transaction(
self,
to: Address,
startgas: int,
value: int = 0,
data: bytes = b'',
) -> bytes:
""" Helper to send signed messages.
This method will use the `privkey` provided in the constructor to
locally sign the transacti... | [
"def",
"send_transaction",
"(",
"self",
",",
"to",
":",
"Address",
",",
"startgas",
":",
"int",
",",
"value",
":",
"int",
"=",
"0",
",",
"data",
":",
"bytes",
"=",
"b''",
",",
")",
"->",
"bytes",
":",
"if",
"to",
"==",
"to_canonical_address",
"(",
... | Helper to send signed messages.
This method will use the `privkey` provided in the constructor to
locally sign the transaction. This requires an extended server
implementation that accepts the variables v, r, and s. | [
"Helper",
"to",
"send",
"signed",
"messages",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L775-L828 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.poll | def poll(
self,
transaction_hash: bytes,
):
""" Wait until the `transaction_hash` is applied or rejected.
Args:
transaction_hash: Transaction hash that we are waiting for.
"""
if len(transaction_hash) != 32:
raise ValueError(
... | python | def poll(
self,
transaction_hash: bytes,
):
""" Wait until the `transaction_hash` is applied or rejected.
Args:
transaction_hash: Transaction hash that we are waiting for.
"""
if len(transaction_hash) != 32:
raise ValueError(
... | [
"def",
"poll",
"(",
"self",
",",
"transaction_hash",
":",
"bytes",
",",
")",
":",
"if",
"len",
"(",
"transaction_hash",
")",
"!=",
"32",
":",
"raise",
"ValueError",
"(",
"'transaction_hash must be a 32 byte hash'",
",",
")",
"transaction_hash",
"=",
"encode_hex"... | Wait until the `transaction_hash` is applied or rejected.
Args:
transaction_hash: Transaction hash that we are waiting for. | [
"Wait",
"until",
"the",
"transaction_hash",
"is",
"applied",
"or",
"rejected",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L830-L877 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.new_filter | def new_filter(
self,
contract_address: Address,
topics: List[str] = None,
from_block: BlockSpecification = 0,
to_block: BlockSpecification = 'latest',
) -> StatelessFilter:
""" Create a filter in the ethereum node. """
logs_blocks_sanity_c... | python | def new_filter(
self,
contract_address: Address,
topics: List[str] = None,
from_block: BlockSpecification = 0,
to_block: BlockSpecification = 'latest',
) -> StatelessFilter:
""" Create a filter in the ethereum node. """
logs_blocks_sanity_c... | [
"def",
"new_filter",
"(",
"self",
",",
"contract_address",
":",
"Address",
",",
"topics",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"from_block",
":",
"BlockSpecification",
"=",
"0",
",",
"to_block",
":",
"BlockSpecification",
"=",
"'latest'",
",",
"... | Create a filter in the ethereum node. | [
"Create",
"a",
"filter",
"in",
"the",
"ethereum",
"node",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L879-L896 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.get_filter_events | def get_filter_events(
self,
contract_address: Address,
topics: List[str] = None,
from_block: BlockSpecification = 0,
to_block: BlockSpecification = 'latest',
) -> List[Dict]:
""" Get events for the given query. """
logs_blocks_sanity_check... | python | def get_filter_events(
self,
contract_address: Address,
topics: List[str] = None,
from_block: BlockSpecification = 0,
to_block: BlockSpecification = 'latest',
) -> List[Dict]:
""" Get events for the given query. """
logs_blocks_sanity_check... | [
"def",
"get_filter_events",
"(",
"self",
",",
"contract_address",
":",
"Address",
",",
"topics",
":",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"from_block",
":",
"BlockSpecification",
"=",
"0",
",",
"to_block",
":",
"BlockSpecification",
"=",
"'latest'",
"... | Get events for the given query. | [
"Get",
"events",
"for",
"the",
"given",
"query",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L898-L912 | train |
raiden-network/raiden | raiden/network/rpc/client.py | JSONRPCClient.check_for_insufficient_eth | def check_for_insufficient_eth(
self,
transaction_name: str,
transaction_executed: bool,
required_gas: int,
block_identifier: BlockSpecification,
):
""" After estimate gas failure checks if our address has enough balance.
If the account di... | python | def check_for_insufficient_eth(
self,
transaction_name: str,
transaction_executed: bool,
required_gas: int,
block_identifier: BlockSpecification,
):
""" After estimate gas failure checks if our address has enough balance.
If the account di... | [
"def",
"check_for_insufficient_eth",
"(",
"self",
",",
"transaction_name",
":",
"str",
",",
"transaction_executed",
":",
"bool",
",",
"required_gas",
":",
"int",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
":",
"if",
"transaction_executed",
":",
... | After estimate gas failure checks if our address has enough balance.
If the account did not have enough ETH balance to execute the,
transaction then it raises an `InsufficientFunds` error | [
"After",
"estimate",
"gas",
"failure",
"checks",
"if",
"our",
"address",
"has",
"enough",
"balance",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/rpc/client.py#L914-L935 | train |
raiden-network/raiden | raiden/utils/upgrades.py | get_db_version | def get_db_version(db_filename: Path) -> int:
"""Return the version value stored in the db"""
assert os.path.exists(db_filename)
# Perform a query directly through SQL rather than using
# storage.get_version()
# as get_version will return the latest version if it doesn't
# find a record in the... | python | def get_db_version(db_filename: Path) -> int:
"""Return the version value stored in the db"""
assert os.path.exists(db_filename)
# Perform a query directly through SQL rather than using
# storage.get_version()
# as get_version will return the latest version if it doesn't
# find a record in the... | [
"def",
"get_db_version",
"(",
"db_filename",
":",
"Path",
")",
"->",
"int",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"db_filename",
")",
"# Perform a query directly through SQL rather than using",
"# storage.get_version()",
"# as get_version will return the lat... | Return the version value stored in the db | [
"Return",
"the",
"version",
"value",
"stored",
"in",
"the",
"db"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/upgrades.py#L73-L101 | train |
raiden-network/raiden | tools/scenario-player/scenario_player/utils.py | get_or_deploy_token | def get_or_deploy_token(runner) -> Tuple[ContractProxy, int]:
""" Deploy or reuse """
token_contract = runner.contract_manager.get_contract(CONTRACT_CUSTOM_TOKEN)
token_config = runner.scenario.get('token', {})
if not token_config:
token_config = {}
address = token_config.get('address')
... | python | def get_or_deploy_token(runner) -> Tuple[ContractProxy, int]:
""" Deploy or reuse """
token_contract = runner.contract_manager.get_contract(CONTRACT_CUSTOM_TOKEN)
token_config = runner.scenario.get('token', {})
if not token_config:
token_config = {}
address = token_config.get('address')
... | [
"def",
"get_or_deploy_token",
"(",
"runner",
")",
"->",
"Tuple",
"[",
"ContractProxy",
",",
"int",
"]",
":",
"token_contract",
"=",
"runner",
".",
"contract_manager",
".",
"get_contract",
"(",
"CONTRACT_CUSTOM_TOKEN",
")",
"token_config",
"=",
"runner",
".",
"sc... | Deploy or reuse | [
"Deploy",
"or",
"reuse"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/utils.py#L199-L257 | train |
raiden-network/raiden | tools/scenario-player/scenario_player/utils.py | get_udc_and_token | def get_udc_and_token(runner) -> Tuple[Optional[ContractProxy], Optional[ContractProxy]]:
""" Return contract proxies for the UserDepositContract and associated token """
from scenario_player.runner import ScenarioRunner
assert isinstance(runner, ScenarioRunner)
udc_config = runner.scenario.services.ge... | python | def get_udc_and_token(runner) -> Tuple[Optional[ContractProxy], Optional[ContractProxy]]:
""" Return contract proxies for the UserDepositContract and associated token """
from scenario_player.runner import ScenarioRunner
assert isinstance(runner, ScenarioRunner)
udc_config = runner.scenario.services.ge... | [
"def",
"get_udc_and_token",
"(",
"runner",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"ContractProxy",
"]",
",",
"Optional",
"[",
"ContractProxy",
"]",
"]",
":",
"from",
"scenario_player",
".",
"runner",
"import",
"ScenarioRunner",
"assert",
"isinstance",
"(",
... | Return contract proxies for the UserDepositContract and associated token | [
"Return",
"contract",
"proxies",
"for",
"the",
"UserDepositContract",
"and",
"associated",
"token"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/utils.py#L260-L285 | train |
raiden-network/raiden | tools/scenario-player/scenario_player/utils.py | mint_token_if_balance_low | def mint_token_if_balance_low(
token_contract: ContractProxy,
target_address: str,
min_balance: int,
fund_amount: int,
gas_limit: int,
mint_msg: str,
no_action_msg: str = None,
) -> Optional[TransactionHash]:
""" Check token balance and mint if below minimum "... | python | def mint_token_if_balance_low(
token_contract: ContractProxy,
target_address: str,
min_balance: int,
fund_amount: int,
gas_limit: int,
mint_msg: str,
no_action_msg: str = None,
) -> Optional[TransactionHash]:
""" Check token balance and mint if below minimum "... | [
"def",
"mint_token_if_balance_low",
"(",
"token_contract",
":",
"ContractProxy",
",",
"target_address",
":",
"str",
",",
"min_balance",
":",
"int",
",",
"fund_amount",
":",
"int",
",",
"gas_limit",
":",
"int",
",",
"mint_msg",
":",
"str",
",",
"no_action_msg",
... | Check token balance and mint if below minimum | [
"Check",
"token",
"balance",
"and",
"mint",
"if",
"below",
"minimum"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/utils.py#L288-L307 | train |
raiden-network/raiden | raiden/storage/wal.py | WriteAheadLog.log_and_dispatch | def log_and_dispatch(self, state_change):
""" Log and apply a state change.
This function will first write the state change to the write-ahead-log,
in case of a node crash the state change can be recovered and replayed
to restore the node state.
Events produced by applying stat... | python | def log_and_dispatch(self, state_change):
""" Log and apply a state change.
This function will first write the state change to the write-ahead-log,
in case of a node crash the state change can be recovered and replayed
to restore the node state.
Events produced by applying stat... | [
"def",
"log_and_dispatch",
"(",
"self",
",",
"state_change",
")",
":",
"with",
"self",
".",
"_lock",
":",
"timestamp",
"=",
"datetime",
".",
"utcnow",
"(",
")",
".",
"isoformat",
"(",
"timespec",
"=",
"'milliseconds'",
")",
"state_change_id",
"=",
"self",
... | Log and apply a state change.
This function will first write the state change to the write-ahead-log,
in case of a node crash the state change can be recovered and replayed
to restore the node state.
Events produced by applying state change are also saved. | [
"Log",
"and",
"apply",
"a",
"state",
"change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/wal.py#L64-L83 | train |
raiden-network/raiden | raiden/storage/wal.py | WriteAheadLog.snapshot | def snapshot(self):
""" Snapshot the application state.
Snapshots are used to restore the application state, either after a
restart or a crash.
"""
with self._lock:
current_state = self.state_manager.current_state
state_change_id = self.state_change_id
... | python | def snapshot(self):
""" Snapshot the application state.
Snapshots are used to restore the application state, either after a
restart or a crash.
"""
with self._lock:
current_state = self.state_manager.current_state
state_change_id = self.state_change_id
... | [
"def",
"snapshot",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"current_state",
"=",
"self",
".",
"state_manager",
".",
"current_state",
"state_change_id",
"=",
"self",
".",
"state_change_id",
"# otherwise no state change was dispatched",
"if",
"state_... | Snapshot the application state.
Snapshots are used to restore the application state, either after a
restart or a crash. | [
"Snapshot",
"the",
"application",
"state",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/wal.py#L85-L97 | train |
raiden-network/raiden | raiden/blockchain_events_handler.py | handle_tokennetwork_new | def handle_tokennetwork_new(raiden: 'RaidenService', event: Event):
""" Handles a `TokenNetworkCreated` event. """
data = event.event_data
args = data['args']
block_number = data['block_number']
token_network_address = args['token_network_address']
token_address = typing.TokenAddress(args['token... | python | def handle_tokennetwork_new(raiden: 'RaidenService', event: Event):
""" Handles a `TokenNetworkCreated` event. """
data = event.event_data
args = data['args']
block_number = data['block_number']
token_network_address = args['token_network_address']
token_address = typing.TokenAddress(args['token... | [
"def",
"handle_tokennetwork_new",
"(",
"raiden",
":",
"'RaidenService'",
",",
"event",
":",
"Event",
")",
":",
"data",
"=",
"event",
".",
"event_data",
"args",
"=",
"data",
"[",
"'args'",
"]",
"block_number",
"=",
"data",
"[",
"'block_number'",
"]",
"token_n... | Handles a `TokenNetworkCreated` event. | [
"Handles",
"a",
"TokenNetworkCreated",
"event",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain_events_handler.py#L45-L75 | train |
raiden-network/raiden | tools/scenario-player/scenario_player/tasks/blockchain.py | query_blockchain_events | def query_blockchain_events(
web3: Web3,
contract_manager: ContractManager,
contract_address: Address,
contract_name: str,
topics: List,
from_block: BlockNumber,
to_block: BlockNumber,
) -> List[Dict]:
"""Returns events emmitted by a contract for a given event... | python | def query_blockchain_events(
web3: Web3,
contract_manager: ContractManager,
contract_address: Address,
contract_name: str,
topics: List,
from_block: BlockNumber,
to_block: BlockNumber,
) -> List[Dict]:
"""Returns events emmitted by a contract for a given event... | [
"def",
"query_blockchain_events",
"(",
"web3",
":",
"Web3",
",",
"contract_manager",
":",
"ContractManager",
",",
"contract_address",
":",
"Address",
",",
"contract_name",
":",
"str",
",",
"topics",
":",
"List",
",",
"from_block",
":",
"BlockNumber",
",",
"to_bl... | Returns events emmitted by a contract for a given event name, within a certain range.
Args:
web3: A Web3 instance
contract_manager: A contract manager
contract_address: The address of the contract to be filtered, can be `None`
contract_name: The name of the contract
topics: ... | [
"Returns",
"events",
"emmitted",
"by",
"a",
"contract",
"for",
"a",
"given",
"event",
"name",
"within",
"a",
"certain",
"range",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/tasks/blockchain.py#L50-L89 | train |
raiden-network/raiden | raiden/storage/migrations/v16_to_v17.py | upgrade_v16_to_v17 | def upgrade_v16_to_v17(storage: SQLiteStorage, old_version: int, current_version: int, **kwargs):
""" InitiatorPaymentState was changed so that the "initiator"
attribute is renamed to "initiator_transfers" and converted to a list.
"""
if old_version == SOURCE_VERSION:
_transform_snapshots(storag... | python | def upgrade_v16_to_v17(storage: SQLiteStorage, old_version: int, current_version: int, **kwargs):
""" InitiatorPaymentState was changed so that the "initiator"
attribute is renamed to "initiator_transfers" and converted to a list.
"""
if old_version == SOURCE_VERSION:
_transform_snapshots(storag... | [
"def",
"upgrade_v16_to_v17",
"(",
"storage",
":",
"SQLiteStorage",
",",
"old_version",
":",
"int",
",",
"current_version",
":",
"int",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"old_version",
"==",
"SOURCE_VERSION",
":",
"_transform_snapshots",
"(",
"storage",
... | InitiatorPaymentState was changed so that the "initiator"
attribute is renamed to "initiator_transfers" and converted to a list. | [
"InitiatorPaymentState",
"was",
"changed",
"so",
"that",
"the",
"initiator",
"attribute",
"is",
"renamed",
"to",
"initiator_transfers",
"and",
"converted",
"to",
"a",
"list",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v16_to_v17.py#L52-L59 | train |
raiden-network/raiden | raiden/storage/versions.py | filter_db_names | def filter_db_names(paths: List[str]) -> List[str]:
"""Returns a filtered list of `paths`, where every name matches our format.
Args:
paths: A list of file names.
"""
return [
db_path
for db_path in paths
if VERSION_RE.match(os.path.basename(db_path))
] | python | def filter_db_names(paths: List[str]) -> List[str]:
"""Returns a filtered list of `paths`, where every name matches our format.
Args:
paths: A list of file names.
"""
return [
db_path
for db_path in paths
if VERSION_RE.match(os.path.basename(db_path))
] | [
"def",
"filter_db_names",
"(",
"paths",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"db_path",
"for",
"db_path",
"in",
"paths",
"if",
"VERSION_RE",
".",
"match",
"(",
"os",
".",
"path",
".",
"basename",
"(",
... | Returns a filtered list of `paths`, where every name matches our format.
Args:
paths: A list of file names. | [
"Returns",
"a",
"filtered",
"list",
"of",
"paths",
"where",
"every",
"name",
"matches",
"our",
"format",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/versions.py#L37-L47 | train |
raiden-network/raiden | raiden/network/proxies/utils.py | compare_contract_versions | def compare_contract_versions(
proxy: ContractProxy,
expected_version: str,
contract_name: str,
address: Address,
) -> None:
"""Compare version strings of a contract.
If not matching raise ContractVersionMismatch. Also may raise AddressWrongContract
if the contract contains ... | python | def compare_contract_versions(
proxy: ContractProxy,
expected_version: str,
contract_name: str,
address: Address,
) -> None:
"""Compare version strings of a contract.
If not matching raise ContractVersionMismatch. Also may raise AddressWrongContract
if the contract contains ... | [
"def",
"compare_contract_versions",
"(",
"proxy",
":",
"ContractProxy",
",",
"expected_version",
":",
"str",
",",
"contract_name",
":",
"str",
",",
"address",
":",
"Address",
",",
")",
"->",
"None",
":",
"assert",
"isinstance",
"(",
"expected_version",
",",
"s... | Compare version strings of a contract.
If not matching raise ContractVersionMismatch. Also may raise AddressWrongContract
if the contract contains no code. | [
"Compare",
"version",
"strings",
"of",
"a",
"contract",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/utils.py#L16-L42 | train |
raiden-network/raiden | raiden/network/proxies/utils.py | get_onchain_locksroots | def get_onchain_locksroots(
chain: 'BlockChainService',
canonical_identifier: CanonicalIdentifier,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
) -> Tuple[Locksroot, Locksroot]:
"""Return the locksroot for `participant1` and `participant... | python | def get_onchain_locksroots(
chain: 'BlockChainService',
canonical_identifier: CanonicalIdentifier,
participant1: Address,
participant2: Address,
block_identifier: BlockSpecification,
) -> Tuple[Locksroot, Locksroot]:
"""Return the locksroot for `participant1` and `participant... | [
"def",
"get_onchain_locksroots",
"(",
"chain",
":",
"'BlockChainService'",
",",
"canonical_identifier",
":",
"CanonicalIdentifier",
",",
"participant1",
":",
"Address",
",",
"participant2",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
... | Return the locksroot for `participant1` and `participant2` at `block_identifier`. | [
"Return",
"the",
"locksroot",
"for",
"participant1",
"and",
"participant2",
"at",
"block_identifier",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/utils.py#L45-L70 | train |
raiden-network/raiden | raiden/transfer/node.py | inplace_delete_message_queue | def inplace_delete_message_queue(
chain_state: ChainState,
state_change: Union[ReceiveDelivered, ReceiveProcessed],
queueid: QueueIdentifier,
) -> None:
""" Filter messages from queue, if the queue becomes empty, cleanup the queue itself. """
queue = chain_state.queueids_to_queues.get(qu... | python | def inplace_delete_message_queue(
chain_state: ChainState,
state_change: Union[ReceiveDelivered, ReceiveProcessed],
queueid: QueueIdentifier,
) -> None:
""" Filter messages from queue, if the queue becomes empty, cleanup the queue itself. """
queue = chain_state.queueids_to_queues.get(qu... | [
"def",
"inplace_delete_message_queue",
"(",
"chain_state",
":",
"ChainState",
",",
"state_change",
":",
"Union",
"[",
"ReceiveDelivered",
",",
"ReceiveProcessed",
"]",
",",
"queueid",
":",
"QueueIdentifier",
",",
")",
"->",
"None",
":",
"queue",
"=",
"chain_state"... | Filter messages from queue, if the queue becomes empty, cleanup the queue itself. | [
"Filter",
"messages",
"from",
"queue",
"if",
"the",
"queue",
"becomes",
"empty",
"cleanup",
"the",
"queue",
"itself",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/node.py#L498-L516 | train |
raiden-network/raiden | raiden/transfer/node.py | inplace_delete_message | def inplace_delete_message(
message_queue: List[SendMessageEvent],
state_change: Union[ReceiveDelivered, ReceiveProcessed],
) -> None:
""" Check if the message exists in queue with ID `queueid` and exclude if found."""
for message in list(message_queue):
message_found = (
mes... | python | def inplace_delete_message(
message_queue: List[SendMessageEvent],
state_change: Union[ReceiveDelivered, ReceiveProcessed],
) -> None:
""" Check if the message exists in queue with ID `queueid` and exclude if found."""
for message in list(message_queue):
message_found = (
mes... | [
"def",
"inplace_delete_message",
"(",
"message_queue",
":",
"List",
"[",
"SendMessageEvent",
"]",
",",
"state_change",
":",
"Union",
"[",
"ReceiveDelivered",
",",
"ReceiveProcessed",
"]",
",",
")",
"->",
"None",
":",
"for",
"message",
"in",
"list",
"(",
"messa... | Check if the message exists in queue with ID `queueid` and exclude if found. | [
"Check",
"if",
"the",
"message",
"exists",
"in",
"queue",
"with",
"ID",
"queueid",
"and",
"exclude",
"if",
"found",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/node.py#L519-L530 | train |
raiden-network/raiden | raiden/transfer/node.py | handle_delivered | def handle_delivered(
chain_state: ChainState,
state_change: ReceiveDelivered,
) -> TransitionResult[ChainState]:
""" Check if the "Delivered" message exists in the global queue and delete if found."""
queueid = QueueIdentifier(state_change.sender, CHANNEL_IDENTIFIER_GLOBAL_QUEUE)
inplace_de... | python | def handle_delivered(
chain_state: ChainState,
state_change: ReceiveDelivered,
) -> TransitionResult[ChainState]:
""" Check if the "Delivered" message exists in the global queue and delete if found."""
queueid = QueueIdentifier(state_change.sender, CHANNEL_IDENTIFIER_GLOBAL_QUEUE)
inplace_de... | [
"def",
"handle_delivered",
"(",
"chain_state",
":",
"ChainState",
",",
"state_change",
":",
"ReceiveDelivered",
",",
")",
"->",
"TransitionResult",
"[",
"ChainState",
"]",
":",
"queueid",
"=",
"QueueIdentifier",
"(",
"state_change",
".",
"sender",
",",
"CHANNEL_ID... | Check if the "Delivered" message exists in the global queue and delete if found. | [
"Check",
"if",
"the",
"Delivered",
"message",
"exists",
"in",
"the",
"global",
"queue",
"and",
"delete",
"if",
"found",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/node.py#L620-L627 | train |
raiden-network/raiden | raiden/transfer/node.py | is_transaction_effect_satisfied | def is_transaction_effect_satisfied(
chain_state: ChainState,
transaction: ContractSendEvent,
state_change: StateChange,
) -> bool:
""" True if the side-effect of `transaction` is satisfied by
`state_change`.
This predicate is used to clear the transaction queue. This should only be... | python | def is_transaction_effect_satisfied(
chain_state: ChainState,
transaction: ContractSendEvent,
state_change: StateChange,
) -> bool:
""" True if the side-effect of `transaction` is satisfied by
`state_change`.
This predicate is used to clear the transaction queue. This should only be... | [
"def",
"is_transaction_effect_satisfied",
"(",
"chain_state",
":",
"ChainState",
",",
"transaction",
":",
"ContractSendEvent",
",",
"state_change",
":",
"StateChange",
",",
")",
"->",
"bool",
":",
"# These transactions are not made atomic through the WAL. They are sent",
"# e... | True if the side-effect of `transaction` is satisfied by
`state_change`.
This predicate is used to clear the transaction queue. This should only be
done once the expected side effect of a transaction is achieved. This
doesn't necessarily mean that the transaction sent by *this* node was
mined, but ... | [
"True",
"if",
"the",
"side",
"-",
"effect",
"of",
"transaction",
"is",
"satisfied",
"by",
"state_change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/node.py#L1043-L1180 | train |
raiden-network/raiden | raiden/transfer/node.py | is_transaction_invalidated | def is_transaction_invalidated(transaction, state_change):
""" True if the `transaction` is made invalid by `state_change`.
Some transactions will fail due to race conditions. The races are:
- Another transaction which has the same side effect is executed before.
- Another transaction which *invalidat... | python | def is_transaction_invalidated(transaction, state_change):
""" True if the `transaction` is made invalid by `state_change`.
Some transactions will fail due to race conditions. The races are:
- Another transaction which has the same side effect is executed before.
- Another transaction which *invalidat... | [
"def",
"is_transaction_invalidated",
"(",
"transaction",
",",
"state_change",
")",
":",
"# Most transactions cannot be invalidated by others. These are:",
"#",
"# - close transactions",
"# - settle transactions",
"# - batch unlocks",
"#",
"# Deposits and withdraws are invalidated by the ... | True if the `transaction` is made invalid by `state_change`.
Some transactions will fail due to race conditions. The races are:
- Another transaction which has the same side effect is executed before.
- Another transaction which *invalidates* the state of the smart contract
required by the local trans... | [
"True",
"if",
"the",
"transaction",
"is",
"made",
"invalid",
"by",
"state_change",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/node.py#L1183-L1232 | train |
raiden-network/raiden | raiden/transfer/node.py | is_transaction_expired | def is_transaction_expired(transaction, block_number):
""" True if transaction cannot be mined because it has expired.
Some transactions are time dependent, e.g. the secret registration must be
done before the lock expiration, and the update transfer must be done
before the settlement window is over. I... | python | def is_transaction_expired(transaction, block_number):
""" True if transaction cannot be mined because it has expired.
Some transactions are time dependent, e.g. the secret registration must be
done before the lock expiration, and the update transfer must be done
before the settlement window is over. I... | [
"def",
"is_transaction_expired",
"(",
"transaction",
",",
"block_number",
")",
":",
"is_update_expired",
"=",
"(",
"isinstance",
"(",
"transaction",
",",
"ContractSendChannelUpdateTransfer",
")",
"and",
"transaction",
".",
"expiration",
"<",
"block_number",
")",
"if",... | True if transaction cannot be mined because it has expired.
Some transactions are time dependent, e.g. the secret registration must be
done before the lock expiration, and the update transfer must be done
before the settlement window is over. If the current block is higher than
any of these expirations... | [
"True",
"if",
"transaction",
"cannot",
"be",
"mined",
"because",
"it",
"has",
"expired",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/node.py#L1235-L1259 | train |
raiden-network/raiden | raiden/network/proxies/user_deposit.py | UserDeposit.deposit | def deposit(
self,
beneficiary: Address,
total_deposit: TokenAmount,
block_identifier: BlockSpecification,
) -> None:
""" Deposit provided amount into the user-deposit contract
to the beneficiary's account. """
token_address = self.token_addre... | python | def deposit(
self,
beneficiary: Address,
total_deposit: TokenAmount,
block_identifier: BlockSpecification,
) -> None:
""" Deposit provided amount into the user-deposit contract
to the beneficiary's account. """
token_address = self.token_addre... | [
"def",
"deposit",
"(",
"self",
",",
"beneficiary",
":",
"Address",
",",
"total_deposit",
":",
"TokenAmount",
",",
"block_identifier",
":",
"BlockSpecification",
",",
")",
"->",
"None",
":",
"token_address",
"=",
"self",
".",
"token_address",
"(",
"block_identifi... | Deposit provided amount into the user-deposit contract
to the beneficiary's account. | [
"Deposit",
"provided",
"amount",
"into",
"the",
"user",
"-",
"deposit",
"contract",
"to",
"the",
"beneficiary",
"s",
"account",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/user_deposit.py#L68-L144 | train |
raiden-network/raiden | raiden/network/proxies/user_deposit.py | UserDeposit.effective_balance | def effective_balance(self, address: Address, block_identifier: BlockSpecification) -> Balance:
""" The user's balance with planned withdrawals deducted. """
fn = getattr(self.proxy.contract.functions, 'effectiveBalance')
balance = fn(address).call(block_identifier=block_identifier)
if ... | python | def effective_balance(self, address: Address, block_identifier: BlockSpecification) -> Balance:
""" The user's balance with planned withdrawals deducted. """
fn = getattr(self.proxy.contract.functions, 'effectiveBalance')
balance = fn(address).call(block_identifier=block_identifier)
if ... | [
"def",
"effective_balance",
"(",
"self",
",",
"address",
":",
"Address",
",",
"block_identifier",
":",
"BlockSpecification",
")",
"->",
"Balance",
":",
"fn",
"=",
"getattr",
"(",
"self",
".",
"proxy",
".",
"contract",
".",
"functions",
",",
"'effectiveBalance'... | The user's balance with planned withdrawals deducted. | [
"The",
"user",
"s",
"balance",
"with",
"planned",
"withdrawals",
"deducted",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/user_deposit.py#L146-L154 | train |
raiden-network/raiden | raiden/encoding/encoders.py | integer.validate | def validate(self, value: int):
''' Validates the integer is in the value range. '''
if not isinstance(value, int):
raise ValueError('value is not an integer')
if self.minimum > value or self.maximum < value:
msg = (
'{} is outside the valide range [{},{}... | python | def validate(self, value: int):
''' Validates the integer is in the value range. '''
if not isinstance(value, int):
raise ValueError('value is not an integer')
if self.minimum > value or self.maximum < value:
msg = (
'{} is outside the valide range [{},{}... | [
"def",
"validate",
"(",
"self",
",",
"value",
":",
"int",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"raise",
"ValueError",
"(",
"'value is not an integer'",
")",
"if",
"self",
".",
"minimum",
">",
"value",
"or",
"self",
"... | Validates the integer is in the value range. | [
"Validates",
"the",
"integer",
"is",
"in",
"the",
"value",
"range",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/encoding/encoders.py#L11-L20 | train |
raiden-network/raiden | raiden/api/python.py | event_filter_for_payments | def event_filter_for_payments(
event: architecture.Event,
token_network_identifier: TokenNetworkID = None,
partner_address: Address = None,
) -> bool:
"""Filters out non payment history related events
- If no other args are given, all payment related events match
- If a token networ... | python | def event_filter_for_payments(
event: architecture.Event,
token_network_identifier: TokenNetworkID = None,
partner_address: Address = None,
) -> bool:
"""Filters out non payment history related events
- If no other args are given, all payment related events match
- If a token networ... | [
"def",
"event_filter_for_payments",
"(",
"event",
":",
"architecture",
".",
"Event",
",",
"token_network_identifier",
":",
"TokenNetworkID",
"=",
"None",
",",
"partner_address",
":",
"Address",
"=",
"None",
",",
")",
"->",
"bool",
":",
"is_matching_event",
"=",
... | Filters out non payment history related events
- If no other args are given, all payment related events match
- If a token network identifier is given then only payment events for that match
- If a partner is also given then if the event is a payment sent event and the
target matches it's returned. I... | [
"Filters",
"out",
"non",
"payment",
"history",
"related",
"events"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L83-L120 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.token_network_register | def token_network_register(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
channel_participant_deposit_limit: TokenAmount,
token_network_deposit_limit: TokenAmount,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
... | python | def token_network_register(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
channel_participant_deposit_limit: TokenAmount,
token_network_deposit_limit: TokenAmount,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
... | [
"def",
"token_network_register",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"channel_participant_deposit_limit",
":",
"TokenAmount",
",",
"token_network_deposit_limit",
":",
"TokenAmount",
",",
"retry_timeo... | Register the `token_address` in the blockchain. If the address is already
registered but the event has not been processed this function will block
until the next block to make sure the event is processed.
Raises:
InvalidAddress: If the registry_address or token_address is not ... | [
"Register",
"the",
"token_address",
"in",
"the",
"blockchain",
".",
"If",
"the",
"address",
"is",
"already",
"registered",
"but",
"the",
"event",
"has",
"not",
"been",
"processed",
"this",
"function",
"will",
"block",
"until",
"the",
"next",
"block",
"to",
"... | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L220-L279 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.token_network_connect | def token_network_connect(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
funds: TokenAmount,
initial_channel_target: int = 3,
joinable_funds_target: float = 0.4,
) -> None:
""" Automatically maintain channels op... | python | def token_network_connect(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
funds: TokenAmount,
initial_channel_target: int = 3,
joinable_funds_target: float = 0.4,
) -> None:
""" Automatically maintain channels op... | [
"def",
"token_network_connect",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"funds",
":",
"TokenAmount",
",",
"initial_channel_target",
":",
"int",
"=",
"3",
",",
"joinable_funds_target",
":",
"float... | Automatically maintain channels open for the given token network.
Args:
token_address: the ERC20 token network to connect to.
funds: the amount of funds that can be used by the ConnectionMananger.
initial_channel_target: number of channels to open proactively.
jo... | [
"Automatically",
"maintain",
"channels",
"open",
"for",
"the",
"given",
"token",
"network",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L281-L329 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.token_network_leave | def token_network_leave(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
""" Close all channels and wait for settlement. """
if not is_binary_address(registry_address):
raise InvalidAddress('regist... | python | def token_network_leave(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
) -> List[NettingChannelState]:
""" Close all channels and wait for settlement. """
if not is_binary_address(registry_address):
raise InvalidAddress('regist... | [
"def",
"token_network_leave",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
")",
"->",
"List",
"[",
"NettingChannelState",
"]",
":",
"if",
"not",
"is_binary_address",
"(",
"registry_address",
")",
":... | Close all channels and wait for settlement. | [
"Close",
"all",
"channels",
"and",
"wait",
"for",
"settlement",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L331-L355 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.channel_open | def channel_open(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
partner_address: Address,
settle_timeout: BlockTimeout = None,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
) -> ChannelID:
""" Open a ch... | python | def channel_open(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
partner_address: Address,
settle_timeout: BlockTimeout = None,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
) -> ChannelID:
""" Open a ch... | [
"def",
"channel_open",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"partner_address",
":",
"Address",
",",
"settle_timeout",
":",
"BlockTimeout",
"=",
"None",
",",
"retry_timeout",
":",
"NetworkTimeo... | Open a channel with the peer at `partner_address`
with the given `token_address`. | [
"Open",
"a",
"channel",
"with",
"the",
"peer",
"at",
"partner_address",
"with",
"the",
"given",
"token_address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L357-L447 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.set_total_channel_deposit | def set_total_channel_deposit(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
partner_address: Address,
total_deposit: TokenAmount,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
):
""" Set the `total_dep... | python | def set_total_channel_deposit(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
partner_address: Address,
total_deposit: TokenAmount,
retry_timeout: NetworkTimeout = DEFAULT_RETRY_TIMEOUT,
):
""" Set the `total_dep... | [
"def",
"set_total_channel_deposit",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"partner_address",
":",
"Address",
",",
"total_deposit",
":",
"TokenAmount",
",",
"retry_timeout",
":",
"NetworkTimeout",
... | Set the `total_deposit` in the channel with the peer at `partner_address` and the
given `token_address` in order to be able to do transfers.
Raises:
InvalidAddress: If either token_address or partner_address is not
20 bytes long.
TransactionThrew: May happen for ... | [
"Set",
"the",
"total_deposit",
"in",
"the",
"channel",
"with",
"the",
"peer",
"at",
"partner_address",
"and",
"the",
"given",
"token_address",
"in",
"order",
"to",
"be",
"able",
"to",
"do",
"transfers",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L449-L563 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.get_node_network_state | def get_node_network_state(self, node_address: Address):
""" Returns the currently network status of `node_address`. """
return views.get_node_network_status(
chain_state=views.state_from_raiden(self.raiden),
node_address=node_address,
) | python | def get_node_network_state(self, node_address: Address):
""" Returns the currently network status of `node_address`. """
return views.get_node_network_status(
chain_state=views.state_from_raiden(self.raiden),
node_address=node_address,
) | [
"def",
"get_node_network_state",
"(",
"self",
",",
"node_address",
":",
"Address",
")",
":",
"return",
"views",
".",
"get_node_network_status",
"(",
"chain_state",
"=",
"views",
".",
"state_from_raiden",
"(",
"self",
".",
"raiden",
")",
",",
"node_address",
"=",... | Returns the currently network status of `node_address`. | [
"Returns",
"the",
"currently",
"network",
"status",
"of",
"node_address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L701-L706 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.get_tokens_list | def get_tokens_list(self, registry_address: PaymentNetworkID):
"""Returns a list of tokens the node knows about"""
tokens_list = views.get_token_identifiers(
chain_state=views.state_from_raiden(self.raiden),
payment_network_id=registry_address,
)
return tokens_lis... | python | def get_tokens_list(self, registry_address: PaymentNetworkID):
"""Returns a list of tokens the node knows about"""
tokens_list = views.get_token_identifiers(
chain_state=views.state_from_raiden(self.raiden),
payment_network_id=registry_address,
)
return tokens_lis... | [
"def",
"get_tokens_list",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
")",
":",
"tokens_list",
"=",
"views",
".",
"get_token_identifiers",
"(",
"chain_state",
"=",
"views",
".",
"state_from_raiden",
"(",
"self",
".",
"raiden",
")",
",",
"payme... | Returns a list of tokens the node knows about | [
"Returns",
"a",
"list",
"of",
"tokens",
"the",
"node",
"knows",
"about"
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L712-L718 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.transfer_and_wait | def transfer_and_wait(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
amount: TokenAmount,
target: Address,
identifier: PaymentID = None,
transfer_timeout: int = None,
secret: Secret = None,
... | python | def transfer_and_wait(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
amount: TokenAmount,
target: Address,
identifier: PaymentID = None,
transfer_timeout: int = None,
secret: Secret = None,
... | [
"def",
"transfer_and_wait",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"amount",
":",
"TokenAmount",
",",
"target",
":",
"Address",
",",
"identifier",
":",
"PaymentID",
"=",
"None",
",",
"transf... | Do a transfer with `target` with the given `amount` of `token_address`. | [
"Do",
"a",
"transfer",
"with",
"target",
"with",
"the",
"given",
"amount",
"of",
"token_address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L731-L755 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.get_blockchain_events_token_network | def get_blockchain_events_token_network(
self,
token_address: TokenAddress,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
):
"""Returns a list of blockchain events coresponding to the token_address."""
... | python | def get_blockchain_events_token_network(
self,
token_address: TokenAddress,
from_block: BlockSpecification = GENESIS_BLOCK_NUMBER,
to_block: BlockSpecification = 'latest',
):
"""Returns a list of blockchain events coresponding to the token_address."""
... | [
"def",
"get_blockchain_events_token_network",
"(",
"self",
",",
"token_address",
":",
"TokenAddress",
",",
"from_block",
":",
"BlockSpecification",
"=",
"GENESIS_BLOCK_NUMBER",
",",
"to_block",
":",
"BlockSpecification",
"=",
"'latest'",
",",
")",
":",
"if",
"not",
... | Returns a list of blockchain events coresponding to the token_address. | [
"Returns",
"a",
"list",
"of",
"blockchain",
"events",
"coresponding",
"to",
"the",
"token_address",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L922-L956 | train |
raiden-network/raiden | raiden/api/python.py | RaidenAPI.create_monitoring_request | def create_monitoring_request(
self,
balance_proof: BalanceProofSignedState,
reward_amount: TokenAmount,
) -> Optional[RequestMonitoring]:
""" This method can be used to create a `RequestMonitoring` message.
It will contain all data necessary for an external monit... | python | def create_monitoring_request(
self,
balance_proof: BalanceProofSignedState,
reward_amount: TokenAmount,
) -> Optional[RequestMonitoring]:
""" This method can be used to create a `RequestMonitoring` message.
It will contain all data necessary for an external monit... | [
"def",
"create_monitoring_request",
"(",
"self",
",",
"balance_proof",
":",
"BalanceProofSignedState",
",",
"reward_amount",
":",
"TokenAmount",
",",
")",
"->",
"Optional",
"[",
"RequestMonitoring",
"]",
":",
"# create RequestMonitoring message from the above + `reward_amount... | This method can be used to create a `RequestMonitoring` message.
It will contain all data necessary for an external monitoring service to
- send an updateNonClosingBalanceProof transaction to the TokenNetwork contract,
for the `balance_proof` that we received from a channel partner.
- cl... | [
"This",
"method",
"can",
"be",
"used",
"to",
"create",
"a",
"RequestMonitoring",
"message",
".",
"It",
"will",
"contain",
"all",
"data",
"necessary",
"for",
"an",
"external",
"monitoring",
"service",
"to",
"-",
"send",
"an",
"updateNonClosingBalanceProof",
"tran... | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L995-L1013 | train |
raiden-network/raiden | raiden/transfer/mediated_transfer/state.py | lockedtransfersigned_from_message | def lockedtransfersigned_from_message(message: 'LockedTransfer') -> 'LockedTransferSignedState':
""" Create LockedTransferSignedState from a LockedTransfer message. """
balance_proof = balanceproof_from_envelope(message)
lock = HashTimeLockState(
message.lock.amount,
message.lock.expiration... | python | def lockedtransfersigned_from_message(message: 'LockedTransfer') -> 'LockedTransferSignedState':
""" Create LockedTransferSignedState from a LockedTransfer message. """
balance_proof = balanceproof_from_envelope(message)
lock = HashTimeLockState(
message.lock.amount,
message.lock.expiration... | [
"def",
"lockedtransfersigned_from_message",
"(",
"message",
":",
"'LockedTransfer'",
")",
"->",
"'LockedTransferSignedState'",
":",
"balance_proof",
"=",
"balanceproof_from_envelope",
"(",
"message",
")",
"lock",
"=",
"HashTimeLockState",
"(",
"message",
".",
"lock",
".... | Create LockedTransferSignedState from a LockedTransfer message. | [
"Create",
"LockedTransferSignedState",
"from",
"a",
"LockedTransfer",
"message",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/state.py#L51-L71 | train |
raiden-network/raiden | raiden/ui/cli.py | version | def version(short):
"""Print version information and exit. """
if short:
print(get_system_spec()['raiden'])
else:
print(json.dumps(
get_system_spec(),
indent=2,
)) | python | def version(short):
"""Print version information and exit. """
if short:
print(get_system_spec()['raiden'])
else:
print(json.dumps(
get_system_spec(),
indent=2,
)) | [
"def",
"version",
"(",
"short",
")",
":",
"if",
"short",
":",
"print",
"(",
"get_system_spec",
"(",
")",
"[",
"'raiden'",
"]",
")",
"else",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"get_system_spec",
"(",
")",
",",
"indent",
"=",
"2",
",",
")"... | Print version information and exit. | [
"Print",
"version",
"information",
"and",
"exit",
"."
] | 407ba15c72074e9de88771d6b9661ff4dc36bef5 | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/ui/cli.py#L553-L561 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.