id
int32
0
252k
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
221,500
raiden-network/raiden
raiden/transfer/mediated_transfer/target.py
state_transition
def state_transition( target_state: Optional[TargetTransferState], state_change: StateChange, channel_state: NettingChannelState, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> TransitionResult[TargetTransferState]: """ State machine for the target no...
python
def state_transition( target_state: Optional[TargetTransferState], state_change: StateChange, channel_state: NettingChannelState, pseudo_random_generator: random.Random, block_number: BlockNumber, ) -> TransitionResult[TargetTransferState]: """ State machine for the target no...
[ "def", "state_transition", "(", "target_state", ":", "Optional", "[", "TargetTransferState", "]", ",", "state_change", ":", "StateChange", ",", "channel_state", ":", "NettingChannelState", ",", "pseudo_random_generator", ":", "random", ".", "Random", ",", "block_numbe...
State machine for the target node of a mediated transfer.
[ "State", "machine", "for", "the", "target", "node", "of", "a", "mediated", "transfer", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/target.py#L352-L426
221,501
raiden-network/raiden
raiden/encoding/messages.py
wrap
def wrap(data): """ Try to decode data into a message, might return None if the data is invalid. """ try: cmdid = data[0] except IndexError: log.warning('data is empty') return None try: message_type = CMDID_MESSAGE[cmdid] except KeyError: log.error('unknown ...
python
def wrap(data): """ Try to decode data into a message, might return None if the data is invalid. """ try: cmdid = data[0] except IndexError: log.warning('data is empty') return None try: message_type = CMDID_MESSAGE[cmdid] except KeyError: log.error('unknown ...
[ "def", "wrap", "(", "data", ")", ":", "try", ":", "cmdid", "=", "data", "[", "0", "]", "except", "IndexError", ":", "log", ".", "warning", "(", "'data is empty'", ")", "return", "None", "try", ":", "message_type", "=", "CMDID_MESSAGE", "[", "cmdid", "]...
Try to decode data into a message, might return None if the data is invalid.
[ "Try", "to", "decode", "data", "into", "a", "message", "might", "return", "None", "if", "the", "data", "is", "invalid", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/encoding/messages.py#L286-L306
221,502
raiden-network/raiden
raiden/utils/solc.py
solidity_resolve_address
def solidity_resolve_address(hex_code, library_symbol, library_address): """ Change the bytecode to use the given library address. Args: hex_code (bin): The bytecode encoded in hexadecimal. library_name (str): The library that will be resolved. library_address (str): The address of the ...
python
def solidity_resolve_address(hex_code, library_symbol, library_address): """ Change the bytecode to use the given library address. Args: hex_code (bin): The bytecode encoded in hexadecimal. library_name (str): The library that will be resolved. library_address (str): The address of the ...
[ "def", "solidity_resolve_address", "(", "hex_code", ",", "library_symbol", ",", "library_address", ")", ":", "if", "library_address", ".", "startswith", "(", "'0x'", ")", ":", "raise", "ValueError", "(", "'Address should not contain the 0x prefix'", ")", "try", ":", ...
Change the bytecode to use the given library address. Args: hex_code (bin): The bytecode encoded in hexadecimal. library_name (str): The library that will be resolved. library_address (str): The address of the library. Returns: bin: The bytecode encoded in hexadecimal with the ...
[ "Change", "the", "bytecode", "to", "use", "the", "given", "library", "address", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/solc.py#L8-L32
221,503
raiden-network/raiden
raiden/utils/solc.py
solidity_library_symbol
def solidity_library_symbol(library_name): """ Return the symbol used in the bytecode to represent the `library_name`. """ # the symbol is always 40 characters in length with the minimum of two # leading and trailing underscores length = min(len(library_name), 36) library_piece = library_name[:leng...
python
def solidity_library_symbol(library_name): """ Return the symbol used in the bytecode to represent the `library_name`. """ # the symbol is always 40 characters in length with the minimum of two # leading and trailing underscores length = min(len(library_name), 36) library_piece = library_name[:leng...
[ "def", "solidity_library_symbol", "(", "library_name", ")", ":", "# the symbol is always 40 characters in length with the minimum of two", "# leading and trailing underscores", "length", "=", "min", "(", "len", "(", "library_name", ")", ",", "36", ")", "library_piece", "=", ...
Return the symbol used in the bytecode to represent the `library_name`.
[ "Return", "the", "symbol", "used", "in", "the", "bytecode", "to", "represent", "the", "library_name", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/solc.py#L48-L60
221,504
raiden-network/raiden
raiden/utils/solc.py
compile_files_cwd
def compile_files_cwd(*args, **kwargs): """change working directory to contract's dir in order to avoid symbol name conflicts""" # get root directory of the contracts compile_wd = os.path.commonprefix(args[0]) # edge case - compiling a single file if os.path.isfile(compile_wd): compile_w...
python
def compile_files_cwd(*args, **kwargs): """change working directory to contract's dir in order to avoid symbol name conflicts""" # get root directory of the contracts compile_wd = os.path.commonprefix(args[0]) # edge case - compiling a single file if os.path.isfile(compile_wd): compile_w...
[ "def", "compile_files_cwd", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# get root directory of the contracts", "compile_wd", "=", "os", ".", "path", ".", "commonprefix", "(", "args", "[", "0", "]", ")", "# edge case - compiling a single file", "if", "...
change working directory to contract's dir in order to avoid symbol name conflicts
[ "change", "working", "directory", "to", "contract", "s", "dir", "in", "order", "to", "avoid", "symbol", "name", "conflicts" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/solc.py#L76-L104
221,505
raiden-network/raiden
raiden/accounts.py
AccountManager.get_privkey
def get_privkey(self, address: AddressHex, password: str) -> PrivateKey: """Find the keystore file for an account, unlock it and get the private key Args: address: The Ethereum address for which to find the keyfile in the system password: Mostly for testing purposes. A password ...
python
def get_privkey(self, address: AddressHex, password: str) -> PrivateKey: """Find the keystore file for an account, unlock it and get the private key Args: address: The Ethereum address for which to find the keyfile in the system password: Mostly for testing purposes. A password ...
[ "def", "get_privkey", "(", "self", ",", "address", ":", "AddressHex", ",", "password", ":", "str", ")", "->", "PrivateKey", ":", "address", "=", "add_0x_prefix", "(", "address", ")", ".", "lower", "(", ")", "if", "not", "self", ".", "address_in_keystore", ...
Find the keystore file for an account, unlock it and get the private key Args: address: The Ethereum address for which to find the keyfile in the system password: Mostly for testing purposes. A password can be provided as the function argument here. If it's no...
[ "Find", "the", "keystore", "file", "for", "an", "account", "unlock", "it", "and", "get", "the", "private", "key" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L135-L155
221,506
raiden-network/raiden
raiden/accounts.py
Account.load
def load(cls, path: str, password: str = None) -> 'Account': """Load an account from a keystore file. Args: path: full path to the keyfile password: the password to decrypt the key file or `None` to leave it encrypted """ with open(path) as f: keystor...
python
def load(cls, path: str, password: str = None) -> 'Account': """Load an account from a keystore file. Args: path: full path to the keyfile password: the password to decrypt the key file or `None` to leave it encrypted """ with open(path) as f: keystor...
[ "def", "load", "(", "cls", ",", "path", ":", "str", ",", "password", ":", "str", "=", "None", ")", "->", "'Account'", ":", "with", "open", "(", "path", ")", "as", "f", ":", "keystore", "=", "json", ".", "load", "(", "f", ")", "if", "not", "chec...
Load an account from a keystore file. Args: path: full path to the keyfile password: the password to decrypt the key file or `None` to leave it encrypted
[ "Load", "an", "account", "from", "a", "keystore", "file", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L186-L197
221,507
raiden-network/raiden
raiden/accounts.py
Account.dump
def dump(self, include_address=True, include_id=True) -> str: """Dump the keystore for later disk storage. The result inherits the entries `'crypto'` and `'version`' from `account.keystore`, and adds `'address'` and `'id'` in accordance with the parameters `'include_address'` and `'incl...
python
def dump(self, include_address=True, include_id=True) -> str: """Dump the keystore for later disk storage. The result inherits the entries `'crypto'` and `'version`' from `account.keystore`, and adds `'address'` and `'id'` in accordance with the parameters `'include_address'` and `'incl...
[ "def", "dump", "(", "self", ",", "include_address", "=", "True", ",", "include_id", "=", "True", ")", "->", "str", ":", "d", "=", "{", "'crypto'", ":", "self", ".", "keystore", "[", "'crypto'", "]", ",", "'version'", ":", "self", ".", "keystore", "["...
Dump the keystore for later disk storage. The result inherits the entries `'crypto'` and `'version`' from `account.keystore`, and adds `'address'` and `'id'` in accordance with the parameters `'include_address'` and `'include_id`'. If address or id are not known, they are not added, ev...
[ "Dump", "the", "keystore", "for", "later", "disk", "storage", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L199-L220
221,508
raiden-network/raiden
raiden/accounts.py
Account.unlock
def unlock(self, password: str): """Unlock the account with a password. If the account is already unlocked, nothing happens, even if the password is wrong. Raises: ValueError: (originating in ethereum.keys) if the password is wrong (and the account is locked) ""...
python
def unlock(self, password: str): """Unlock the account with a password. If the account is already unlocked, nothing happens, even if the password is wrong. Raises: ValueError: (originating in ethereum.keys) if the password is wrong (and the account is locked) ""...
[ "def", "unlock", "(", "self", ",", "password", ":", "str", ")", ":", "if", "self", ".", "locked", ":", "self", ".", "_privkey", "=", "decode_keyfile_json", "(", "self", ".", "keystore", ",", "password", ".", "encode", "(", "'UTF-8'", ")", ")", "self", ...
Unlock the account with a password. If the account is already unlocked, nothing happens, even if the password is wrong. Raises: ValueError: (originating in ethereum.keys) if the password is wrong (and the account is locked)
[ "Unlock", "the", "account", "with", "a", "password", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L222-L235
221,509
raiden-network/raiden
raiden/accounts.py
Account.uuid
def uuid(self, value): """Set the UUID. Set it to `None` in order to remove it.""" if value is not None: self.keystore['id'] = value elif 'id' in self.keystore: self.keystore.pop('id')
python
def uuid(self, value): """Set the UUID. Set it to `None` in order to remove it.""" if value is not None: self.keystore['id'] = value elif 'id' in self.keystore: self.keystore.pop('id')
[ "def", "uuid", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "self", ".", "keystore", "[", "'id'", "]", "=", "value", "elif", "'id'", "in", "self", ".", "keystore", ":", "self", ".", "keystore", ".", "pop", "(", "'...
Set the UUID. Set it to `None` in order to remove it.
[ "Set", "the", "UUID", ".", "Set", "it", "to", "None", "in", "order", "to", "remove", "it", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/accounts.py#L289-L294
221,510
raiden-network/raiden
raiden/storage/migrations/v21_to_v22.py
recover_chain_id
def recover_chain_id(storage: SQLiteStorage) -> ChainID: """We can reasonably assume, that any database has only one value for `chain_id` at this point in time. """ action_init_chain = json.loads(storage.get_state_changes(limit=1, offset=0)[0]) assert action_init_chain['_type'] == 'raiden.transfer....
python
def recover_chain_id(storage: SQLiteStorage) -> ChainID: """We can reasonably assume, that any database has only one value for `chain_id` at this point in time. """ action_init_chain = json.loads(storage.get_state_changes(limit=1, offset=0)[0]) assert action_init_chain['_type'] == 'raiden.transfer....
[ "def", "recover_chain_id", "(", "storage", ":", "SQLiteStorage", ")", "->", "ChainID", ":", "action_init_chain", "=", "json", ".", "loads", "(", "storage", ".", "get_state_changes", "(", "limit", "=", "1", ",", "offset", "=", "0", ")", "[", "0", "]", ")"...
We can reasonably assume, that any database has only one value for `chain_id` at this point in time.
[ "We", "can", "reasonably", "assume", "that", "any", "database", "has", "only", "one", "value", "for", "chain_id", "at", "this", "point", "in", "time", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v21_to_v22.py#L366-L373
221,511
raiden-network/raiden
tools/scenario-player/scenario_player/runner.py
ScenarioRunner.determine_run_number
def determine_run_number(self) -> int: """Determine the current run number. We check for a run number file, and use any number that is logged there after incrementing it. """ run_number = 0 run_number_file = self.data_path.joinpath('run_number.txt') if run_number...
python
def determine_run_number(self) -> int: """Determine the current run number. We check for a run number file, and use any number that is logged there after incrementing it. """ run_number = 0 run_number_file = self.data_path.joinpath('run_number.txt') if run_number...
[ "def", "determine_run_number", "(", "self", ")", "->", "int", ":", "run_number", "=", "0", "run_number_file", "=", "self", ".", "data_path", ".", "joinpath", "(", "'run_number.txt'", ")", "if", "run_number_file", ".", "exists", "(", ")", ":", "run_number", "...
Determine the current run number. We check for a run number file, and use any number that is logged there after incrementing it.
[ "Determine", "the", "current", "run", "number", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/runner.py#L125-L137
221,512
raiden-network/raiden
tools/scenario-player/scenario_player/runner.py
ScenarioRunner.select_chain
def select_chain(self, chain_urls: Dict[str, List[str]]) -> Tuple[str, List[str]]: """Select a chain and return its name and RPC URL. If the currently loaded scenario's designated chain is set to 'any', we randomly select a chain from the given `chain_urls`. Otherwise, we will return `S...
python
def select_chain(self, chain_urls: Dict[str, List[str]]) -> Tuple[str, List[str]]: """Select a chain and return its name and RPC URL. If the currently loaded scenario's designated chain is set to 'any', we randomly select a chain from the given `chain_urls`. Otherwise, we will return `S...
[ "def", "select_chain", "(", "self", ",", "chain_urls", ":", "Dict", "[", "str", ",", "List", "[", "str", "]", "]", ")", "->", "Tuple", "[", "str", ",", "List", "[", "str", "]", "]", ":", "chain_name", "=", "self", ".", "scenario", ".", "chain_name"...
Select a chain and return its name and RPC URL. If the currently loaded scenario's designated chain is set to 'any', we randomly select a chain from the given `chain_urls`. Otherwise, we will return `ScenarioRunner.scenario.chain_name` and whatever value may be associated with this key ...
[ "Select", "a", "chain", "and", "return", "its", "name", "and", "RPC", "URL", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/scenario-player/scenario_player/runner.py#L139-L161
221,513
raiden-network/raiden
raiden/transfer/balance_proof.py
pack_balance_proof
def pack_balance_proof( nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, canonical_identifier: CanonicalIdentifier, msg_type: MessageTypeId = MessageTypeId.BALANCE_PROOF, ) -> bytes: """Packs balance proof data to be signed Packs the given argume...
python
def pack_balance_proof( nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, canonical_identifier: CanonicalIdentifier, msg_type: MessageTypeId = MessageTypeId.BALANCE_PROOF, ) -> bytes: """Packs balance proof data to be signed Packs the given argume...
[ "def", "pack_balance_proof", "(", "nonce", ":", "Nonce", ",", "balance_hash", ":", "BalanceHash", ",", "additional_hash", ":", "AdditionalHash", ",", "canonical_identifier", ":", "CanonicalIdentifier", ",", "msg_type", ":", "MessageTypeId", "=", "MessageTypeId", ".", ...
Packs balance proof data to be signed Packs the given arguments in a byte array in the same configuration the contracts expect the signed data to have.
[ "Packs", "balance", "proof", "data", "to", "be", "signed" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/balance_proof.py#L7-L35
221,514
raiden-network/raiden
raiden/transfer/balance_proof.py
pack_balance_proof_update
def pack_balance_proof_update( nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, canonical_identifier: CanonicalIdentifier, partner_signature: Signature, ) -> bytes: """Packs balance proof data to be signed for updateNonClosingBalanceProof Packs t...
python
def pack_balance_proof_update( nonce: Nonce, balance_hash: BalanceHash, additional_hash: AdditionalHash, canonical_identifier: CanonicalIdentifier, partner_signature: Signature, ) -> bytes: """Packs balance proof data to be signed for updateNonClosingBalanceProof Packs t...
[ "def", "pack_balance_proof_update", "(", "nonce", ":", "Nonce", ",", "balance_hash", ":", "BalanceHash", ",", "additional_hash", ":", "AdditionalHash", ",", "canonical_identifier", ":", "CanonicalIdentifier", ",", "partner_signature", ":", "Signature", ",", ")", "->",...
Packs balance proof data to be signed for updateNonClosingBalanceProof Packs the given arguments in a byte array in the same configuration the contracts expect the signed data for updateNonClosingBalanceProof to have.
[ "Packs", "balance", "proof", "data", "to", "be", "signed", "for", "updateNonClosingBalanceProof" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/balance_proof.py#L38-L56
221,515
raiden-network/raiden
raiden/network/transport/udp/healthcheck.py
healthcheck
def healthcheck( transport: 'UDPTransport', recipient: Address, stop_event: Event, event_healthy: Event, event_unhealthy: Event, nat_keepalive_retries: int, nat_keepalive_timeout: int, nat_invitation_timeout: int, ping_nonce: Dict[str, Nonce], ): ...
python
def healthcheck( transport: 'UDPTransport', recipient: Address, stop_event: Event, event_healthy: Event, event_unhealthy: Event, nat_keepalive_retries: int, nat_keepalive_timeout: int, nat_invitation_timeout: int, ping_nonce: Dict[str, Nonce], ): ...
[ "def", "healthcheck", "(", "transport", ":", "'UDPTransport'", ",", "recipient", ":", "Address", ",", "stop_event", ":", "Event", ",", "event_healthy", ":", "Event", ",", "event_unhealthy", ":", "Event", ",", "nat_keepalive_retries", ":", "int", ",", "nat_keepal...
Sends a periodical Ping to `recipient` to check its health.
[ "Sends", "a", "periodical", "Ping", "to", "recipient", "to", "check", "its", "health", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/transport/udp/healthcheck.py#L32-L171
221,516
raiden-network/raiden
raiden/network/proxies/token_network_registry.py
TokenNetworkRegistry.get_token_network
def get_token_network( self, token_address: TokenAddress, block_identifier: BlockSpecification = 'latest', ) -> Optional[Address]: """ Return the token network address for the given token or None if there is no correspoding address. """ if not isin...
python
def get_token_network( self, token_address: TokenAddress, block_identifier: BlockSpecification = 'latest', ) -> Optional[Address]: """ Return the token network address for the given token or None if there is no correspoding address. """ if not isin...
[ "def", "get_token_network", "(", "self", ",", "token_address", ":", "TokenAddress", ",", "block_identifier", ":", "BlockSpecification", "=", "'latest'", ",", ")", "->", "Optional", "[", "Address", "]", ":", "if", "not", "isinstance", "(", "token_address", ",", ...
Return the token network address for the given token or None if there is no correspoding address.
[ "Return", "the", "token", "network", "address", "for", "the", "given", "token", "or", "None", "if", "there", "is", "no", "correspoding", "address", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network_registry.py#L79-L98
221,517
raiden-network/raiden
raiden/network/proxies/token_network_registry.py
TokenNetworkRegistry.add_token_with_limits
def add_token_with_limits( self, token_address: TokenAddress, channel_participant_deposit_limit: TokenAmount, token_network_deposit_limit: TokenAmount, ) -> Address: """ Register token of `token_address` with the token network. The limits apply...
python
def add_token_with_limits( self, token_address: TokenAddress, channel_participant_deposit_limit: TokenAmount, token_network_deposit_limit: TokenAmount, ) -> Address: """ Register token of `token_address` with the token network. The limits apply...
[ "def", "add_token_with_limits", "(", "self", ",", "token_address", ":", "TokenAddress", ",", "channel_participant_deposit_limit", ":", "TokenAmount", ",", "token_network_deposit_limit", ":", "TokenAmount", ",", ")", "->", "Address", ":", "return", "self", ".", "_add_t...
Register token of `token_address` with the token network. The limits apply for version 0.13.0 and above of raiden-contracts, since instantiation also takes the limits as constructor arguments.
[ "Register", "token", "of", "token_address", "with", "the", "token", "network", ".", "The", "limits", "apply", "for", "version", "0", ".", "13", ".", "0", "and", "above", "of", "raiden", "-", "contracts", "since", "instantiation", "also", "takes", "the", "l...
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network_registry.py#L100-L117
221,518
raiden-network/raiden
raiden/network/proxies/token_network_registry.py
TokenNetworkRegistry.add_token_without_limits
def add_token_without_limits( self, token_address: TokenAddress, ) -> Address: """ Register token of `token_address` with the token network. This applies for versions prior to 0.13.0 of raiden-contracts, since limits were hardcoded into the TokenNetwork contra...
python
def add_token_without_limits( self, token_address: TokenAddress, ) -> Address: """ Register token of `token_address` with the token network. This applies for versions prior to 0.13.0 of raiden-contracts, since limits were hardcoded into the TokenNetwork contra...
[ "def", "add_token_without_limits", "(", "self", ",", "token_address", ":", "TokenAddress", ",", ")", "->", "Address", ":", "return", "self", ".", "_add_token", "(", "token_address", "=", "token_address", ",", "additional_arguments", "=", "dict", "(", ")", ",", ...
Register token of `token_address` with the token network. This applies for versions prior to 0.13.0 of raiden-contracts, since limits were hardcoded into the TokenNetwork contract.
[ "Register", "token", "of", "token_address", "with", "the", "token", "network", ".", "This", "applies", "for", "versions", "prior", "to", "0", ".", "13", ".", "0", "of", "raiden", "-", "contracts", "since", "limits", "were", "hardcoded", "into", "the", "Tok...
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/proxies/token_network_registry.py#L119-L131
221,519
raiden-network/raiden
raiden/network/utils.py
get_free_port
def get_free_port( initial_port: int = 0, socket_kind: SocketKind = SocketKind.SOCK_STREAM, reliable: bool = True, ): """ Find an unused TCP port. Unless the `reliable` parameter is set to `True` (the default) this is prone to race conditions - some other process may grab the po...
python
def get_free_port( initial_port: int = 0, socket_kind: SocketKind = SocketKind.SOCK_STREAM, reliable: bool = True, ): """ Find an unused TCP port. Unless the `reliable` parameter is set to `True` (the default) this is prone to race conditions - some other process may grab the po...
[ "def", "get_free_port", "(", "initial_port", ":", "int", "=", "0", ",", "socket_kind", ":", "SocketKind", "=", "SocketKind", ".", "SOCK_STREAM", ",", "reliable", ":", "bool", "=", "True", ",", ")", ":", "def", "_port_generator", "(", ")", ":", "if", "ini...
Find an unused TCP port. Unless the `reliable` parameter is set to `True` (the default) this is prone to race conditions - some other process may grab the port before the caller of this function has a chance to use it. When using `reliable` the port is forced into TIME_WAIT mode, ensuring that it will ...
[ "Find", "an", "unused", "TCP", "port", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/utils.py#L13-L64
221,520
raiden-network/raiden
raiden/network/utils.py
get_http_rtt
def get_http_rtt( url: str, samples: int = 3, method: str = 'head', timeout: int = 1, ) -> Optional[float]: """ Determine the average HTTP RTT to `url` over the number of `samples`. Returns `None` if the server is unreachable. """ durations = [] for _ in range(sam...
python
def get_http_rtt( url: str, samples: int = 3, method: str = 'head', timeout: int = 1, ) -> Optional[float]: """ Determine the average HTTP RTT to `url` over the number of `samples`. Returns `None` if the server is unreachable. """ durations = [] for _ in range(sam...
[ "def", "get_http_rtt", "(", "url", ":", "str", ",", "samples", ":", "int", "=", "3", ",", "method", ":", "str", "=", "'head'", ",", "timeout", ":", "int", "=", "1", ",", ")", "->", "Optional", "[", "float", "]", ":", "durations", "=", "[", "]", ...
Determine the average HTTP RTT to `url` over the number of `samples`. Returns `None` if the server is unreachable.
[ "Determine", "the", "average", "HTTP", "RTT", "to", "url", "over", "the", "number", "of", "samples", ".", "Returns", "None", "if", "the", "server", "is", "unreachable", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/network/utils.py#L67-L90
221,521
raiden-network/raiden
raiden/storage/migrations/v18_to_v19.py
_add_blockhash_to_state_changes
def _add_blockhash_to_state_changes(storage: SQLiteStorage, cache: BlockHashCache) -> None: """Adds blockhash to ContractReceiveXXX and ActionInitChain state changes""" batch_size = 50 batch_query = storage.batch_query_state_changes( batch_size=batch_size, filters=[ ('_type', 'r...
python
def _add_blockhash_to_state_changes(storage: SQLiteStorage, cache: BlockHashCache) -> None: """Adds blockhash to ContractReceiveXXX and ActionInitChain state changes""" batch_size = 50 batch_query = storage.batch_query_state_changes( batch_size=batch_size, filters=[ ('_type', 'r...
[ "def", "_add_blockhash_to_state_changes", "(", "storage", ":", "SQLiteStorage", ",", "cache", ":", "BlockHashCache", ")", "->", "None", ":", "batch_size", "=", "50", "batch_query", "=", "storage", ".", "batch_query_state_changes", "(", "batch_size", "=", "batch_size...
Adds blockhash to ContractReceiveXXX and ActionInitChain state changes
[ "Adds", "blockhash", "to", "ContractReceiveXXX", "and", "ActionInitChain", "state", "changes" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L53-L90
221,522
raiden-network/raiden
raiden/storage/migrations/v18_to_v19.py
_add_blockhash_to_events
def _add_blockhash_to_events(storage: SQLiteStorage, cache: BlockHashCache) -> None: """Adds blockhash to all ContractSendXXX events""" batch_query = storage.batch_query_event_records( batch_size=500, filters=[('_type', 'raiden.transfer.events.ContractSend%')], ) for events_batch in batc...
python
def _add_blockhash_to_events(storage: SQLiteStorage, cache: BlockHashCache) -> None: """Adds blockhash to all ContractSendXXX events""" batch_query = storage.batch_query_event_records( batch_size=500, filters=[('_type', 'raiden.transfer.events.ContractSend%')], ) for events_batch in batc...
[ "def", "_add_blockhash_to_events", "(", "storage", ":", "SQLiteStorage", ",", "cache", ":", "BlockHashCache", ")", "->", "None", ":", "batch_query", "=", "storage", ".", "batch_query_event_records", "(", "batch_size", "=", "500", ",", "filters", "=", "[", "(", ...
Adds blockhash to all ContractSendXXX events
[ "Adds", "blockhash", "to", "all", "ContractSendXXX", "events" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L93-L125
221,523
raiden-network/raiden
raiden/storage/migrations/v18_to_v19.py
_transform_snapshot
def _transform_snapshot( raw_snapshot: str, storage: SQLiteStorage, cache: BlockHashCache, ) -> str: """Upgrades a single snapshot by adding the blockhash to it and to any pending transactions""" snapshot = json.loads(raw_snapshot) block_number = int(snapshot['block_number']) sna...
python
def _transform_snapshot( raw_snapshot: str, storage: SQLiteStorage, cache: BlockHashCache, ) -> str: """Upgrades a single snapshot by adding the blockhash to it and to any pending transactions""" snapshot = json.loads(raw_snapshot) block_number = int(snapshot['block_number']) sna...
[ "def", "_transform_snapshot", "(", "raw_snapshot", ":", "str", ",", "storage", ":", "SQLiteStorage", ",", "cache", ":", "BlockHashCache", ",", ")", "->", "str", ":", "snapshot", "=", "json", ".", "loads", "(", "raw_snapshot", ")", "block_number", "=", "int",...
Upgrades a single snapshot by adding the blockhash to it and to any pending transactions
[ "Upgrades", "a", "single", "snapshot", "by", "adding", "the", "blockhash", "to", "it", "and", "to", "any", "pending", "transactions" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L128-L162
221,524
raiden-network/raiden
raiden/storage/migrations/v18_to_v19.py
_transform_snapshots_for_blockhash
def _transform_snapshots_for_blockhash(storage: SQLiteStorage, cache: BlockHashCache) -> None: """Upgrades the snapshots by adding the blockhash to it and to any pending transactions""" snapshots = storage.get_snapshots() snapshot_records = [ TransformSnapshotRecord( data=snapshot.data,...
python
def _transform_snapshots_for_blockhash(storage: SQLiteStorage, cache: BlockHashCache) -> None: """Upgrades the snapshots by adding the blockhash to it and to any pending transactions""" snapshots = storage.get_snapshots() snapshot_records = [ TransformSnapshotRecord( data=snapshot.data,...
[ "def", "_transform_snapshots_for_blockhash", "(", "storage", ":", "SQLiteStorage", ",", "cache", ":", "BlockHashCache", ")", "->", "None", ":", "snapshots", "=", "storage", ".", "get_snapshots", "(", ")", "snapshot_records", "=", "[", "TransformSnapshotRecord", "(",...
Upgrades the snapshots by adding the blockhash to it and to any pending transactions
[ "Upgrades", "the", "snapshots", "by", "adding", "the", "blockhash", "to", "it", "and", "to", "any", "pending", "transactions" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L181-L201
221,525
raiden-network/raiden
raiden/storage/migrations/v18_to_v19.py
BlockHashCache.get
def get(self, block_number: BlockNumber) -> str: """Given a block number returns the hex representation of the blockhash""" if block_number in self.mapping: return self.mapping[block_number] block_hash = self.web3.eth.getBlock(block_number)['hash'] block_hash = block_hash.he...
python
def get(self, block_number: BlockNumber) -> str: """Given a block number returns the hex representation of the blockhash""" if block_number in self.mapping: return self.mapping[block_number] block_hash = self.web3.eth.getBlock(block_number)['hash'] block_hash = block_hash.he...
[ "def", "get", "(", "self", ",", "block_number", ":", "BlockNumber", ")", "->", "str", ":", "if", "block_number", "in", "self", ".", "mapping", ":", "return", "self", ".", "mapping", "[", "block_number", "]", "block_hash", "=", "self", ".", "web3", ".", ...
Given a block number returns the hex representation of the blockhash
[ "Given", "a", "block", "number", "returns", "the", "hex", "representation", "of", "the", "blockhash" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v18_to_v19.py#L27-L35
221,526
raiden-network/raiden
raiden/utils/gas_reserve.py
has_enough_gas_reserve
def has_enough_gas_reserve( raiden, channels_to_open: int = 0, ) -> Tuple[bool, int]: """ Checks if the account has enough balance to handle the lifecycles of all open channels as well as the to be created channels. Note: This is just an estimation. Args: raiden: A raiden servi...
python
def has_enough_gas_reserve( raiden, channels_to_open: int = 0, ) -> Tuple[bool, int]: """ Checks if the account has enough balance to handle the lifecycles of all open channels as well as the to be created channels. Note: This is just an estimation. Args: raiden: A raiden servi...
[ "def", "has_enough_gas_reserve", "(", "raiden", ",", "channels_to_open", ":", "int", "=", "0", ",", ")", "->", "Tuple", "[", "bool", ",", "int", "]", ":", "secure_reserve_estimate", "=", "get_reserve_estimate", "(", "raiden", ",", "channels_to_open", ")", "cur...
Checks if the account has enough balance to handle the lifecycles of all open channels as well as the to be created channels. Note: This is just an estimation. Args: raiden: A raiden service instance channels_to_open: The number of new channels that should be opened Returns: T...
[ "Checks", "if", "the", "account", "has", "enough", "balance", "to", "handle", "the", "lifecycles", "of", "all", "open", "channels", "as", "well", "as", "the", "to", "be", "created", "channels", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/gas_reserve.py#L126-L147
221,527
raiden-network/raiden
raiden/transfer/merkle_tree.py
hash_pair
def hash_pair(first: Keccak256, second: Optional[Keccak256]) -> Keccak256: """ Computes the keccak hash of the elements ordered topologically. Since a merkle proof will not include all the elements, but only the path starting from the leaves up to the root, the order of the elements is not known by the...
python
def hash_pair(first: Keccak256, second: Optional[Keccak256]) -> Keccak256: """ Computes the keccak hash of the elements ordered topologically. Since a merkle proof will not include all the elements, but only the path starting from the leaves up to the root, the order of the elements is not known by the...
[ "def", "hash_pair", "(", "first", ":", "Keccak256", ",", "second", ":", "Optional", "[", "Keccak256", "]", ")", "->", "Keccak256", ":", "assert", "first", "is", "not", "None", "if", "second", "is", "None", ":", "return", "first", "if", "first", ">", "s...
Computes the keccak hash of the elements ordered topologically. Since a merkle proof will not include all the elements, but only the path starting from the leaves up to the root, the order of the elements is not known by the proof checker. The topological order is used as a deterministic way of orderin...
[ "Computes", "the", "keccak", "hash", "of", "the", "elements", "ordered", "topologically", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L16-L33
221,528
raiden-network/raiden
raiden/transfer/merkle_tree.py
compute_layers
def compute_layers(elements: List[Keccak256]) -> List[List[Keccak256]]: """ Computes the layers of the merkletree. First layer is the list of elements and the last layer is a list with a single entry, the merkleroot. """ elements = list(elements) # consume generators assert elements, 'Use mak...
python
def compute_layers(elements: List[Keccak256]) -> List[List[Keccak256]]: """ Computes the layers of the merkletree. First layer is the list of elements and the last layer is a list with a single entry, the merkleroot. """ elements = list(elements) # consume generators assert elements, 'Use mak...
[ "def", "compute_layers", "(", "elements", ":", "List", "[", "Keccak256", "]", ")", "->", "List", "[", "List", "[", "Keccak256", "]", "]", ":", "elements", "=", "list", "(", "elements", ")", "# consume generators", "assert", "elements", ",", "'Use make_empty_...
Computes the layers of the merkletree. First layer is the list of elements and the last layer is a list with a single entry, the merkleroot.
[ "Computes", "the", "layers", "of", "the", "merkletree", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L36-L64
221,529
raiden-network/raiden
raiden/transfer/merkle_tree.py
compute_merkleproof_for
def compute_merkleproof_for(merkletree: 'MerkleTreeState', element: Keccak256) -> List[Keccak256]: """ Containment proof for element. The proof contains only the entries that are sufficient to recompute the merkleroot, from the leaf `element` up to `root`. Raises: IndexError: If the element is...
python
def compute_merkleproof_for(merkletree: 'MerkleTreeState', element: Keccak256) -> List[Keccak256]: """ Containment proof for element. The proof contains only the entries that are sufficient to recompute the merkleroot, from the leaf `element` up to `root`. Raises: IndexError: If the element is...
[ "def", "compute_merkleproof_for", "(", "merkletree", ":", "'MerkleTreeState'", ",", "element", ":", "Keccak256", ")", "->", "List", "[", "Keccak256", "]", ":", "idx", "=", "merkletree", ".", "layers", "[", "LEAVES", "]", ".", "index", "(", "element", ")", ...
Containment proof for element. The proof contains only the entries that are sufficient to recompute the merkleroot, from the leaf `element` up to `root`. Raises: IndexError: If the element is not part of the merkletree.
[ "Containment", "proof", "for", "element", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L67-L92
221,530
raiden-network/raiden
raiden/transfer/merkle_tree.py
validate_proof
def validate_proof(proof: List[Keccak256], root: Keccak256, leaf_element: Keccak256) -> bool: """ Checks that `leaf_element` was contained in the tree represented by `merkleroot`. """ hash_ = leaf_element for pair in proof: hash_ = hash_pair(hash_, pair) return hash_ == root
python
def validate_proof(proof: List[Keccak256], root: Keccak256, leaf_element: Keccak256) -> bool: """ Checks that `leaf_element` was contained in the tree represented by `merkleroot`. """ hash_ = leaf_element for pair in proof: hash_ = hash_pair(hash_, pair) return hash_ == root
[ "def", "validate_proof", "(", "proof", ":", "List", "[", "Keccak256", "]", ",", "root", ":", "Keccak256", ",", "leaf_element", ":", "Keccak256", ")", "->", "bool", ":", "hash_", "=", "leaf_element", "for", "pair", "in", "proof", ":", "hash_", "=", "hash_...
Checks that `leaf_element` was contained in the tree represented by `merkleroot`.
[ "Checks", "that", "leaf_element", "was", "contained", "in", "the", "tree", "represented", "by", "merkleroot", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L95-L104
221,531
raiden-network/raiden
raiden/transfer/merkle_tree.py
merkleroot
def merkleroot(merkletree: 'MerkleTreeState') -> Locksroot: """ Return the root element of the merkle tree. """ assert merkletree.layers, 'the merkle tree layers are empty' assert merkletree.layers[MERKLEROOT], 'the root layer is empty' return Locksroot(merkletree.layers[MERKLEROOT][0])
python
def merkleroot(merkletree: 'MerkleTreeState') -> Locksroot: """ Return the root element of the merkle tree. """ assert merkletree.layers, 'the merkle tree layers are empty' assert merkletree.layers[MERKLEROOT], 'the root layer is empty' return Locksroot(merkletree.layers[MERKLEROOT][0])
[ "def", "merkleroot", "(", "merkletree", ":", "'MerkleTreeState'", ")", "->", "Locksroot", ":", "assert", "merkletree", ".", "layers", ",", "'the merkle tree layers are empty'", "assert", "merkletree", ".", "layers", "[", "MERKLEROOT", "]", ",", "'the root layer is emp...
Return the root element of the merkle tree.
[ "Return", "the", "root", "element", "of", "the", "merkle", "tree", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/merkle_tree.py#L107-L112
221,532
raiden-network/raiden
raiden/storage/migrations/v19_to_v20.py
_add_onchain_locksroot_to_channel_settled_state_changes
def _add_onchain_locksroot_to_channel_settled_state_changes( raiden: RaidenService, storage: SQLiteStorage, ) -> None: """ Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to ContractReceiveChannelSettled. """ batch_size = 50 batch_query = storage.batch_query_state_changes( ...
python
def _add_onchain_locksroot_to_channel_settled_state_changes( raiden: RaidenService, storage: SQLiteStorage, ) -> None: """ Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to ContractReceiveChannelSettled. """ batch_size = 50 batch_query = storage.batch_query_state_changes( ...
[ "def", "_add_onchain_locksroot_to_channel_settled_state_changes", "(", "raiden", ":", "RaidenService", ",", "storage", ":", "SQLiteStorage", ",", ")", "->", "None", ":", "batch_size", "=", "50", "batch_query", "=", "storage", ".", "batch_query_state_changes", "(", "ba...
Adds `our_onchain_locksroot` and `partner_onchain_locksroot` to ContractReceiveChannelSettled.
[ "Adds", "our_onchain_locksroot", "and", "partner_onchain_locksroot", "to", "ContractReceiveChannelSettled", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v19_to_v20.py#L103-L168
221,533
raiden-network/raiden
raiden/storage/migrations/v19_to_v20.py
_add_onchain_locksroot_to_snapshot
def _add_onchain_locksroot_to_snapshot( raiden: RaidenService, storage: SQLiteStorage, snapshot_record: StateChangeRecord, ) -> str: """ Add `onchain_locksroot` to each NettingChannelEndState """ snapshot = json.loads(snapshot_record.data) for payment_network in snapshot.get...
python
def _add_onchain_locksroot_to_snapshot( raiden: RaidenService, storage: SQLiteStorage, snapshot_record: StateChangeRecord, ) -> str: """ Add `onchain_locksroot` to each NettingChannelEndState """ snapshot = json.loads(snapshot_record.data) for payment_network in snapshot.get...
[ "def", "_add_onchain_locksroot_to_snapshot", "(", "raiden", ":", "RaidenService", ",", "storage", ":", "SQLiteStorage", ",", "snapshot_record", ":", "StateChangeRecord", ",", ")", "->", "str", ":", "snapshot", "=", "json", ".", "loads", "(", "snapshot_record", "."...
Add `onchain_locksroot` to each NettingChannelEndState
[ "Add", "onchain_locksroot", "to", "each", "NettingChannelEndState" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v19_to_v20.py#L171-L197
221,534
raiden-network/raiden
raiden/log_config.py
add_greenlet_name
def add_greenlet_name( _logger: str, _method_name: str, event_dict: Dict[str, Any], ) -> Dict[str, Any]: """Add greenlet_name to the event dict for greenlets that have a non-default name.""" current_greenlet = gevent.getcurrent() greenlet_name = getattr(current_greenlet, 'name', None...
python
def add_greenlet_name( _logger: str, _method_name: str, event_dict: Dict[str, Any], ) -> Dict[str, Any]: """Add greenlet_name to the event dict for greenlets that have a non-default name.""" current_greenlet = gevent.getcurrent() greenlet_name = getattr(current_greenlet, 'name', None...
[ "def", "add_greenlet_name", "(", "_logger", ":", "str", ",", "_method_name", ":", "str", ",", "event_dict", ":", "Dict", "[", "str", ",", "Any", "]", ",", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "current_greenlet", "=", "gevent", ".", "g...
Add greenlet_name to the event dict for greenlets that have a non-default name.
[ "Add", "greenlet_name", "to", "the", "event", "dict", "for", "greenlets", "that", "have", "a", "non", "-", "default", "name", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L107-L117
221,535
raiden-network/raiden
raiden/log_config.py
redactor
def redactor(blacklist: Dict[Pattern, str]) -> Callable[[str], str]: """Returns a function which transforms a str, replacing all matches for its replacement""" def processor_wrapper(msg: str) -> str: for regex, repl in blacklist.items(): if repl is None: repl = '<redacted>' ...
python
def redactor(blacklist: Dict[Pattern, str]) -> Callable[[str], str]: """Returns a function which transforms a str, replacing all matches for its replacement""" def processor_wrapper(msg: str) -> str: for regex, repl in blacklist.items(): if repl is None: repl = '<redacted>' ...
[ "def", "redactor", "(", "blacklist", ":", "Dict", "[", "Pattern", ",", "str", "]", ")", "->", "Callable", "[", "[", "str", "]", ",", "str", "]", ":", "def", "processor_wrapper", "(", "msg", ":", "str", ")", "->", "str", ":", "for", "regex", ",", ...
Returns a function which transforms a str, replacing all matches for its replacement
[ "Returns", "a", "function", "which", "transforms", "a", "str", "replacing", "all", "matches", "for", "its", "replacement" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L120-L128
221,536
raiden-network/raiden
raiden/log_config.py
_wrap_tracebackexception_format
def _wrap_tracebackexception_format(redact: Callable[[str], str]): """Monkey-patch TracebackException.format to redact printed lines. Only the last call will be effective. Consecutive calls will overwrite the previous monkey patches. """ original_format = getattr(TracebackException, '_original', No...
python
def _wrap_tracebackexception_format(redact: Callable[[str], str]): """Monkey-patch TracebackException.format to redact printed lines. Only the last call will be effective. Consecutive calls will overwrite the previous monkey patches. """ original_format = getattr(TracebackException, '_original', No...
[ "def", "_wrap_tracebackexception_format", "(", "redact", ":", "Callable", "[", "[", "str", "]", ",", "str", "]", ")", ":", "original_format", "=", "getattr", "(", "TracebackException", ",", "'_original'", ",", "None", ")", "if", "original_format", "is", "None"...
Monkey-patch TracebackException.format to redact printed lines. Only the last call will be effective. Consecutive calls will overwrite the previous monkey patches.
[ "Monkey", "-", "patch", "TracebackException", ".", "format", "to", "redact", "printed", "lines", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L131-L147
221,537
raiden-network/raiden
raiden/log_config.py
LogFilter.should_log
def should_log(self, logger_name: str, level: str) -> bool: """ Returns if a message for the logger should be logged. """ if (logger_name, level) not in self._should_log: log_level_per_rule = self._get_log_level(logger_name) log_level_per_rule_numeric = getattr(logging, log_level...
python
def should_log(self, logger_name: str, level: str) -> bool: """ Returns if a message for the logger should be logged. """ if (logger_name, level) not in self._should_log: log_level_per_rule = self._get_log_level(logger_name) log_level_per_rule_numeric = getattr(logging, log_level...
[ "def", "should_log", "(", "self", ",", "logger_name", ":", "str", ",", "level", ":", "str", ")", "->", "bool", ":", "if", "(", "logger_name", ",", "level", ")", "not", "in", "self", ".", "_should_log", ":", "log_level_per_rule", "=", "self", ".", "_get...
Returns if a message for the logger should be logged.
[ "Returns", "if", "a", "message", "for", "the", "logger", "should", "be", "logged", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/log_config.py#L86-L95
221,538
raiden-network/raiden
raiden/storage/migrations/v20_to_v21.py
_update_statechanges
def _update_statechanges(storage: SQLiteStorage): """ Update each ContractReceiveChannelNew's channel_state member by setting the `mediation_fee` that was added to the NettingChannelState """ batch_size = 50 batch_query = storage.batch_query_state_changes( batch_size=batch_size, ...
python
def _update_statechanges(storage: SQLiteStorage): """ Update each ContractReceiveChannelNew's channel_state member by setting the `mediation_fee` that was added to the NettingChannelState """ batch_size = 50 batch_query = storage.batch_query_state_changes( batch_size=batch_size, ...
[ "def", "_update_statechanges", "(", "storage", ":", "SQLiteStorage", ")", ":", "batch_size", "=", "50", "batch_query", "=", "storage", ".", "batch_query_state_changes", "(", "batch_size", "=", "batch_size", ",", "filters", "=", "[", "(", "'_type'", ",", "'raiden...
Update each ContractReceiveChannelNew's channel_state member by setting the `mediation_fee` that was added to the NettingChannelState
[ "Update", "each", "ContractReceiveChannelNew", "s", "channel_state", "member", "by", "setting", "the", "mediation_fee", "that", "was", "added", "to", "the", "NettingChannelState" ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v20_to_v21.py#L52-L100
221,539
raiden-network/raiden
raiden/blockchain/events.py
get_contract_events
def get_contract_events( chain: BlockChainService, abi: Dict, contract_address: Address, topics: Optional[List[str]], from_block: BlockSpecification, to_block: BlockSpecification, ) -> List[Dict]: """ Query the blockchain for all events of the smart contract at `c...
python
def get_contract_events( chain: BlockChainService, abi: Dict, contract_address: Address, topics: Optional[List[str]], from_block: BlockSpecification, to_block: BlockSpecification, ) -> List[Dict]: """ Query the blockchain for all events of the smart contract at `c...
[ "def", "get_contract_events", "(", "chain", ":", "BlockChainService", ",", "abi", ":", "Dict", ",", "contract_address", ":", "Address", ",", "topics", ":", "Optional", "[", "List", "[", "str", "]", "]", ",", "from_block", ":", "BlockSpecification", ",", "to_...
Query the blockchain for all events of the smart contract at `contract_address` that match the filters `topics`, `from_block`, and `to_block`.
[ "Query", "the", "blockchain", "for", "all", "events", "of", "the", "smart", "contract", "at", "contract_address", "that", "match", "the", "filters", "topics", "from_block", "and", "to_block", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L50-L78
221,540
raiden-network/raiden
raiden/blockchain/events.py
get_token_network_registry_events
def get_token_network_registry_events( chain: BlockChainService, token_network_registry_address: PaymentNetworkID, contract_manager: ContractManager, events: Optional[List[str]] = ALL_EVENTS, from_block: BlockSpecification = GENESIS_BLOCK_NUMBER, to_block: BlockSpecificat...
python
def get_token_network_registry_events( chain: BlockChainService, token_network_registry_address: PaymentNetworkID, contract_manager: ContractManager, events: Optional[List[str]] = ALL_EVENTS, from_block: BlockSpecification = GENESIS_BLOCK_NUMBER, to_block: BlockSpecificat...
[ "def", "get_token_network_registry_events", "(", "chain", ":", "BlockChainService", ",", "token_network_registry_address", ":", "PaymentNetworkID", ",", "contract_manager", ":", "ContractManager", ",", "events", ":", "Optional", "[", "List", "[", "str", "]", "]", "=",...
Helper to get all events of the Registry contract at `registry_address`.
[ "Helper", "to", "get", "all", "events", "of", "the", "Registry", "contract", "at", "registry_address", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L81-L97
221,541
raiden-network/raiden
raiden/blockchain/events.py
get_token_network_events
def get_token_network_events( chain: BlockChainService, token_network_address: Address, contract_manager: ContractManager, events: Optional[List[str]] = ALL_EVENTS, from_block: BlockSpecification = GENESIS_BLOCK_NUMBER, to_block: BlockSpecification = 'latest', ) -> List[D...
python
def get_token_network_events( chain: BlockChainService, token_network_address: Address, contract_manager: ContractManager, events: Optional[List[str]] = ALL_EVENTS, from_block: BlockSpecification = GENESIS_BLOCK_NUMBER, to_block: BlockSpecification = 'latest', ) -> List[D...
[ "def", "get_token_network_events", "(", "chain", ":", "BlockChainService", ",", "token_network_address", ":", "Address", ",", "contract_manager", ":", "ContractManager", ",", "events", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "ALL_EVENTS", ",", "...
Helper to get all events of the ChannelManagerContract at `token_address`.
[ "Helper", "to", "get", "all", "events", "of", "the", "ChannelManagerContract", "at", "token_address", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L100-L117
221,542
raiden-network/raiden
raiden/blockchain/events.py
get_all_netting_channel_events
def get_all_netting_channel_events( chain: BlockChainService, token_network_address: TokenNetworkAddress, netting_channel_identifier: ChannelID, contract_manager: ContractManager, from_block: BlockSpecification = GENESIS_BLOCK_NUMBER, to_block: BlockSpecification = 'lates...
python
def get_all_netting_channel_events( chain: BlockChainService, token_network_address: TokenNetworkAddress, netting_channel_identifier: ChannelID, contract_manager: ContractManager, from_block: BlockSpecification = GENESIS_BLOCK_NUMBER, to_block: BlockSpecification = 'lates...
[ "def", "get_all_netting_channel_events", "(", "chain", ":", "BlockChainService", ",", "token_network_address", ":", "TokenNetworkAddress", ",", "netting_channel_identifier", ":", "ChannelID", ",", "contract_manager", ":", "ContractManager", ",", "from_block", ":", "BlockSpe...
Helper to get all events of a NettingChannelContract.
[ "Helper", "to", "get", "all", "events", "of", "a", "NettingChannelContract", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L120-L145
221,543
raiden-network/raiden
raiden/blockchain/events.py
decode_event_to_internal
def decode_event_to_internal(abi, log_event): """ Enforce the binary for internal usage. """ # Note: All addresses inside the event_data must be decoded. decoded_event = decode_event(abi, log_event) if not decoded_event: raise UnknownEventType() # copy the attribute dict because that data...
python
def decode_event_to_internal(abi, log_event): """ Enforce the binary for internal usage. """ # Note: All addresses inside the event_data must be decoded. decoded_event = decode_event(abi, log_event) if not decoded_event: raise UnknownEventType() # copy the attribute dict because that data...
[ "def", "decode_event_to_internal", "(", "abi", ",", "log_event", ")", ":", "# Note: All addresses inside the event_data must be decoded.", "decoded_event", "=", "decode_event", "(", "abi", ",", "log_event", ")", "if", "not", "decoded_event", ":", "raise", "UnknownEventTyp...
Enforce the binary for internal usage.
[ "Enforce", "the", "binary", "for", "internal", "usage", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L148-L195
221,544
raiden-network/raiden
raiden/blockchain/events.py
BlockchainEvents.poll_blockchain_events
def poll_blockchain_events(self, block_number: typing.BlockNumber): """ Poll for new blockchain events up to `block_number`. """ for event_listener in self.event_listeners: assert isinstance(event_listener.filter, StatelessFilter) for log_event in event_listener.filter.get_new_...
python
def poll_blockchain_events(self, block_number: typing.BlockNumber): """ Poll for new blockchain events up to `block_number`. """ for event_listener in self.event_listeners: assert isinstance(event_listener.filter, StatelessFilter) for log_event in event_listener.filter.get_new_...
[ "def", "poll_blockchain_events", "(", "self", ",", "block_number", ":", "typing", ".", "BlockNumber", ")", ":", "for", "event_listener", "in", "self", ".", "event_listeners", ":", "assert", "isinstance", "(", "event_listener", ".", "filter", ",", "StatelessFilter"...
Poll for new blockchain events up to `block_number`.
[ "Poll", "for", "new", "blockchain", "events", "up", "to", "block_number", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/blockchain/events.py#L216-L223
221,545
raiden-network/raiden
tools/genesis_builder.py
generate_accounts
def generate_accounts(seeds): """Create private keys and addresses for all seeds. """ return { seed: { 'privatekey': encode_hex(sha3(seed)), 'address': encode_hex(privatekey_to_address(sha3(seed))), } for seed in seeds }
python
def generate_accounts(seeds): """Create private keys and addresses for all seeds. """ return { seed: { 'privatekey': encode_hex(sha3(seed)), 'address': encode_hex(privatekey_to_address(sha3(seed))), } for seed in seeds }
[ "def", "generate_accounts", "(", "seeds", ")", ":", "return", "{", "seed", ":", "{", "'privatekey'", ":", "encode_hex", "(", "sha3", "(", "seed", ")", ")", ",", "'address'", ":", "encode_hex", "(", "privatekey_to_address", "(", "sha3", "(", "seed", ")", ...
Create private keys and addresses for all seeds.
[ "Create", "private", "keys", "and", "addresses", "for", "all", "seeds", "." ]
407ba15c72074e9de88771d6b9661ff4dc36bef5
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/tools/genesis_builder.py#L9-L18
221,546
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
221,547
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
221,548
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
221,549
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
221,550
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
221,551
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
221,552
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
221,553
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
221,554
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
221,555
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
221,556
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
221,557
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
221,558
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
221,559
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
221,560
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
221,561
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
221,562
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
221,563
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
221,564
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
221,565
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
221,566
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
221,567
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
221,568
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
221,569
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
221,570
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
221,571
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
221,572
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
221,573
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
221,574
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
221,575
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
221,576
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
221,577
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
221,578
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
221,579
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
221,580
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
221,581
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
221,582
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
221,583
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
221,584
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
221,585
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
221,586
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
221,587
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
221,588
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
221,589
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
221,590
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
221,591
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
221,592
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
221,593
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
221,594
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
221,595
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
221,596
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
221,597
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
221,598
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
221,599
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