repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
hyperledger/indy-plenum | stp_core/network/keep_in_touch.py | KITNetworkInterface.getRemoteName | def getRemoteName(self, remote):
"""
Returns the name of the remote object if found in node registry.
:param remote: the remote object
"""
if remote.name not in self.registry:
find = [name for name, ha in self.registry.items()
if ha == remote.ha]
... | python | def getRemoteName(self, remote):
"""
Returns the name of the remote object if found in node registry.
:param remote: the remote object
"""
if remote.name not in self.registry:
find = [name for name, ha in self.registry.items()
if ha == remote.ha]
... | [
"def",
"getRemoteName",
"(",
"self",
",",
"remote",
")",
":",
"if",
"remote",
".",
"name",
"not",
"in",
"self",
".",
"registry",
":",
"find",
"=",
"[",
"name",
"for",
"name",
",",
"ha",
"in",
"self",
".",
"registry",
".",
"items",
"(",
")",
"if",
... | Returns the name of the remote object if found in node registry.
:param remote: the remote object | [
"Returns",
"the",
"name",
"of",
"the",
"remote",
"object",
"if",
"found",
"in",
"node",
"registry",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/network/keep_in_touch.py#L124-L135 | train |
hyperledger/indy-plenum | stp_core/network/keep_in_touch.py | KITNetworkInterface.notConnectedNodes | def notConnectedNodes(self) -> Set[str]:
"""
Returns the names of nodes in the registry this node is NOT connected
to.
"""
return set(self.registry.keys()) - self.conns | python | def notConnectedNodes(self) -> Set[str]:
"""
Returns the names of nodes in the registry this node is NOT connected
to.
"""
return set(self.registry.keys()) - self.conns | [
"def",
"notConnectedNodes",
"(",
"self",
")",
"->",
"Set",
"[",
"str",
"]",
":",
"return",
"set",
"(",
"self",
".",
"registry",
".",
"keys",
"(",
")",
")",
"-",
"self",
".",
"conns"
] | Returns the names of nodes in the registry this node is NOT connected
to. | [
"Returns",
"the",
"names",
"of",
"nodes",
"in",
"the",
"registry",
"this",
"node",
"is",
"NOT",
"connected",
"to",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/network/keep_in_touch.py#L138-L143 | train |
hyperledger/indy-plenum | stp_zmq/authenticator.py | MultiZapAuthenticator.start | def start(self):
"""Create and bind the ZAP socket"""
self.zap_socket = self.context.socket(zmq.REP)
self.zap_socket.linger = 1
zapLoc = 'inproc://zeromq.zap.{}'.format(MultiZapAuthenticator.count)
self.zap_socket.bind(zapLoc)
self.log.debug('Starting ZAP at {}'.format(za... | python | def start(self):
"""Create and bind the ZAP socket"""
self.zap_socket = self.context.socket(zmq.REP)
self.zap_socket.linger = 1
zapLoc = 'inproc://zeromq.zap.{}'.format(MultiZapAuthenticator.count)
self.zap_socket.bind(zapLoc)
self.log.debug('Starting ZAP at {}'.format(za... | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"zap_socket",
"=",
"self",
".",
"context",
".",
"socket",
"(",
"zmq",
".",
"REP",
")",
"self",
".",
"zap_socket",
".",
"linger",
"=",
"1",
"zapLoc",
"=",
"'inproc://zeromq.zap.{}'",
".",
"format",
"("... | Create and bind the ZAP socket | [
"Create",
"and",
"bind",
"the",
"ZAP",
"socket"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/authenticator.py#L25-L31 | train |
hyperledger/indy-plenum | stp_zmq/authenticator.py | MultiZapAuthenticator.stop | def stop(self):
"""Close the ZAP socket"""
if self.zap_socket:
self.log.debug(
'Stopping ZAP at {}'.format(self.zap_socket.LAST_ENDPOINT))
super().stop() | python | def stop(self):
"""Close the ZAP socket"""
if self.zap_socket:
self.log.debug(
'Stopping ZAP at {}'.format(self.zap_socket.LAST_ENDPOINT))
super().stop() | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"zap_socket",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'Stopping ZAP at {}'",
".",
"format",
"(",
"self",
".",
"zap_socket",
".",
"LAST_ENDPOINT",
")",
")",
"super",
"(",
")",
".",
"stop",
... | Close the ZAP socket | [
"Close",
"the",
"ZAP",
"socket"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/authenticator.py#L33-L38 | train |
hyperledger/indy-plenum | stp_zmq/authenticator.py | AsyncioAuthenticator.start | def start(self):
"""Start ZAP authentication"""
super().start()
self.__poller = zmq.asyncio.Poller()
self.__poller.register(self.zap_socket, zmq.POLLIN)
self.__task = asyncio.ensure_future(self.__handle_zap()) | python | def start(self):
"""Start ZAP authentication"""
super().start()
self.__poller = zmq.asyncio.Poller()
self.__poller.register(self.zap_socket, zmq.POLLIN)
self.__task = asyncio.ensure_future(self.__handle_zap()) | [
"def",
"start",
"(",
"self",
")",
":",
"super",
"(",
")",
".",
"start",
"(",
")",
"self",
".",
"__poller",
"=",
"zmq",
".",
"asyncio",
".",
"Poller",
"(",
")",
"self",
".",
"__poller",
".",
"register",
"(",
"self",
".",
"zap_socket",
",",
"zmq",
... | Start ZAP authentication | [
"Start",
"ZAP",
"authentication"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/authenticator.py#L88-L93 | train |
hyperledger/indy-plenum | stp_zmq/authenticator.py | AsyncioAuthenticator.stop | def stop(self):
"""Stop ZAP authentication"""
if self.__task:
self.__task.cancel()
if self.__poller:
self.__poller.unregister(self.zap_socket)
self.__poller = None
super().stop() | python | def stop(self):
"""Stop ZAP authentication"""
if self.__task:
self.__task.cancel()
if self.__poller:
self.__poller.unregister(self.zap_socket)
self.__poller = None
super().stop() | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"__task",
":",
"self",
".",
"__task",
".",
"cancel",
"(",
")",
"if",
"self",
".",
"__poller",
":",
"self",
".",
"__poller",
".",
"unregister",
"(",
"self",
".",
"zap_socket",
")",
"self",
"."... | Stop ZAP authentication | [
"Stop",
"ZAP",
"authentication"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/authenticator.py#L95-L102 | train |
hyperledger/indy-plenum | plenum/common/util.py | randomString | def randomString(size: int = 20) -> str:
"""
Generate a random string in hex of the specified size
DO NOT use python provided random class its a Pseudo Random Number Generator
and not secure enough for our needs
:param size: size of the random string to generate
:return: the hexadecimal random... | python | def randomString(size: int = 20) -> str:
"""
Generate a random string in hex of the specified size
DO NOT use python provided random class its a Pseudo Random Number Generator
and not secure enough for our needs
:param size: size of the random string to generate
:return: the hexadecimal random... | [
"def",
"randomString",
"(",
"size",
":",
"int",
"=",
"20",
")",
"->",
"str",
":",
"def",
"randomStr",
"(",
"size",
")",
":",
"if",
"not",
"isinstance",
"(",
"size",
",",
"int",
")",
":",
"raise",
"PlenumTypeError",
"(",
"'size'",
",",
"size",
",",
... | Generate a random string in hex of the specified size
DO NOT use python provided random class its a Pseudo Random Number Generator
and not secure enough for our needs
:param size: size of the random string to generate
:return: the hexadecimal random string | [
"Generate",
"a",
"random",
"string",
"in",
"hex",
"of",
"the",
"specified",
"size"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/util.py#L48-L75 | train |
hyperledger/indy-plenum | plenum/common/util.py | mostCommonElement | def mostCommonElement(elements: Iterable[T], to_hashable_f: Callable=None):
"""
Find the most frequent element of a collection.
:param elements: An iterable of elements
:param to_hashable_f: (optional) if defined will be used to get
hashable presentation for non-hashable elements. Otherwise jso... | python | def mostCommonElement(elements: Iterable[T], to_hashable_f: Callable=None):
"""
Find the most frequent element of a collection.
:param elements: An iterable of elements
:param to_hashable_f: (optional) if defined will be used to get
hashable presentation for non-hashable elements. Otherwise jso... | [
"def",
"mostCommonElement",
"(",
"elements",
":",
"Iterable",
"[",
"T",
"]",
",",
"to_hashable_f",
":",
"Callable",
"=",
"None",
")",
":",
"class",
"_Hashable",
"(",
"collections",
".",
"abc",
".",
"Hashable",
")",
":",
"def",
"__init__",
"(",
"self",
",... | Find the most frequent element of a collection.
:param elements: An iterable of elements
:param to_hashable_f: (optional) if defined will be used to get
hashable presentation for non-hashable elements. Otherwise json.dumps
is used with sort_keys=True
:return: element which is the most frequ... | [
"Find",
"the",
"most",
"frequent",
"element",
"of",
"a",
"collection",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/util.py#L92-L122 | train |
hyperledger/indy-plenum | plenum/common/util.py | objSearchReplace | def objSearchReplace(obj: Any,
toFrom: Dict[Any, Any],
checked: Set[Any]=None,
logMsg: str=None,
deepLevel: int=None) -> None:
"""
Search for an attribute in an object and replace it with another.
:param obj: the object to ... | python | def objSearchReplace(obj: Any,
toFrom: Dict[Any, Any],
checked: Set[Any]=None,
logMsg: str=None,
deepLevel: int=None) -> None:
"""
Search for an attribute in an object and replace it with another.
:param obj: the object to ... | [
"def",
"objSearchReplace",
"(",
"obj",
":",
"Any",
",",
"toFrom",
":",
"Dict",
"[",
"Any",
",",
"Any",
"]",
",",
"checked",
":",
"Set",
"[",
"Any",
"]",
"=",
"None",
",",
"logMsg",
":",
"str",
"=",
"None",
",",
"deepLevel",
":",
"int",
"=",
"None... | Search for an attribute in an object and replace it with another.
:param obj: the object to search for the attribute
:param toFrom: dictionary of the attribute name before and after search and replace i.e. search for the key and replace with the value
:param checked: set of attributes of the object for rec... | [
"Search",
"for",
"an",
"attribute",
"in",
"an",
"object",
"and",
"replace",
"it",
"with",
"another",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/util.py#L131-L174 | train |
hyperledger/indy-plenum | plenum/common/util.py | runall | async def runall(corogen):
"""
Run an array of coroutines
:param corogen: a generator that generates coroutines
:return: list or returns of the coroutines
"""
results = []
for c in corogen:
result = await c
results.append(result)
return results | python | async def runall(corogen):
"""
Run an array of coroutines
:param corogen: a generator that generates coroutines
:return: list or returns of the coroutines
"""
results = []
for c in corogen:
result = await c
results.append(result)
return results | [
"async",
"def",
"runall",
"(",
"corogen",
")",
":",
"results",
"=",
"[",
"]",
"for",
"c",
"in",
"corogen",
":",
"result",
"=",
"await",
"c",
"results",
".",
"append",
"(",
"result",
")",
"return",
"results"
] | Run an array of coroutines
:param corogen: a generator that generates coroutines
:return: list or returns of the coroutines | [
"Run",
"an",
"array",
"of",
"coroutines"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/util.py#L186-L197 | train |
hyperledger/indy-plenum | plenum/common/util.py | prime_gen | def prime_gen() -> int:
# credit to David Eppstein, Wolfgang Beneicke, Paul Hofstra
"""
A generator for prime numbers starting from 2.
"""
D = {}
yield 2
for q in itertools.islice(itertools.count(3), 0, None, 2):
p = D.pop(q, None)
if p is None:
D[q * q] = 2 * q
... | python | def prime_gen() -> int:
# credit to David Eppstein, Wolfgang Beneicke, Paul Hofstra
"""
A generator for prime numbers starting from 2.
"""
D = {}
yield 2
for q in itertools.islice(itertools.count(3), 0, None, 2):
p = D.pop(q, None)
if p is None:
D[q * q] = 2 * q
... | [
"def",
"prime_gen",
"(",
")",
"->",
"int",
":",
"D",
"=",
"{",
"}",
"yield",
"2",
"for",
"q",
"in",
"itertools",
".",
"islice",
"(",
"itertools",
".",
"count",
"(",
"3",
")",
",",
"0",
",",
"None",
",",
"2",
")",
":",
"p",
"=",
"D",
".",
"p... | A generator for prime numbers starting from 2. | [
"A",
"generator",
"for",
"prime",
"numbers",
"starting",
"from",
"2",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/util.py#L254-L270 | train |
hyperledger/indy-plenum | plenum/common/util.py | untilTrue | async def untilTrue(condition, *args, timeout=5) -> bool:
"""
Keep checking the condition till it is true or a timeout is reached
:param condition: the condition to check (a function that returns bool)
:param args: the arguments to the condition
:return: True if the condition is met in the given ti... | python | async def untilTrue(condition, *args, timeout=5) -> bool:
"""
Keep checking the condition till it is true or a timeout is reached
:param condition: the condition to check (a function that returns bool)
:param args: the arguments to the condition
:return: True if the condition is met in the given ti... | [
"async",
"def",
"untilTrue",
"(",
"condition",
",",
"*",
"args",
",",
"timeout",
"=",
"5",
")",
"->",
"bool",
":",
"result",
"=",
"False",
"start",
"=",
"time",
".",
"perf_counter",
"(",
")",
"elapsed",
"=",
"0",
"while",
"elapsed",
"<",
"timeout",
"... | Keep checking the condition till it is true or a timeout is reached
:param condition: the condition to check (a function that returns bool)
:param args: the arguments to the condition
:return: True if the condition is met in the given timeout, False otherwise | [
"Keep",
"checking",
"the",
"condition",
"till",
"it",
"is",
"true",
"or",
"a",
"timeout",
"is",
"reached"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/util.py#L273-L290 | train |
hyperledger/indy-plenum | plenum/common/stacks.py | ClientZStack.transmitToClient | def transmitToClient(self, msg: Any, remoteName: str):
"""
Transmit the specified message to the remote client specified by `remoteName`.
:param msg: a message
:param remoteName: the name of the remote
"""
payload = self.prepForSending(msg)
try:
if is... | python | def transmitToClient(self, msg: Any, remoteName: str):
"""
Transmit the specified message to the remote client specified by `remoteName`.
:param msg: a message
:param remoteName: the name of the remote
"""
payload = self.prepForSending(msg)
try:
if is... | [
"def",
"transmitToClient",
"(",
"self",
",",
"msg",
":",
"Any",
",",
"remoteName",
":",
"str",
")",
":",
"payload",
"=",
"self",
".",
"prepForSending",
"(",
"msg",
")",
"try",
":",
"if",
"isinstance",
"(",
"remoteName",
",",
"str",
")",
":",
"remoteNam... | Transmit the specified message to the remote client specified by `remoteName`.
:param msg: a message
:param remoteName: the name of the remote | [
"Transmit",
"the",
"specified",
"message",
"to",
"the",
"remote",
"client",
"specified",
"by",
"remoteName",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/stacks.py#L139-L158 | train |
hyperledger/indy-plenum | plenum/server/catchup/catchup_rep_service.py | CatchupRepService._has_valid_catchup_replies | def _has_valid_catchup_replies(self, seq_no: int, txns_to_process: List[Tuple[int, Any]]) -> Tuple[bool, str, int]:
"""
Transforms transactions for ledger!
Returns:
Whether catchup reply corresponding to seq_no
Name of node from which txns came
Number of tran... | python | def _has_valid_catchup_replies(self, seq_no: int, txns_to_process: List[Tuple[int, Any]]) -> Tuple[bool, str, int]:
"""
Transforms transactions for ledger!
Returns:
Whether catchup reply corresponding to seq_no
Name of node from which txns came
Number of tran... | [
"def",
"_has_valid_catchup_replies",
"(",
"self",
",",
"seq_no",
":",
"int",
",",
"txns_to_process",
":",
"List",
"[",
"Tuple",
"[",
"int",
",",
"Any",
"]",
"]",
")",
"->",
"Tuple",
"[",
"bool",
",",
"str",
",",
"int",
"]",
":",
"assert",
"seq_no",
"... | Transforms transactions for ledger!
Returns:
Whether catchup reply corresponding to seq_no
Name of node from which txns came
Number of transactions ready to be processed | [
"Transforms",
"transactions",
"for",
"ledger!"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/catchup/catchup_rep_service.py#L374-L425 | train |
hyperledger/indy-plenum | plenum/common/stack_manager.py | TxnStackManager._parse_pool_transaction_file | def _parse_pool_transaction_file(
ledger, nodeReg, cliNodeReg, nodeKeys, activeValidators,
ledger_size=None):
"""
helper function for parseLedgerForHaAndKeys
"""
for _, txn in ledger.getAllTxn(to=ledger_size):
if get_type(txn) == NODE:
... | python | def _parse_pool_transaction_file(
ledger, nodeReg, cliNodeReg, nodeKeys, activeValidators,
ledger_size=None):
"""
helper function for parseLedgerForHaAndKeys
"""
for _, txn in ledger.getAllTxn(to=ledger_size):
if get_type(txn) == NODE:
... | [
"def",
"_parse_pool_transaction_file",
"(",
"ledger",
",",
"nodeReg",
",",
"cliNodeReg",
",",
"nodeKeys",
",",
"activeValidators",
",",
"ledger_size",
"=",
"None",
")",
":",
"for",
"_",
",",
"txn",
"in",
"ledger",
".",
"getAllTxn",
"(",
"to",
"=",
"ledger_si... | helper function for parseLedgerForHaAndKeys | [
"helper",
"function",
"for",
"parseLedgerForHaAndKeys"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/stack_manager.py#L58-L98 | train |
hyperledger/indy-plenum | ledger/merkle_verifier.py | MerkleVerifier.verify_tree_consistency | def verify_tree_consistency(self, old_tree_size: int, new_tree_size: int,
old_root: bytes, new_root: bytes,
proof: Sequence[bytes]):
"""Verify the consistency between two root hashes.
old_tree_size must be <= new_tree_size.
Args:
... | python | def verify_tree_consistency(self, old_tree_size: int, new_tree_size: int,
old_root: bytes, new_root: bytes,
proof: Sequence[bytes]):
"""Verify the consistency between two root hashes.
old_tree_size must be <= new_tree_size.
Args:
... | [
"def",
"verify_tree_consistency",
"(",
"self",
",",
"old_tree_size",
":",
"int",
",",
"new_tree_size",
":",
"int",
",",
"old_root",
":",
"bytes",
",",
"new_root",
":",
"bytes",
",",
"proof",
":",
"Sequence",
"[",
"bytes",
"]",
")",
":",
"old_size",
"=",
... | Verify the consistency between two root hashes.
old_tree_size must be <= new_tree_size.
Args:
old_tree_size: size of the older tree.
new_tree_size: size of the newer_tree.
old_root: the root hash of the older tree.
new_root: the root hash of the newer tr... | [
"Verify",
"the",
"consistency",
"between",
"two",
"root",
"hashes",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/merkle_verifier.py#L23-L153 | train |
hyperledger/indy-plenum | plenum/server/has_action_queue.py | HasActionQueue._schedule | def _schedule(self, action: Callable, seconds: int=0) -> int:
"""
Schedule an action to be executed after `seconds` seconds.
:param action: a callable to be scheduled
:param seconds: the time in seconds after which the action must be executed
"""
self.aid += 1
if... | python | def _schedule(self, action: Callable, seconds: int=0) -> int:
"""
Schedule an action to be executed after `seconds` seconds.
:param action: a callable to be scheduled
:param seconds: the time in seconds after which the action must be executed
"""
self.aid += 1
if... | [
"def",
"_schedule",
"(",
"self",
",",
"action",
":",
"Callable",
",",
"seconds",
":",
"int",
"=",
"0",
")",
"->",
"int",
":",
"self",
".",
"aid",
"+=",
"1",
"if",
"seconds",
">",
"0",
":",
"nxt",
"=",
"time",
".",
"perf_counter",
"(",
")",
"+",
... | Schedule an action to be executed after `seconds` seconds.
:param action: a callable to be scheduled
:param seconds: the time in seconds after which the action must be executed | [
"Schedule",
"an",
"action",
"to",
"be",
"executed",
"after",
"seconds",
"seconds",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/has_action_queue.py#L23-L48 | train |
hyperledger/indy-plenum | plenum/server/has_action_queue.py | HasActionQueue._cancel | def _cancel(self, action: Callable = None, aid: int = None):
"""
Cancel scheduled events
:param action: (optional) scheduled action. If specified, all
scheduled events for the action are cancelled.
:param aid: (options) scheduled event id. If specified,
... | python | def _cancel(self, action: Callable = None, aid: int = None):
"""
Cancel scheduled events
:param action: (optional) scheduled action. If specified, all
scheduled events for the action are cancelled.
:param aid: (options) scheduled event id. If specified,
... | [
"def",
"_cancel",
"(",
"self",
",",
"action",
":",
"Callable",
"=",
"None",
",",
"aid",
":",
"int",
"=",
"None",
")",
":",
"if",
"action",
"is",
"not",
"None",
":",
"if",
"action",
"in",
"self",
".",
"scheduled",
":",
"logger",
".",
"trace",
"(",
... | Cancel scheduled events
:param action: (optional) scheduled action. If specified, all
scheduled events for the action are cancelled.
:param aid: (options) scheduled event id. If specified,
scheduled event with the aid is cancelled. | [
"Cancel",
"scheduled",
"events"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/has_action_queue.py#L50-L72 | train |
hyperledger/indy-plenum | plenum/server/has_action_queue.py | HasActionQueue._serviceActions | def _serviceActions(self) -> int:
"""
Run all pending actions in the action queue.
:return: number of actions executed.
"""
if self.aqStash:
tm = time.perf_counter()
if tm > self.aqNextCheck:
earliest = float('inf')
for d i... | python | def _serviceActions(self) -> int:
"""
Run all pending actions in the action queue.
:return: number of actions executed.
"""
if self.aqStash:
tm = time.perf_counter()
if tm > self.aqNextCheck:
earliest = float('inf')
for d i... | [
"def",
"_serviceActions",
"(",
"self",
")",
"->",
"int",
":",
"if",
"self",
".",
"aqStash",
":",
"tm",
"=",
"time",
".",
"perf_counter",
"(",
")",
"if",
"tm",
">",
"self",
".",
"aqNextCheck",
":",
"earliest",
"=",
"float",
"(",
"'inf'",
")",
"for",
... | Run all pending actions in the action queue.
:return: number of actions executed. | [
"Run",
"all",
"pending",
"actions",
"in",
"the",
"action",
"queue",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/has_action_queue.py#L74-L104 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.execute_pool_txns | def execute_pool_txns(self, three_pc_batch) -> List:
"""
Execute a transaction that involves consensus pool management, like
adding a node, client or a steward.
:param ppTime: PrePrepare request time
:param reqs_keys: requests keys to be committed
"""
committed_t... | python | def execute_pool_txns(self, three_pc_batch) -> List:
"""
Execute a transaction that involves consensus pool management, like
adding a node, client or a steward.
:param ppTime: PrePrepare request time
:param reqs_keys: requests keys to be committed
"""
committed_t... | [
"def",
"execute_pool_txns",
"(",
"self",
",",
"three_pc_batch",
")",
"->",
"List",
":",
"committed_txns",
"=",
"self",
".",
"default_executer",
"(",
"three_pc_batch",
")",
"for",
"txn",
"in",
"committed_txns",
":",
"self",
".",
"poolManager",
".",
"onPoolMembers... | Execute a transaction that involves consensus pool management, like
adding a node, client or a steward.
:param ppTime: PrePrepare request time
:param reqs_keys: requests keys to be committed | [
"Execute",
"a",
"transaction",
"that",
"involves",
"consensus",
"pool",
"management",
"like",
"adding",
"a",
"node",
"client",
"or",
"a",
"steward",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L637-L648 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.init_state_from_ledger | def init_state_from_ledger(self, state: State, ledger: Ledger, reqHandler):
"""
If the trie is empty then initialize it by applying
txns from ledger.
"""
if state.isEmpty:
logger.info('{} found state to be empty, recreating from '
'ledger'.form... | python | def init_state_from_ledger(self, state: State, ledger: Ledger, reqHandler):
"""
If the trie is empty then initialize it by applying
txns from ledger.
"""
if state.isEmpty:
logger.info('{} found state to be empty, recreating from '
'ledger'.form... | [
"def",
"init_state_from_ledger",
"(",
"self",
",",
"state",
":",
"State",
",",
"ledger",
":",
"Ledger",
",",
"reqHandler",
")",
":",
"if",
"state",
".",
"isEmpty",
":",
"logger",
".",
"info",
"(",
"'{} found state to be empty, recreating from '",
"'ledger'",
"."... | If the trie is empty then initialize it by applying
txns from ledger. | [
"If",
"the",
"trie",
"is",
"empty",
"then",
"initialize",
"it",
"by",
"applying",
"txns",
"from",
"ledger",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L663-L674 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.on_view_change_start | def on_view_change_start(self):
"""
Notifies node about the fact that view changed to let it
prepare for election
"""
self.view_changer.start_view_change_ts = self.utc_epoch()
for replica in self.replicas.values():
replica.on_view_change_start()
logge... | python | def on_view_change_start(self):
"""
Notifies node about the fact that view changed to let it
prepare for election
"""
self.view_changer.start_view_change_ts = self.utc_epoch()
for replica in self.replicas.values():
replica.on_view_change_start()
logge... | [
"def",
"on_view_change_start",
"(",
"self",
")",
":",
"self",
".",
"view_changer",
".",
"start_view_change_ts",
"=",
"self",
".",
"utc_epoch",
"(",
")",
"for",
"replica",
"in",
"self",
".",
"replicas",
".",
"values",
"(",
")",
":",
"replica",
".",
"on_view... | Notifies node about the fact that view changed to let it
prepare for election | [
"Notifies",
"node",
"about",
"the",
"fact",
"that",
"view",
"changed",
"to",
"let",
"it",
"prepare",
"for",
"election"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L791-L821 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.on_view_change_complete | def on_view_change_complete(self):
"""
View change completes for a replica when it has been decided which was
the last ppSeqNo and state and txn root for previous view
"""
self.future_primaries_handler.set_node_state()
if not self.replicas.all_instances_have_primary:
... | python | def on_view_change_complete(self):
"""
View change completes for a replica when it has been decided which was
the last ppSeqNo and state and txn root for previous view
"""
self.future_primaries_handler.set_node_state()
if not self.replicas.all_instances_have_primary:
... | [
"def",
"on_view_change_complete",
"(",
"self",
")",
":",
"self",
".",
"future_primaries_handler",
".",
"set_node_state",
"(",
")",
"if",
"not",
"self",
".",
"replicas",
".",
"all_instances_have_primary",
":",
"raise",
"LogicError",
"(",
"\"{} Not all replicas have \""... | View change completes for a replica when it has been decided which was
the last ppSeqNo and state and txn root for previous view | [
"View",
"change",
"completes",
"for",
"a",
"replica",
"when",
"it",
"has",
"been",
"decided",
"which",
"was",
"the",
"last",
"ppSeqNo",
"and",
"state",
"and",
"txn",
"root",
"for",
"previous",
"view"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L823-L851 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.onStopping | def onStopping(self):
"""
Actions to be performed on stopping the node.
- Close the UDP socket of the nodestack
"""
# Log stats should happen before any kind of reset or clearing
if self.config.STACK_COMPANION == 1:
add_stop_time(self.ledger_dir, self.utc_epo... | python | def onStopping(self):
"""
Actions to be performed on stopping the node.
- Close the UDP socket of the nodestack
"""
# Log stats should happen before any kind of reset or clearing
if self.config.STACK_COMPANION == 1:
add_stop_time(self.ledger_dir, self.utc_epo... | [
"def",
"onStopping",
"(",
"self",
")",
":",
"if",
"self",
".",
"config",
".",
"STACK_COMPANION",
"==",
"1",
":",
"add_stop_time",
"(",
"self",
".",
"ledger_dir",
",",
"self",
".",
"utc_epoch",
"(",
")",
")",
"self",
".",
"logstats",
"(",
")",
"self",
... | Actions to be performed on stopping the node.
- Close the UDP socket of the nodestack | [
"Actions",
"to",
"be",
"performed",
"on",
"stopping",
"the",
"node",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1248-L1275 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.prod | async def prod(self, limit: int = None) -> int:
""".opened
This function is executed by the node each time it gets its share of
CPU time from the event loop.
:param limit: the number of items to be serviced in this attempt
:return: total number of messages serviced by this node
... | python | async def prod(self, limit: int = None) -> int:
""".opened
This function is executed by the node each time it gets its share of
CPU time from the event loop.
:param limit: the number of items to be serviced in this attempt
:return: total number of messages serviced by this node
... | [
"async",
"def",
"prod",
"(",
"self",
",",
"limit",
":",
"int",
"=",
"None",
")",
"->",
"int",
":",
"c",
"=",
"0",
"if",
"self",
".",
"last_prod_started",
":",
"self",
".",
"metrics",
".",
"add_event",
"(",
"MetricsName",
".",
"LOOPER_RUN_TIME_SPENT",
"... | .opened
This function is executed by the node each time it gets its share of
CPU time from the event loop.
:param limit: the number of items to be serviced in this attempt
:return: total number of messages serviced by this node | [
".",
"opened",
"This",
"function",
"is",
"executed",
"by",
"the",
"node",
"each",
"time",
"it",
"gets",
"its",
"share",
"of",
"CPU",
"time",
"from",
"the",
"event",
"loop",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1309-L1349 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.serviceNodeMsgs | async def serviceNodeMsgs(self, limit: int) -> int:
"""
Process `limit` number of messages from the nodeInBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed
"""
with self.metrics.measure_time(MetricsName.SE... | python | async def serviceNodeMsgs(self, limit: int) -> int:
"""
Process `limit` number of messages from the nodeInBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed
"""
with self.metrics.measure_time(MetricsName.SE... | [
"async",
"def",
"serviceNodeMsgs",
"(",
"self",
",",
"limit",
":",
"int",
")",
"->",
"int",
":",
"with",
"self",
".",
"metrics",
".",
"measure_time",
"(",
"MetricsName",
".",
"SERVICE_NODE_STACK_TIME",
")",
":",
"n",
"=",
"await",
"self",
".",
"nodestack",... | Process `limit` number of messages from the nodeInBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed | [
"Process",
"limit",
"number",
"of",
"messages",
"from",
"the",
"nodeInBox",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1368-L1381 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.serviceClientMsgs | async def serviceClientMsgs(self, limit: int) -> int:
"""
Process `limit` number of messages from the clientInBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed
"""
c = await self.clientstack.service(limit,... | python | async def serviceClientMsgs(self, limit: int) -> int:
"""
Process `limit` number of messages from the clientInBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed
"""
c = await self.clientstack.service(limit,... | [
"async",
"def",
"serviceClientMsgs",
"(",
"self",
",",
"limit",
":",
"int",
")",
"->",
"int",
":",
"c",
"=",
"await",
"self",
".",
"clientstack",
".",
"service",
"(",
"limit",
",",
"self",
".",
"quota_control",
".",
"client_quota",
")",
"self",
".",
"m... | Process `limit` number of messages from the clientInBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed | [
"Process",
"limit",
"number",
"of",
"messages",
"from",
"the",
"clientInBox",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1384-L1395 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.serviceViewChanger | async def serviceViewChanger(self, limit) -> int:
"""
Service the view_changer's inBox, outBox and action queues.
:return: the number of messages successfully serviced
"""
if not self.isReady():
return 0
o = self.serviceViewChangerOutBox(limit)
i = aw... | python | async def serviceViewChanger(self, limit) -> int:
"""
Service the view_changer's inBox, outBox and action queues.
:return: the number of messages successfully serviced
"""
if not self.isReady():
return 0
o = self.serviceViewChangerOutBox(limit)
i = aw... | [
"async",
"def",
"serviceViewChanger",
"(",
"self",
",",
"limit",
")",
"->",
"int",
":",
"if",
"not",
"self",
".",
"isReady",
"(",
")",
":",
"return",
"0",
"o",
"=",
"self",
".",
"serviceViewChangerOutBox",
"(",
"limit",
")",
"i",
"=",
"await",
"self",
... | Service the view_changer's inBox, outBox and action queues.
:return: the number of messages successfully serviced | [
"Service",
"the",
"view_changer",
"s",
"inBox",
"outBox",
"and",
"action",
"queues",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1398-L1408 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.service_observable | async def service_observable(self, limit) -> int:
"""
Service the observable's inBox and outBox
:return: the number of messages successfully serviced
"""
if not self.isReady():
return 0
o = self._service_observable_out_box(limit)
i = await self._obser... | python | async def service_observable(self, limit) -> int:
"""
Service the observable's inBox and outBox
:return: the number of messages successfully serviced
"""
if not self.isReady():
return 0
o = self._service_observable_out_box(limit)
i = await self._obser... | [
"async",
"def",
"service_observable",
"(",
"self",
",",
"limit",
")",
"->",
"int",
":",
"if",
"not",
"self",
".",
"isReady",
"(",
")",
":",
"return",
"0",
"o",
"=",
"self",
".",
"_service_observable_out_box",
"(",
"limit",
")",
"i",
"=",
"await",
"self... | Service the observable's inBox and outBox
:return: the number of messages successfully serviced | [
"Service",
"the",
"observable",
"s",
"inBox",
"and",
"outBox"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1411-L1421 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node._service_observable_out_box | def _service_observable_out_box(self, limit: int = None) -> int:
"""
Service at most `limit` number of messages from the observable's outBox.
:return: the number of messages successfully serviced.
"""
msg_count = 0
while True:
if limit and msg_count >= limit:... | python | def _service_observable_out_box(self, limit: int = None) -> int:
"""
Service at most `limit` number of messages from the observable's outBox.
:return: the number of messages successfully serviced.
"""
msg_count = 0
while True:
if limit and msg_count >= limit:... | [
"def",
"_service_observable_out_box",
"(",
"self",
",",
"limit",
":",
"int",
"=",
"None",
")",
"->",
"int",
":",
"msg_count",
"=",
"0",
"while",
"True",
":",
"if",
"limit",
"and",
"msg_count",
">=",
"limit",
":",
"break",
"msg",
"=",
"self",
".",
"_obs... | Service at most `limit` number of messages from the observable's outBox.
:return: the number of messages successfully serviced. | [
"Service",
"at",
"most",
"limit",
"number",
"of",
"messages",
"from",
"the",
"observable",
"s",
"outBox",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1423-L1442 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.service_observer | async def service_observer(self, limit) -> int:
"""
Service the observer's inBox and outBox
:return: the number of messages successfully serviced
"""
if not self.isReady():
return 0
return await self._observer.serviceQueues(limit) | python | async def service_observer(self, limit) -> int:
"""
Service the observer's inBox and outBox
:return: the number of messages successfully serviced
"""
if not self.isReady():
return 0
return await self._observer.serviceQueues(limit) | [
"async",
"def",
"service_observer",
"(",
"self",
",",
"limit",
")",
"->",
"int",
":",
"if",
"not",
"self",
".",
"isReady",
"(",
")",
":",
"return",
"0",
"return",
"await",
"self",
".",
"_observer",
".",
"serviceQueues",
"(",
"limit",
")"
] | Service the observer's inBox and outBox
:return: the number of messages successfully serviced | [
"Service",
"the",
"observer",
"s",
"inBox",
"and",
"outBox"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1445-L1453 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node._ask_for_ledger_status | def _ask_for_ledger_status(self, node_name: str, ledger_id):
"""
Ask other node for LedgerStatus
"""
self.request_msg(LEDGER_STATUS, {f.LEDGER_ID.nm: ledger_id},
[node_name, ])
logger.info("{} asking {} for ledger status of ledger {}".format(self, node_na... | python | def _ask_for_ledger_status(self, node_name: str, ledger_id):
"""
Ask other node for LedgerStatus
"""
self.request_msg(LEDGER_STATUS, {f.LEDGER_ID.nm: ledger_id},
[node_name, ])
logger.info("{} asking {} for ledger status of ledger {}".format(self, node_na... | [
"def",
"_ask_for_ledger_status",
"(",
"self",
",",
"node_name",
":",
"str",
",",
"ledger_id",
")",
":",
"self",
".",
"request_msg",
"(",
"LEDGER_STATUS",
",",
"{",
"f",
".",
"LEDGER_ID",
".",
"nm",
":",
"ledger_id",
"}",
",",
"[",
"node_name",
",",
"]",
... | Ask other node for LedgerStatus | [
"Ask",
"other",
"node",
"for",
"LedgerStatus"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1525-L1531 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.checkInstances | def checkInstances(self) -> None:
# TODO: Is this method really needed?
"""
Check if this node has the minimum required number of protocol
instances, i.e. f+1. If not, add a replica. If no election is in
progress, this node will try to nominate one of its replicas as primary.
... | python | def checkInstances(self) -> None:
# TODO: Is this method really needed?
"""
Check if this node has the minimum required number of protocol
instances, i.e. f+1. If not, add a replica. If no election is in
progress, this node will try to nominate one of its replicas as primary.
... | [
"def",
"checkInstances",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"\"{} choosing to start election on the basis of count {} and nodes {}\"",
".",
"format",
"(",
"self",
",",
"self",
".",
"connectedNodeCount",
",",
"self",
".",
"nodestack",
"... | Check if this node has the minimum required number of protocol
instances, i.e. f+1. If not, add a replica. If no election is in
progress, this node will try to nominate one of its replicas as primary.
This method is called whenever a connection with a new node is
established. | [
"Check",
"if",
"this",
"node",
"has",
"the",
"minimum",
"required",
"number",
"of",
"protocol",
"instances",
"i",
".",
"e",
".",
"f",
"+",
"1",
".",
"If",
"not",
"add",
"a",
"replica",
".",
"If",
"no",
"election",
"is",
"in",
"progress",
"this",
"nod... | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1587-L1597 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.adjustReplicas | def adjustReplicas(self,
old_required_number_of_instances: int,
new_required_number_of_instances: int):
"""
Add or remove replicas depending on `f`
"""
# TODO: refactor this
replica_num = old_required_number_of_instances
while... | python | def adjustReplicas(self,
old_required_number_of_instances: int,
new_required_number_of_instances: int):
"""
Add or remove replicas depending on `f`
"""
# TODO: refactor this
replica_num = old_required_number_of_instances
while... | [
"def",
"adjustReplicas",
"(",
"self",
",",
"old_required_number_of_instances",
":",
"int",
",",
"new_required_number_of_instances",
":",
"int",
")",
":",
"replica_num",
"=",
"old_required_number_of_instances",
"while",
"replica_num",
"<",
"new_required_number_of_instances",
... | Add or remove replicas depending on `f` | [
"Add",
"or",
"remove",
"replicas",
"depending",
"on",
"f"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1599-L1622 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node._check_view_change_completed | def _check_view_change_completed(self):
"""
This thing checks whether new primary was elected.
If it was not - starts view change again
"""
logger.info('{} running the scheduled check for view change completion'.format(self))
if not self.view_changer.view_change_in_progre... | python | def _check_view_change_completed(self):
"""
This thing checks whether new primary was elected.
If it was not - starts view change again
"""
logger.info('{} running the scheduled check for view change completion'.format(self))
if not self.view_changer.view_change_in_progre... | [
"def",
"_check_view_change_completed",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'{} running the scheduled check for view change completion'",
".",
"format",
"(",
"self",
")",
")",
"if",
"not",
"self",
".",
"view_changer",
".",
"view_change_in_progress",
":"... | This thing checks whether new primary was elected.
If it was not - starts view change again | [
"This",
"thing",
"checks",
"whether",
"new",
"primary",
"was",
"elected",
".",
"If",
"it",
"was",
"not",
"-",
"starts",
"view",
"change",
"again"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1663-L1674 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.service_replicas_outbox | def service_replicas_outbox(self, limit: int = None) -> int:
"""
Process `limit` number of replica messages
"""
# TODO: rewrite this using Router
num_processed = 0
for message in self.replicas.get_output(limit):
num_processed += 1
if isinstance(me... | python | def service_replicas_outbox(self, limit: int = None) -> int:
"""
Process `limit` number of replica messages
"""
# TODO: rewrite this using Router
num_processed = 0
for message in self.replicas.get_output(limit):
num_processed += 1
if isinstance(me... | [
"def",
"service_replicas_outbox",
"(",
"self",
",",
"limit",
":",
"int",
"=",
"None",
")",
"->",
"int",
":",
"num_processed",
"=",
"0",
"for",
"message",
"in",
"self",
".",
"replicas",
".",
"get_output",
"(",
"limit",
")",
":",
"num_processed",
"+=",
"1"... | Process `limit` number of replica messages | [
"Process",
"limit",
"number",
"of",
"replica",
"messages"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1677-L1708 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.master_primary_name | def master_primary_name(self) -> Optional[str]:
"""
Return the name of the primary node of the master instance
"""
master_primary_name = self.master_replica.primaryName
if master_primary_name:
return self.master_replica.getNodeName(master_primary_name)
return... | python | def master_primary_name(self) -> Optional[str]:
"""
Return the name of the primary node of the master instance
"""
master_primary_name = self.master_replica.primaryName
if master_primary_name:
return self.master_replica.getNodeName(master_primary_name)
return... | [
"def",
"master_primary_name",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"master_primary_name",
"=",
"self",
".",
"master_replica",
".",
"primaryName",
"if",
"master_primary_name",
":",
"return",
"self",
".",
"master_replica",
".",
"getNodeName",
... | Return the name of the primary node of the master instance | [
"Return",
"the",
"name",
"of",
"the",
"primary",
"node",
"of",
"the",
"master",
"instance"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1758-L1766 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.msgHasAcceptableInstId | def msgHasAcceptableInstId(self, msg, frm) -> bool:
"""
Return true if the instance id of message corresponds to a correct
replica.
:param msg: the node message to validate
:return:
"""
# TODO: refactor this! this should not do anything except checking!
i... | python | def msgHasAcceptableInstId(self, msg, frm) -> bool:
"""
Return true if the instance id of message corresponds to a correct
replica.
:param msg: the node message to validate
:return:
"""
# TODO: refactor this! this should not do anything except checking!
i... | [
"def",
"msgHasAcceptableInstId",
"(",
"self",
",",
"msg",
",",
"frm",
")",
"->",
"bool",
":",
"instId",
"=",
"getattr",
"(",
"msg",
",",
"f",
".",
"INST_ID",
".",
"nm",
",",
"None",
")",
"if",
"not",
"(",
"isinstance",
"(",
"instId",
",",
"int",
")... | Return true if the instance id of message corresponds to a correct
replica.
:param msg: the node message to validate
:return: | [
"Return",
"true",
"if",
"the",
"instance",
"id",
"of",
"message",
"corresponds",
"to",
"a",
"correct",
"replica",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1778-L1796 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.sendToReplica | def sendToReplica(self, msg, frm):
"""
Send the message to the intended replica.
:param msg: the message to send
:param frm: the name of the node which sent this `msg`
"""
# TODO: discard or stash messages here instead of doing
# this in msgHas* methods!!!
... | python | def sendToReplica(self, msg, frm):
"""
Send the message to the intended replica.
:param msg: the message to send
:param frm: the name of the node which sent this `msg`
"""
# TODO: discard or stash messages here instead of doing
# this in msgHas* methods!!!
... | [
"def",
"sendToReplica",
"(",
"self",
",",
"msg",
",",
"frm",
")",
":",
"if",
"self",
".",
"msgHasAcceptableInstId",
"(",
"msg",
",",
"frm",
")",
":",
"self",
".",
"replicas",
".",
"pass_message",
"(",
"(",
"msg",
",",
"frm",
")",
",",
"msg",
".",
"... | Send the message to the intended replica.
:param msg: the message to send
:param frm: the name of the node which sent this `msg` | [
"Send",
"the",
"message",
"to",
"the",
"intended",
"replica",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1831-L1841 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.sendToViewChanger | def sendToViewChanger(self, msg, frm):
"""
Send the message to the intended view changer.
:param msg: the message to send
:param frm: the name of the node which sent this `msg`
"""
if (isinstance(msg, InstanceChange) or
self.msgHasAcceptableViewNo(msg, fr... | python | def sendToViewChanger(self, msg, frm):
"""
Send the message to the intended view changer.
:param msg: the message to send
:param frm: the name of the node which sent this `msg`
"""
if (isinstance(msg, InstanceChange) or
self.msgHasAcceptableViewNo(msg, fr... | [
"def",
"sendToViewChanger",
"(",
"self",
",",
"msg",
",",
"frm",
")",
":",
"if",
"(",
"isinstance",
"(",
"msg",
",",
"InstanceChange",
")",
"or",
"self",
".",
"msgHasAcceptableViewNo",
"(",
"msg",
",",
"frm",
")",
")",
":",
"logger",
".",
"debug",
"(",... | Send the message to the intended view changer.
:param msg: the message to send
:param frm: the name of the node which sent this `msg` | [
"Send",
"the",
"message",
"to",
"the",
"intended",
"view",
"changer",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1843-L1854 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.send_to_observer | def send_to_observer(self, msg, frm):
"""
Send the message to the observer.
:param msg: the message to send
:param frm: the name of the node which sent this `msg`
"""
logger.debug("{} sending message to observer: {}".
format(self, (msg, frm)))
... | python | def send_to_observer(self, msg, frm):
"""
Send the message to the observer.
:param msg: the message to send
:param frm: the name of the node which sent this `msg`
"""
logger.debug("{} sending message to observer: {}".
format(self, (msg, frm)))
... | [
"def",
"send_to_observer",
"(",
"self",
",",
"msg",
",",
"frm",
")",
":",
"logger",
".",
"debug",
"(",
"\"{} sending message to observer: {}\"",
".",
"format",
"(",
"self",
",",
"(",
"msg",
",",
"frm",
")",
")",
")",
"self",
".",
"_observer",
".",
"appen... | Send the message to the observer.
:param msg: the message to send
:param frm: the name of the node which sent this `msg` | [
"Send",
"the",
"message",
"to",
"the",
"observer",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1856-L1865 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.handleOneNodeMsg | def handleOneNodeMsg(self, wrappedMsg):
"""
Validate and process one message from a node.
:param wrappedMsg: Tuple of message and the name of the node that sent
the message
"""
try:
vmsg = self.validateNodeMsg(wrappedMsg)
if vmsg:
... | python | def handleOneNodeMsg(self, wrappedMsg):
"""
Validate and process one message from a node.
:param wrappedMsg: Tuple of message and the name of the node that sent
the message
"""
try:
vmsg = self.validateNodeMsg(wrappedMsg)
if vmsg:
... | [
"def",
"handleOneNodeMsg",
"(",
"self",
",",
"wrappedMsg",
")",
":",
"try",
":",
"vmsg",
"=",
"self",
".",
"validateNodeMsg",
"(",
"wrappedMsg",
")",
"if",
"vmsg",
":",
"logger",
".",
"trace",
"(",
"\"{} msg validated {}\"",
".",
"format",
"(",
"self",
","... | Validate and process one message from a node.
:param wrappedMsg: Tuple of message and the name of the node that sent
the message | [
"Validate",
"and",
"process",
"one",
"message",
"from",
"a",
"node",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1867-L1887 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.validateNodeMsg | def validateNodeMsg(self, wrappedMsg):
"""
Validate another node's message sent to this node.
:param wrappedMsg: Tuple of message and the name of the node that sent
the message
:return: Tuple of message from node and name of the node
"""
msg, frm = wrappedMsg
... | python | def validateNodeMsg(self, wrappedMsg):
"""
Validate another node's message sent to this node.
:param wrappedMsg: Tuple of message and the name of the node that sent
the message
:return: Tuple of message from node and name of the node
"""
msg, frm = wrappedMsg
... | [
"def",
"validateNodeMsg",
"(",
"self",
",",
"wrappedMsg",
")",
":",
"msg",
",",
"frm",
"=",
"wrappedMsg",
"if",
"self",
".",
"isNodeBlacklisted",
"(",
"frm",
")",
":",
"self",
".",
"discard",
"(",
"str",
"(",
"msg",
")",
"[",
":",
"256",
"]",
",",
... | Validate another node's message sent to this node.
:param wrappedMsg: Tuple of message and the name of the node that sent
the message
:return: Tuple of message from node and name of the node | [
"Validate",
"another",
"node",
"s",
"message",
"sent",
"to",
"this",
"node",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1890-L1916 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.unpackNodeMsg | def unpackNodeMsg(self, msg, frm) -> None:
"""
If the message is a batch message validate each message in the batch,
otherwise add the message to the node's inbox.
:param msg: a node message
:param frm: the name of the node that sent this `msg`
"""
# TODO: why do... | python | def unpackNodeMsg(self, msg, frm) -> None:
"""
If the message is a batch message validate each message in the batch,
otherwise add the message to the node's inbox.
:param msg: a node message
:param frm: the name of the node that sent this `msg`
"""
# TODO: why do... | [
"def",
"unpackNodeMsg",
"(",
"self",
",",
"msg",
",",
"frm",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"msg",
",",
"Batch",
")",
":",
"logger",
".",
"trace",
"(",
"\"{} processing a batch {}\"",
".",
"format",
"(",
"self",
",",
"msg",
")",
")",
... | If the message is a batch message validate each message in the batch,
otherwise add the message to the node's inbox.
:param msg: a node message
:param frm: the name of the node that sent this `msg` | [
"If",
"the",
"message",
"is",
"a",
"batch",
"message",
"validate",
"each",
"message",
"in",
"the",
"batch",
"otherwise",
"add",
"the",
"message",
"to",
"the",
"node",
"s",
"inbox",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1918-L1940 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.postToNodeInBox | def postToNodeInBox(self, msg, frm):
"""
Append the message to the node inbox
:param msg: a node message
:param frm: the name of the node that sent this `msg`
"""
logger.trace("{} appending to nodeInbox {}".format(self, msg))
self.nodeInBox.append((msg, frm)) | python | def postToNodeInBox(self, msg, frm):
"""
Append the message to the node inbox
:param msg: a node message
:param frm: the name of the node that sent this `msg`
"""
logger.trace("{} appending to nodeInbox {}".format(self, msg))
self.nodeInBox.append((msg, frm)) | [
"def",
"postToNodeInBox",
"(",
"self",
",",
"msg",
",",
"frm",
")",
":",
"logger",
".",
"trace",
"(",
"\"{} appending to nodeInbox {}\"",
".",
"format",
"(",
"self",
",",
"msg",
")",
")",
"self",
".",
"nodeInBox",
".",
"append",
"(",
"(",
"msg",
",",
"... | Append the message to the node inbox
:param msg: a node message
:param frm: the name of the node that sent this `msg` | [
"Append",
"the",
"message",
"to",
"the",
"node",
"inbox"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1942-L1950 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.processNodeInBox | async def processNodeInBox(self):
"""
Process the messages in the node inbox asynchronously.
"""
while self.nodeInBox:
m = self.nodeInBox.popleft()
await self.process_one_node_message(m) | python | async def processNodeInBox(self):
"""
Process the messages in the node inbox asynchronously.
"""
while self.nodeInBox:
m = self.nodeInBox.popleft()
await self.process_one_node_message(m) | [
"async",
"def",
"processNodeInBox",
"(",
"self",
")",
":",
"while",
"self",
".",
"nodeInBox",
":",
"m",
"=",
"self",
".",
"nodeInBox",
".",
"popleft",
"(",
")",
"await",
"self",
".",
"process_one_node_message",
"(",
"m",
")"
] | Process the messages in the node inbox asynchronously. | [
"Process",
"the",
"messages",
"in",
"the",
"node",
"inbox",
"asynchronously",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1953-L1959 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.handleOneClientMsg | def handleOneClientMsg(self, wrappedMsg):
"""
Validate and process a client message
:param wrappedMsg: a message from a client
"""
try:
vmsg = self.validateClientMsg(wrappedMsg)
if vmsg:
self.unpackClientMsg(*vmsg)
except BlowUp:
... | python | def handleOneClientMsg(self, wrappedMsg):
"""
Validate and process a client message
:param wrappedMsg: a message from a client
"""
try:
vmsg = self.validateClientMsg(wrappedMsg)
if vmsg:
self.unpackClientMsg(*vmsg)
except BlowUp:
... | [
"def",
"handleOneClientMsg",
"(",
"self",
",",
"wrappedMsg",
")",
":",
"try",
":",
"vmsg",
"=",
"self",
".",
"validateClientMsg",
"(",
"wrappedMsg",
")",
"if",
"vmsg",
":",
"self",
".",
"unpackClientMsg",
"(",
"*",
"vmsg",
")",
"except",
"BlowUp",
":",
"... | Validate and process a client message
:param wrappedMsg: a message from a client | [
"Validate",
"and",
"process",
"a",
"client",
"message"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1968-L1986 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.processClientInBox | async def processClientInBox(self):
"""
Process the messages in the node's clientInBox asynchronously.
All messages in the inBox have already been validated, including
signature check.
"""
while self.clientInBox:
m = self.clientInBox.popleft()
req,... | python | async def processClientInBox(self):
"""
Process the messages in the node's clientInBox asynchronously.
All messages in the inBox have already been validated, including
signature check.
"""
while self.clientInBox:
m = self.clientInBox.popleft()
req,... | [
"async",
"def",
"processClientInBox",
"(",
"self",
")",
":",
"while",
"self",
".",
"clientInBox",
":",
"m",
"=",
"self",
".",
"clientInBox",
".",
"popleft",
"(",
")",
"req",
",",
"frm",
"=",
"m",
"logger",
".",
"debug",
"(",
"\"{} processing {} request {}\... | Process the messages in the node's clientInBox asynchronously.
All messages in the inBox have already been validated, including
signature check. | [
"Process",
"the",
"messages",
"in",
"the",
"node",
"s",
"clientInBox",
"asynchronously",
".",
"All",
"messages",
"in",
"the",
"inBox",
"have",
"already",
"been",
"validated",
"including",
"signature",
"check",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2120-L2137 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.is_catchup_needed_during_view_change | def is_catchup_needed_during_view_change(self) -> bool:
"""
Check if received a quorum of view change done messages and if yes
check if caught up till the
Check if all requests ordered till last prepared certificate
Check if last catchup resulted in no txns
"""
if... | python | def is_catchup_needed_during_view_change(self) -> bool:
"""
Check if received a quorum of view change done messages and if yes
check if caught up till the
Check if all requests ordered till last prepared certificate
Check if last catchup resulted in no txns
"""
if... | [
"def",
"is_catchup_needed_during_view_change",
"(",
"self",
")",
"->",
"bool",
":",
"if",
"self",
".",
"caught_up_for_current_view",
"(",
")",
":",
"logger",
".",
"info",
"(",
"'{} is caught up for the current view {}'",
".",
"format",
"(",
"self",
",",
"self",
".... | Check if received a quorum of view change done messages and if yes
check if caught up till the
Check if all requests ordered till last prepared certificate
Check if last catchup resulted in no txns | [
"Check",
"if",
"received",
"a",
"quorum",
"of",
"view",
"change",
"done",
"messages",
"and",
"if",
"yes",
"check",
"if",
"caught",
"up",
"till",
"the",
"Check",
"if",
"all",
"requests",
"ordered",
"till",
"last",
"prepared",
"certificate",
"Check",
"if",
"... | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2275-L2298 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.doDynamicValidation | def doDynamicValidation(self, request: Request):
"""
State based validation
"""
self.execute_hook(NodeHooks.PRE_DYNAMIC_VALIDATION, request=request)
# Digest validation
ledger_id, seq_no = self.seqNoDB.get_by_payload_digest(request.payload_digest)
if ledger_id is... | python | def doDynamicValidation(self, request: Request):
"""
State based validation
"""
self.execute_hook(NodeHooks.PRE_DYNAMIC_VALIDATION, request=request)
# Digest validation
ledger_id, seq_no = self.seqNoDB.get_by_payload_digest(request.payload_digest)
if ledger_id is... | [
"def",
"doDynamicValidation",
"(",
"self",
",",
"request",
":",
"Request",
")",
":",
"self",
".",
"execute_hook",
"(",
"NodeHooks",
".",
"PRE_DYNAMIC_VALIDATION",
",",
"request",
"=",
"request",
")",
"ledger_id",
",",
"seq_no",
"=",
"self",
".",
"seqNoDB",
"... | State based validation | [
"State",
"based",
"validation"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2401-L2421 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.applyReq | def applyReq(self, request: Request, cons_time: int):
"""
Apply request to appropriate ledger and state. `cons_time` is the
UTC epoch at which consensus was reached.
"""
self.execute_hook(NodeHooks.PRE_REQUEST_APPLICATION, request=request,
cons_time=cons... | python | def applyReq(self, request: Request, cons_time: int):
"""
Apply request to appropriate ledger and state. `cons_time` is the
UTC epoch at which consensus was reached.
"""
self.execute_hook(NodeHooks.PRE_REQUEST_APPLICATION, request=request,
cons_time=cons... | [
"def",
"applyReq",
"(",
"self",
",",
"request",
":",
"Request",
",",
"cons_time",
":",
"int",
")",
":",
"self",
".",
"execute_hook",
"(",
"NodeHooks",
".",
"PRE_REQUEST_APPLICATION",
",",
"request",
"=",
"request",
",",
"cons_time",
"=",
"cons_time",
")",
... | Apply request to appropriate ledger and state. `cons_time` is the
UTC epoch at which consensus was reached. | [
"Apply",
"request",
"to",
"appropriate",
"ledger",
"and",
"state",
".",
"cons_time",
"is",
"the",
"UTC",
"epoch",
"at",
"which",
"consensus",
"was",
"reached",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2423-L2435 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.processRequest | def processRequest(self, request: Request, frm: str):
"""
Handle a REQUEST from the client.
If the request has already been executed, the node re-sends the reply to
the client. Otherwise, the node acknowledges the client request, adds it
to its list of client requests, and sends ... | python | def processRequest(self, request: Request, frm: str):
"""
Handle a REQUEST from the client.
If the request has already been executed, the node re-sends the reply to
the client. Otherwise, the node acknowledges the client request, adds it
to its list of client requests, and sends ... | [
"def",
"processRequest",
"(",
"self",
",",
"request",
":",
"Request",
",",
"frm",
":",
"str",
")",
":",
"logger",
".",
"debug",
"(",
"\"{} received client request: {} from {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"request",
",",
"frm",
")",
")"... | Handle a REQUEST from the client.
If the request has already been executed, the node re-sends the reply to
the client. Otherwise, the node acknowledges the client request, adds it
to its list of client requests, and sends a PROPAGATE to the
remaining nodes.
:param request: the R... | [
"Handle",
"a",
"REQUEST",
"from",
"the",
"client",
".",
"If",
"the",
"request",
"has",
"already",
"been",
"executed",
"the",
"node",
"re",
"-",
"sends",
"the",
"reply",
"to",
"the",
"client",
".",
"Otherwise",
"the",
"node",
"acknowledges",
"the",
"client"... | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2464-L2528 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.processPropagate | def processPropagate(self, msg: Propagate, frm):
"""
Process one propagateRequest sent to this node asynchronously
- If this propagateRequest hasn't been seen by this node, then broadcast
it to all nodes after verifying the the signature.
- Add the client to blacklist if its sig... | python | def processPropagate(self, msg: Propagate, frm):
"""
Process one propagateRequest sent to this node asynchronously
- If this propagateRequest hasn't been seen by this node, then broadcast
it to all nodes after verifying the the signature.
- Add the client to blacklist if its sig... | [
"def",
"processPropagate",
"(",
"self",
",",
"msg",
":",
"Propagate",
",",
"frm",
")",
":",
"logger",
".",
"debug",
"(",
"\"{} received propagated request: {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"msg",
")",
")",
"request",
"=",
"TxnUtilConfig",... | Process one propagateRequest sent to this node asynchronously
- If this propagateRequest hasn't been seen by this node, then broadcast
it to all nodes after verifying the the signature.
- Add the client to blacklist if its signature is invalid
:param msg: the propagateRequest
:... | [
"Process",
"one",
"propagateRequest",
"sent",
"to",
"this",
"node",
"asynchronously"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2569-L2610 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.handle_get_txn_req | def handle_get_txn_req(self, request: Request, frm: str):
"""
Handle GET_TXN request
"""
ledger_id = request.operation.get(f.LEDGER_ID.nm, DOMAIN_LEDGER_ID)
if ledger_id not in self.ledger_to_req_handler:
self.send_nack_to_client((request.identifier, request.reqId),
... | python | def handle_get_txn_req(self, request: Request, frm: str):
"""
Handle GET_TXN request
"""
ledger_id = request.operation.get(f.LEDGER_ID.nm, DOMAIN_LEDGER_ID)
if ledger_id not in self.ledger_to_req_handler:
self.send_nack_to_client((request.identifier, request.reqId),
... | [
"def",
"handle_get_txn_req",
"(",
"self",
",",
"request",
":",
"Request",
",",
"frm",
":",
"str",
")",
":",
"ledger_id",
"=",
"request",
".",
"operation",
".",
"get",
"(",
"f",
".",
"LEDGER_ID",
".",
"nm",
",",
"DOMAIN_LEDGER_ID",
")",
"if",
"ledger_id",... | Handle GET_TXN request | [
"Handle",
"GET_TXN",
"request"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2634-L2670 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.processOrdered | def processOrdered(self, ordered: Ordered):
"""
Execute ordered request
:param ordered: an ordered request
:return: whether executed
"""
if ordered.instId not in self.instances.ids:
logger.warning('{} got ordered request for instance {} which '
... | python | def processOrdered(self, ordered: Ordered):
"""
Execute ordered request
:param ordered: an ordered request
:return: whether executed
"""
if ordered.instId not in self.instances.ids:
logger.warning('{} got ordered request for instance {} which '
... | [
"def",
"processOrdered",
"(",
"self",
",",
"ordered",
":",
"Ordered",
")",
":",
"if",
"ordered",
".",
"instId",
"not",
"in",
"self",
".",
"instances",
".",
"ids",
":",
"logger",
".",
"warning",
"(",
"'{} got ordered request for instance {} which '",
"'does not e... | Execute ordered request
:param ordered: an ordered request
:return: whether executed | [
"Execute",
"ordered",
"request"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2673-L2735 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.force_process_ordered | def force_process_ordered(self):
"""
Take any messages from replica that have been ordered and process
them, this should be done rarely, like before catchup starts
so a more current LedgerStatus can be sent.
can be called either
1. when node is participating, this happens... | python | def force_process_ordered(self):
"""
Take any messages from replica that have been ordered and process
them, this should be done rarely, like before catchup starts
so a more current LedgerStatus can be sent.
can be called either
1. when node is participating, this happens... | [
"def",
"force_process_ordered",
"(",
"self",
")",
":",
"for",
"instance_id",
",",
"messages",
"in",
"self",
".",
"replicas",
".",
"take_ordereds_out_of_turn",
"(",
")",
":",
"num_processed",
"=",
"0",
"for",
"message",
"in",
"messages",
":",
"self",
".",
"tr... | Take any messages from replica that have been ordered and process
them, this should be done rarely, like before catchup starts
so a more current LedgerStatus can be sent.
can be called either
1. when node is participating, this happens just before catchup starts
so the node can h... | [
"Take",
"any",
"messages",
"from",
"replica",
"that",
"have",
"been",
"ordered",
"and",
"process",
"them",
"this",
"should",
"be",
"done",
"rarely",
"like",
"before",
"catchup",
"starts",
"so",
"a",
"more",
"current",
"LedgerStatus",
"can",
"be",
"sent",
"."... | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2737-L2758 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.processEscalatedException | def processEscalatedException(self, ex):
"""
Process an exception escalated from a Replica
"""
if isinstance(ex, SuspiciousNode):
self.reportSuspiciousNodeEx(ex)
else:
raise RuntimeError("unhandled replica-escalated exception") from ex | python | def processEscalatedException(self, ex):
"""
Process an exception escalated from a Replica
"""
if isinstance(ex, SuspiciousNode):
self.reportSuspiciousNodeEx(ex)
else:
raise RuntimeError("unhandled replica-escalated exception") from ex | [
"def",
"processEscalatedException",
"(",
"self",
",",
"ex",
")",
":",
"if",
"isinstance",
"(",
"ex",
",",
"SuspiciousNode",
")",
":",
"self",
".",
"reportSuspiciousNodeEx",
"(",
"ex",
")",
"else",
":",
"raise",
"RuntimeError",
"(",
"\"unhandled replica-escalated... | Process an exception escalated from a Replica | [
"Process",
"an",
"exception",
"escalated",
"from",
"a",
"Replica"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L2766-L2773 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.lost_master_primary | def lost_master_primary(self):
"""
Schedule an primary connection check which in turn can send a view
change message
"""
self.primaries_disconnection_times[self.master_replica.instId] = time.perf_counter()
self._schedule_view_change() | python | def lost_master_primary(self):
"""
Schedule an primary connection check which in turn can send a view
change message
"""
self.primaries_disconnection_times[self.master_replica.instId] = time.perf_counter()
self._schedule_view_change() | [
"def",
"lost_master_primary",
"(",
"self",
")",
":",
"self",
".",
"primaries_disconnection_times",
"[",
"self",
".",
"master_replica",
".",
"instId",
"]",
"=",
"time",
".",
"perf_counter",
"(",
")",
"self",
".",
"_schedule_view_change",
"(",
")"
] | Schedule an primary connection check which in turn can send a view
change message | [
"Schedule",
"an",
"primary",
"connection",
"check",
"which",
"in",
"turn",
"can",
"send",
"a",
"view",
"change",
"message"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3134-L3140 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.executeBatch | def executeBatch(self, three_pc_batch: ThreePcBatch,
valid_reqs_keys: List, invalid_reqs_keys: List,
audit_txn_root) -> None:
"""
Execute the REQUEST sent to this Node
:param view_no: the view number (See glossary)
:param pp_time: the time at wh... | python | def executeBatch(self, three_pc_batch: ThreePcBatch,
valid_reqs_keys: List, invalid_reqs_keys: List,
audit_txn_root) -> None:
"""
Execute the REQUEST sent to this Node
:param view_no: the view number (See glossary)
:param pp_time: the time at wh... | [
"def",
"executeBatch",
"(",
"self",
",",
"three_pc_batch",
":",
"ThreePcBatch",
",",
"valid_reqs_keys",
":",
"List",
",",
"invalid_reqs_keys",
":",
"List",
",",
"audit_txn_root",
")",
"->",
"None",
":",
"three_pc_batch",
".",
"txn_root",
"=",
"Ledger",
".",
"h... | Execute the REQUEST sent to this Node
:param view_no: the view number (See glossary)
:param pp_time: the time at which PRE-PREPARE was sent
:param valid_reqs: list of valid client requests keys
:param valid_reqs: list of invalid client requests keys | [
"Execute",
"the",
"REQUEST",
"sent",
"to",
"this",
"Node"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3251-L3346 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.addNewRole | def addNewRole(self, txn):
"""
Adds a new client or steward to this node based on transaction type.
"""
# If the client authenticator is a simple authenticator then add verkey.
# For a custom authenticator, handle appropriately.
# NOTE: The following code should not be u... | python | def addNewRole(self, txn):
"""
Adds a new client or steward to this node based on transaction type.
"""
# If the client authenticator is a simple authenticator then add verkey.
# For a custom authenticator, handle appropriately.
# NOTE: The following code should not be u... | [
"def",
"addNewRole",
"(",
"self",
",",
"txn",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"clientAuthNr",
".",
"core_authenticator",
",",
"SimpleAuthNr",
")",
":",
"txn_data",
"=",
"get_payload_data",
"(",
"txn",
")",
"identifier",
"=",
"txn_data",
"[",
... | Adds a new client or steward to this node based on transaction type. | [
"Adds",
"a",
"new",
"client",
"or",
"steward",
"to",
"this",
"node",
"based",
"on",
"transaction",
"type",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3441-L3461 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.ensureKeysAreSetup | def ensureKeysAreSetup(self):
"""
Check whether the keys are setup in the local STP keep.
Raises KeysNotFoundException if not found.
"""
if not areKeysSetup(self.name, self.keys_dir):
raise REx(REx.reason.format(self.name) + self.keygenScript) | python | def ensureKeysAreSetup(self):
"""
Check whether the keys are setup in the local STP keep.
Raises KeysNotFoundException if not found.
"""
if not areKeysSetup(self.name, self.keys_dir):
raise REx(REx.reason.format(self.name) + self.keygenScript) | [
"def",
"ensureKeysAreSetup",
"(",
"self",
")",
":",
"if",
"not",
"areKeysSetup",
"(",
"self",
".",
"name",
",",
"self",
".",
"keys_dir",
")",
":",
"raise",
"REx",
"(",
"REx",
".",
"reason",
".",
"format",
"(",
"self",
".",
"name",
")",
"+",
"self",
... | Check whether the keys are setup in the local STP keep.
Raises KeysNotFoundException if not found. | [
"Check",
"whether",
"the",
"keys",
"are",
"setup",
"in",
"the",
"local",
"STP",
"keep",
".",
"Raises",
"KeysNotFoundException",
"if",
"not",
"found",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3478-L3484 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.reportSuspiciousNodeEx | def reportSuspiciousNodeEx(self, ex: SuspiciousNode):
"""
Report suspicion on a node on the basis of an exception
"""
self.reportSuspiciousNode(ex.node, ex.reason, ex.code, ex.offendingMsg) | python | def reportSuspiciousNodeEx(self, ex: SuspiciousNode):
"""
Report suspicion on a node on the basis of an exception
"""
self.reportSuspiciousNode(ex.node, ex.reason, ex.code, ex.offendingMsg) | [
"def",
"reportSuspiciousNodeEx",
"(",
"self",
",",
"ex",
":",
"SuspiciousNode",
")",
":",
"self",
".",
"reportSuspiciousNode",
"(",
"ex",
".",
"node",
",",
"ex",
".",
"reason",
",",
"ex",
".",
"code",
",",
"ex",
".",
"offendingMsg",
")"
] | Report suspicion on a node on the basis of an exception | [
"Report",
"suspicion",
"on",
"a",
"node",
"on",
"the",
"basis",
"of",
"an",
"exception"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3492-L3496 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.reportSuspiciousNode | def reportSuspiciousNode(self,
nodeName: str,
reason=None,
code: int = None,
offendingMsg=None):
"""
Report suspicion on a node and add it to this node's blacklist.
:param nodeNam... | python | def reportSuspiciousNode(self,
nodeName: str,
reason=None,
code: int = None,
offendingMsg=None):
"""
Report suspicion on a node and add it to this node's blacklist.
:param nodeNam... | [
"def",
"reportSuspiciousNode",
"(",
"self",
",",
"nodeName",
":",
"str",
",",
"reason",
"=",
"None",
",",
"code",
":",
"int",
"=",
"None",
",",
"offendingMsg",
"=",
"None",
")",
":",
"logger",
".",
"warning",
"(",
"\"{} raised suspicion on node {} for {}; susp... | Report suspicion on a node and add it to this node's blacklist.
:param nodeName: name of the node to report suspicion on
:param reason: the reason for suspicion | [
"Report",
"suspicion",
"on",
"a",
"node",
"and",
"add",
"it",
"to",
"this",
"node",
"s",
"blacklist",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3498-L3543 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.reportSuspiciousClient | def reportSuspiciousClient(self, clientName: str, reason):
"""
Report suspicion on a client and add it to this node's blacklist.
:param clientName: name of the client to report suspicion on
:param reason: the reason for suspicion
"""
logger.warning("{} raised suspicion o... | python | def reportSuspiciousClient(self, clientName: str, reason):
"""
Report suspicion on a client and add it to this node's blacklist.
:param clientName: name of the client to report suspicion on
:param reason: the reason for suspicion
"""
logger.warning("{} raised suspicion o... | [
"def",
"reportSuspiciousClient",
"(",
"self",
",",
"clientName",
":",
"str",
",",
"reason",
")",
":",
"logger",
".",
"warning",
"(",
"\"{} raised suspicion on client {} for {}\"",
".",
"format",
"(",
"self",
",",
"clientName",
",",
"reason",
")",
")",
"self",
... | Report suspicion on a client and add it to this node's blacklist.
:param clientName: name of the client to report suspicion on
:param reason: the reason for suspicion | [
"Report",
"suspicion",
"on",
"a",
"client",
"and",
"add",
"it",
"to",
"this",
"node",
"s",
"blacklist",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3545-L3554 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.blacklistClient | def blacklistClient(self, clientName: str,
reason: str = None, code: int = None):
"""
Add the client specified by `clientName` to this node's blacklist
"""
msg = "{} blacklisting client {}".format(self, clientName)
if reason:
msg += " for reaso... | python | def blacklistClient(self, clientName: str,
reason: str = None, code: int = None):
"""
Add the client specified by `clientName` to this node's blacklist
"""
msg = "{} blacklisting client {}".format(self, clientName)
if reason:
msg += " for reaso... | [
"def",
"blacklistClient",
"(",
"self",
",",
"clientName",
":",
"str",
",",
"reason",
":",
"str",
"=",
"None",
",",
"code",
":",
"int",
"=",
"None",
")",
":",
"msg",
"=",
"\"{} blacklisting client {}\"",
".",
"format",
"(",
"self",
",",
"clientName",
")",... | Add the client specified by `clientName` to this node's blacklist | [
"Add",
"the",
"client",
"specified",
"by",
"clientName",
"to",
"this",
"node",
"s",
"blacklist"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3565-L3574 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.blacklistNode | def blacklistNode(self, nodeName: str, reason: str = None, code: int = None):
"""
Add the node specified by `nodeName` to this node's blacklist
"""
msg = "{} blacklisting node {}".format(self, nodeName)
if reason:
msg += " for reason {}".format(reason)
if code... | python | def blacklistNode(self, nodeName: str, reason: str = None, code: int = None):
"""
Add the node specified by `nodeName` to this node's blacklist
"""
msg = "{} blacklisting node {}".format(self, nodeName)
if reason:
msg += " for reason {}".format(reason)
if code... | [
"def",
"blacklistNode",
"(",
"self",
",",
"nodeName",
":",
"str",
",",
"reason",
":",
"str",
"=",
"None",
",",
"code",
":",
"int",
"=",
"None",
")",
":",
"msg",
"=",
"\"{} blacklisting node {}\"",
".",
"format",
"(",
"self",
",",
"nodeName",
")",
"if",... | Add the node specified by `nodeName` to this node's blacklist | [
"Add",
"the",
"node",
"specified",
"by",
"nodeName",
"to",
"this",
"node",
"s",
"blacklist"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3585-L3595 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.logstats | def logstats(self):
"""
Print the node's current statistics to log.
"""
lines = [
"node {} current stats".format(self),
"--------------------------------------------------------",
"node inbox size : {}".format(len(self.nodeInBox)),
... | python | def logstats(self):
"""
Print the node's current statistics to log.
"""
lines = [
"node {} current stats".format(self),
"--------------------------------------------------------",
"node inbox size : {}".format(len(self.nodeInBox)),
... | [
"def",
"logstats",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"\"node {} current stats\"",
".",
"format",
"(",
"self",
")",
",",
"\"--------------------------------------------------------\"",
",",
"\"node inbox size : {}\"",
".",
"format",
"(",
"len",
"(",
"se... | Print the node's current statistics to log. | [
"Print",
"the",
"node",
"s",
"current",
"statistics",
"to",
"log",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3685-L3711 | train |
hyperledger/indy-plenum | plenum/server/node.py | Node.logNodeInfo | def logNodeInfo(self):
"""
Print the node's info to log for the REST backend to read.
"""
self.nodeInfo['data'] = self.collectNodeInfo()
with closing(open(os.path.join(self.ledger_dir, 'node_info'), 'w')) \
as logNodeInfoFile:
logNodeInfoFile.write(js... | python | def logNodeInfo(self):
"""
Print the node's info to log for the REST backend to read.
"""
self.nodeInfo['data'] = self.collectNodeInfo()
with closing(open(os.path.join(self.ledger_dir, 'node_info'), 'w')) \
as logNodeInfoFile:
logNodeInfoFile.write(js... | [
"def",
"logNodeInfo",
"(",
"self",
")",
":",
"self",
".",
"nodeInfo",
"[",
"'data'",
"]",
"=",
"self",
".",
"collectNodeInfo",
"(",
")",
"with",
"closing",
"(",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"ledger_dir",
",",
"'node_... | Print the node's info to log for the REST backend to read. | [
"Print",
"the",
"node",
"s",
"info",
"to",
"log",
"for",
"the",
"REST",
"backend",
"to",
"read",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L3738-L3746 | train |
hyperledger/indy-plenum | plenum/common/perf_util.py | get_collection_sizes | def get_collection_sizes(obj, collections: Optional[Tuple]=None,
get_only_non_empty=False):
"""
Iterates over `collections` of the gives object and gives its byte size
and number of items in collection
"""
from pympler import asizeof
collections = collections or (list, d... | python | def get_collection_sizes(obj, collections: Optional[Tuple]=None,
get_only_non_empty=False):
"""
Iterates over `collections` of the gives object and gives its byte size
and number of items in collection
"""
from pympler import asizeof
collections = collections or (list, d... | [
"def",
"get_collection_sizes",
"(",
"obj",
",",
"collections",
":",
"Optional",
"[",
"Tuple",
"]",
"=",
"None",
",",
"get_only_non_empty",
"=",
"False",
")",
":",
"from",
"pympler",
"import",
"asizeof",
"collections",
"=",
"collections",
"or",
"(",
"list",
"... | Iterates over `collections` of the gives object and gives its byte size
and number of items in collection | [
"Iterates",
"over",
"collections",
"of",
"the",
"gives",
"object",
"and",
"gives",
"its",
"byte",
"size",
"and",
"number",
"of",
"items",
"in",
"collection"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/perf_util.py#L52-L70 | train |
hyperledger/indy-plenum | ledger/error.py | returns_true_or_raises | def returns_true_or_raises(f):
"""A safety net.
Decorator for functions that are only allowed to return True or raise
an exception.
Args:
f: A function whose only expected return value is True.
Returns:
A wrapped functions whose guaranteed only return value is True.
"""
@f... | python | def returns_true_or_raises(f):
"""A safety net.
Decorator for functions that are only allowed to return True or raise
an exception.
Args:
f: A function whose only expected return value is True.
Returns:
A wrapped functions whose guaranteed only return value is True.
"""
@f... | [
"def",
"returns_true_or_raises",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"ret",
"=",
"f",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"ret",
"is",... | A safety net.
Decorator for functions that are only allowed to return True or raise
an exception.
Args:
f: A function whose only expected return value is True.
Returns:
A wrapped functions whose guaranteed only return value is True. | [
"A",
"safety",
"net",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/error.py#L126-L144 | train |
hyperledger/indy-plenum | plenum/server/instances.py | Instances.backupIds | def backupIds(self) -> Sequence[int]:
"""
Return the list of replicas that don't belong to the master protocol
instance
"""
return [id for id in self.started.keys() if id != 0] | python | def backupIds(self) -> Sequence[int]:
"""
Return the list of replicas that don't belong to the master protocol
instance
"""
return [id for id in self.started.keys() if id != 0] | [
"def",
"backupIds",
"(",
"self",
")",
"->",
"Sequence",
"[",
"int",
"]",
":",
"return",
"[",
"id",
"for",
"id",
"in",
"self",
".",
"started",
".",
"keys",
"(",
")",
"if",
"id",
"!=",
"0",
"]"
] | Return the list of replicas that don't belong to the master protocol
instance | [
"Return",
"the",
"list",
"of",
"replicas",
"that",
"don",
"t",
"belong",
"to",
"the",
"master",
"protocol",
"instance"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/instances.py#L37-L42 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger._hasViewChangeQuorum | def _hasViewChangeQuorum(self):
# This method should just be present for master instance.
"""
Checks whether n-f nodes completed view change and whether one
of them is the next primary
"""
num_of_ready_nodes = len(self._view_change_done)
diff = self.quorum - num_o... | python | def _hasViewChangeQuorum(self):
# This method should just be present for master instance.
"""
Checks whether n-f nodes completed view change and whether one
of them is the next primary
"""
num_of_ready_nodes = len(self._view_change_done)
diff = self.quorum - num_o... | [
"def",
"_hasViewChangeQuorum",
"(",
"self",
")",
":",
"num_of_ready_nodes",
"=",
"len",
"(",
"self",
".",
"_view_change_done",
")",
"diff",
"=",
"self",
".",
"quorum",
"-",
"num_of_ready_nodes",
"if",
"diff",
">",
"0",
":",
"logger",
".",
"info",
"(",
"'{}... | Checks whether n-f nodes completed view change and whether one
of them is the next primary | [
"Checks",
"whether",
"n",
"-",
"f",
"nodes",
"completed",
"view",
"change",
"and",
"whether",
"one",
"of",
"them",
"is",
"the",
"next",
"primary"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L234-L248 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger.process_instance_change_msg | def process_instance_change_msg(self, instChg: InstanceChange, frm: str) -> None:
"""
Validate and process an instance change request.
:param instChg: the instance change request
:param frm: the name of the node that sent this `msg`
"""
if frm not in self.provider.connec... | python | def process_instance_change_msg(self, instChg: InstanceChange, frm: str) -> None:
"""
Validate and process an instance change request.
:param instChg: the instance change request
:param frm: the name of the node that sent this `msg`
"""
if frm not in self.provider.connec... | [
"def",
"process_instance_change_msg",
"(",
"self",
",",
"instChg",
":",
"InstanceChange",
",",
"frm",
":",
"str",
")",
"->",
"None",
":",
"if",
"frm",
"not",
"in",
"self",
".",
"provider",
".",
"connected_nodes",
"(",
")",
":",
"self",
".",
"provider",
"... | Validate and process an instance change request.
:param instChg: the instance change request
:param frm: the name of the node that sent this `msg` | [
"Validate",
"and",
"process",
"an",
"instance",
"change",
"request",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L373-L416 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger.process_vchd_msg | def process_vchd_msg(self, msg: ViewChangeDone, sender: str) -> bool:
"""
Processes ViewChangeDone messages. Once n-f messages have been
received, decides on a primary for specific replica.
:param msg: ViewChangeDone message
:param sender: the name of the node from which this me... | python | def process_vchd_msg(self, msg: ViewChangeDone, sender: str) -> bool:
"""
Processes ViewChangeDone messages. Once n-f messages have been
received, decides on a primary for specific replica.
:param msg: ViewChangeDone message
:param sender: the name of the node from which this me... | [
"def",
"process_vchd_msg",
"(",
"self",
",",
"msg",
":",
"ViewChangeDone",
",",
"sender",
":",
"str",
")",
"->",
"bool",
":",
"logger",
".",
"info",
"(",
"\"{}'s primary selector started processing of ViewChangeDone msg from {} : {}\"",
".",
"format",
"(",
"self",
"... | Processes ViewChangeDone messages. Once n-f messages have been
received, decides on a primary for specific replica.
:param msg: ViewChangeDone message
:param sender: the name of the node from which this message was sent | [
"Processes",
"ViewChangeDone",
"messages",
".",
"Once",
"n",
"-",
"f",
"messages",
"have",
"been",
"received",
"decides",
"on",
"a",
"primary",
"for",
"specific",
"replica",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L418-L452 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger.sendInstanceChange | def sendInstanceChange(self, view_no: int,
suspicion=Suspicions.PRIMARY_DEGRADED):
"""
Broadcast an instance change request to all the remaining nodes
:param view_no: the view number when the instance change is requested
"""
# If not found any sent in... | python | def sendInstanceChange(self, view_no: int,
suspicion=Suspicions.PRIMARY_DEGRADED):
"""
Broadcast an instance change request to all the remaining nodes
:param view_no: the view number when the instance change is requested
"""
# If not found any sent in... | [
"def",
"sendInstanceChange",
"(",
"self",
",",
"view_no",
":",
"int",
",",
"suspicion",
"=",
"Suspicions",
".",
"PRIMARY_DEGRADED",
")",
":",
"canSendInsChange",
",",
"cooldown",
"=",
"self",
".",
"insChngThrottler",
".",
"acquire",
"(",
")",
"if",
"canSendIns... | Broadcast an instance change request to all the remaining nodes
:param view_no: the view number when the instance change is requested | [
"Broadcast",
"an",
"instance",
"change",
"request",
"to",
"all",
"the",
"remaining",
"nodes"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L475-L505 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger._canViewChange | def _canViewChange(self, proposedViewNo: int) -> (bool, str):
"""
Return whether there's quorum for view change for the proposed view
number and its view is less than or equal to the proposed view
"""
msg = None
quorum = self.quorums.view_change.value
if not self.... | python | def _canViewChange(self, proposedViewNo: int) -> (bool, str):
"""
Return whether there's quorum for view change for the proposed view
number and its view is less than or equal to the proposed view
"""
msg = None
quorum = self.quorums.view_change.value
if not self.... | [
"def",
"_canViewChange",
"(",
"self",
",",
"proposedViewNo",
":",
"int",
")",
"->",
"(",
"bool",
",",
"str",
")",
":",
"msg",
"=",
"None",
"quorum",
"=",
"self",
".",
"quorums",
".",
"view_change",
".",
"value",
"if",
"not",
"self",
".",
"instance_chan... | Return whether there's quorum for view change for the proposed view
number and its view is less than or equal to the proposed view | [
"Return",
"whether",
"there",
"s",
"quorum",
"for",
"view",
"change",
"for",
"the",
"proposed",
"view",
"number",
"and",
"its",
"view",
"is",
"less",
"than",
"or",
"equal",
"to",
"the",
"proposed",
"view"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L548-L561 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger.start_view_change | def start_view_change(self, proposed_view_no: int, continue_vc=False):
"""
Trigger the view change process.
:param proposed_view_no: the new view number after view change.
"""
# TODO: consider moving this to pool manager
# TODO: view change is a special case, which can h... | python | def start_view_change(self, proposed_view_no: int, continue_vc=False):
"""
Trigger the view change process.
:param proposed_view_no: the new view number after view change.
"""
# TODO: consider moving this to pool manager
# TODO: view change is a special case, which can h... | [
"def",
"start_view_change",
"(",
"self",
",",
"proposed_view_no",
":",
"int",
",",
"continue_vc",
"=",
"False",
")",
":",
"if",
"self",
".",
"pre_vc_strategy",
"and",
"(",
"not",
"continue_vc",
")",
":",
"self",
".",
"pre_view_change_in_progress",
"=",
"True",... | Trigger the view change process.
:param proposed_view_no: the new view number after view change. | [
"Trigger",
"the",
"view",
"change",
"process",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L563-L591 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger._verify_primary | def _verify_primary(self, new_primary, ledger_info):
"""
This method is called when sufficient number of ViewChangeDone
received and makes steps to switch to the new primary
"""
expected_primary = self.provider.next_primary_name()
if new_primary != expected_primary:
... | python | def _verify_primary(self, new_primary, ledger_info):
"""
This method is called when sufficient number of ViewChangeDone
received and makes steps to switch to the new primary
"""
expected_primary = self.provider.next_primary_name()
if new_primary != expected_primary:
... | [
"def",
"_verify_primary",
"(",
"self",
",",
"new_primary",
",",
"ledger_info",
")",
":",
"expected_primary",
"=",
"self",
".",
"provider",
".",
"next_primary_name",
"(",
")",
"if",
"new_primary",
"!=",
"expected_primary",
":",
"logger",
".",
"error",
"(",
"\"{... | This method is called when sufficient number of ViewChangeDone
received and makes steps to switch to the new primary | [
"This",
"method",
"is",
"called",
"when",
"sufficient",
"number",
"of",
"ViewChangeDone",
"received",
"and",
"makes",
"steps",
"to",
"switch",
"to",
"the",
"new",
"primary"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L691-L705 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger._send_view_change_done_message | def _send_view_change_done_message(self):
"""
Sends ViewChangeDone message to other protocol participants
"""
new_primary_name = self.provider.next_primary_name()
ledger_summary = self.provider.ledger_summary()
message = ViewChangeDone(self.view_no,
... | python | def _send_view_change_done_message(self):
"""
Sends ViewChangeDone message to other protocol participants
"""
new_primary_name = self.provider.next_primary_name()
ledger_summary = self.provider.ledger_summary()
message = ViewChangeDone(self.view_no,
... | [
"def",
"_send_view_change_done_message",
"(",
"self",
")",
":",
"new_primary_name",
"=",
"self",
".",
"provider",
".",
"next_primary_name",
"(",
")",
"ledger_summary",
"=",
"self",
".",
"provider",
".",
"ledger_summary",
"(",
")",
"message",
"=",
"ViewChangeDone",... | Sends ViewChangeDone message to other protocol participants | [
"Sends",
"ViewChangeDone",
"message",
"to",
"other",
"protocol",
"participants"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L708-L721 | train |
hyperledger/indy-plenum | plenum/server/view_change/view_changer.py | ViewChanger.get_msgs_for_lagged_nodes | def get_msgs_for_lagged_nodes(self) -> List[ViewChangeDone]:
# Should not return a list, only done for compatibility with interface
"""
Returns the last accepted `ViewChangeDone` message.
If no view change has happened returns ViewChangeDone
with view no 0 to a newly joined node
... | python | def get_msgs_for_lagged_nodes(self) -> List[ViewChangeDone]:
# Should not return a list, only done for compatibility with interface
"""
Returns the last accepted `ViewChangeDone` message.
If no view change has happened returns ViewChangeDone
with view no 0 to a newly joined node
... | [
"def",
"get_msgs_for_lagged_nodes",
"(",
"self",
")",
"->",
"List",
"[",
"ViewChangeDone",
"]",
":",
"messages",
"=",
"[",
"]",
"accepted",
"=",
"self",
".",
"_accepted_view_change_done_message",
"if",
"accepted",
":",
"messages",
".",
"append",
"(",
"ViewChange... | Returns the last accepted `ViewChangeDone` message.
If no view change has happened returns ViewChangeDone
with view no 0 to a newly joined node | [
"Returns",
"the",
"last",
"accepted",
"ViewChangeDone",
"message",
".",
"If",
"no",
"view",
"change",
"has",
"happened",
"returns",
"ViewChangeDone",
"with",
"view",
"no",
"0",
"to",
"a",
"newly",
"joined",
"node"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/view_change/view_changer.py#L724-L744 | train |
hyperledger/indy-plenum | plenum/common/messages/fields.py | FieldBase.validate | def validate(self, val):
"""
Performs basic validation of field value and then passes it for
specific validation.
:param val: field value to validate
:return: error message or None
"""
if self.nullable and val is None:
return
type_er = self._... | python | def validate(self, val):
"""
Performs basic validation of field value and then passes it for
specific validation.
:param val: field value to validate
:return: error message or None
"""
if self.nullable and val is None:
return
type_er = self._... | [
"def",
"validate",
"(",
"self",
",",
"val",
")",
":",
"if",
"self",
".",
"nullable",
"and",
"val",
"is",
"None",
":",
"return",
"type_er",
"=",
"self",
".",
"__type_check",
"(",
"val",
")",
"if",
"type_er",
":",
"return",
"type_er",
"spec_err",
"=",
... | Performs basic validation of field value and then passes it for
specific validation.
:param val: field value to validate
:return: error message or None | [
"Performs",
"basic",
"validation",
"of",
"field",
"value",
"and",
"then",
"passes",
"it",
"for",
"specific",
"validation",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/messages/fields.py#L51-L68 | train |
hyperledger/indy-plenum | plenum/common/signer_did.py | DidSigner.sign | def sign(self, msg: Dict) -> Dict:
"""
Return a signature for the given message.
"""
ser = serialize_msg_for_signing(msg, topLevelKeysToIgnore=[f.SIG.nm])
bsig = self.naclSigner.signature(ser)
sig = base58.b58encode(bsig).decode("utf-8")
return sig | python | def sign(self, msg: Dict) -> Dict:
"""
Return a signature for the given message.
"""
ser = serialize_msg_for_signing(msg, topLevelKeysToIgnore=[f.SIG.nm])
bsig = self.naclSigner.signature(ser)
sig = base58.b58encode(bsig).decode("utf-8")
return sig | [
"def",
"sign",
"(",
"self",
",",
"msg",
":",
"Dict",
")",
"->",
"Dict",
":",
"ser",
"=",
"serialize_msg_for_signing",
"(",
"msg",
",",
"topLevelKeysToIgnore",
"=",
"[",
"f",
".",
"SIG",
".",
"nm",
"]",
")",
"bsig",
"=",
"self",
".",
"naclSigner",
"."... | Return a signature for the given message. | [
"Return",
"a",
"signature",
"for",
"the",
"given",
"message",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/signer_did.py#L122-L129 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.lastPrePrepareSeqNo | def lastPrePrepareSeqNo(self, n):
"""
This will _lastPrePrepareSeqNo to values greater than its previous
values else it will not. To forcefully override as in case of `revert`,
directly set `self._lastPrePrepareSeqNo`
"""
if n > self._lastPrePrepareSeqNo:
self... | python | def lastPrePrepareSeqNo(self, n):
"""
This will _lastPrePrepareSeqNo to values greater than its previous
values else it will not. To forcefully override as in case of `revert`,
directly set `self._lastPrePrepareSeqNo`
"""
if n > self._lastPrePrepareSeqNo:
self... | [
"def",
"lastPrePrepareSeqNo",
"(",
"self",
",",
"n",
")",
":",
"if",
"n",
">",
"self",
".",
"_lastPrePrepareSeqNo",
":",
"self",
".",
"_lastPrePrepareSeqNo",
"=",
"n",
"else",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'{} cannot set lastPrePrepareSeqNo t... | This will _lastPrePrepareSeqNo to values greater than its previous
values else it will not. To forcefully override as in case of `revert`,
directly set `self._lastPrePrepareSeqNo` | [
"This",
"will",
"_lastPrePrepareSeqNo",
"to",
"values",
"greater",
"than",
"its",
"previous",
"values",
"else",
"it",
"will",
"not",
".",
"To",
"forcefully",
"override",
"as",
"in",
"case",
"of",
"revert",
"directly",
"set",
"self",
".",
"_lastPrePrepareSeqNo"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L515-L527 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.primaryName | def primaryName(self, value: Optional[str]) -> None:
"""
Set the value of isPrimary.
:param value: the value to set isPrimary to
"""
if value is not None:
self.warned_no_primary = False
self.primaryNames[self.viewNo] = value
self.compact_primary_names... | python | def primaryName(self, value: Optional[str]) -> None:
"""
Set the value of isPrimary.
:param value: the value to set isPrimary to
"""
if value is not None:
self.warned_no_primary = False
self.primaryNames[self.viewNo] = value
self.compact_primary_names... | [
"def",
"primaryName",
"(",
"self",
",",
"value",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"None",
":",
"if",
"value",
"is",
"not",
"None",
":",
"self",
".",
"warned_no_primary",
"=",
"False",
"self",
".",
"primaryNames",
"[",
"self",
".",
"viewNo",... | Set the value of isPrimary.
:param value: the value to set isPrimary to | [
"Set",
"the",
"value",
"of",
"isPrimary",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L598-L618 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.get_lowest_probable_prepared_certificate_in_view | def get_lowest_probable_prepared_certificate_in_view(
self, view_no) -> Optional[int]:
"""
Return lowest pp_seq_no of the view for which can be prepared but
choose from unprocessed PRE-PREPAREs and PREPAREs.
"""
# TODO: Naive implementation, dont need to iterate over ... | python | def get_lowest_probable_prepared_certificate_in_view(
self, view_no) -> Optional[int]:
"""
Return lowest pp_seq_no of the view for which can be prepared but
choose from unprocessed PRE-PREPAREs and PREPAREs.
"""
# TODO: Naive implementation, dont need to iterate over ... | [
"def",
"get_lowest_probable_prepared_certificate_in_view",
"(",
"self",
",",
"view_no",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"seq_no_pp",
"=",
"SortedList",
"(",
")",
"seq_no_p",
"=",
"set",
"(",
")",
"for",
"(",
"v",
",",
"p",
")",
"in",
"self",
... | Return lowest pp_seq_no of the view for which can be prepared but
choose from unprocessed PRE-PREPAREs and PREPAREs. | [
"Return",
"lowest",
"pp_seq_no",
"of",
"the",
"view",
"for",
"which",
"can",
"be",
"prepared",
"but",
"choose",
"from",
"unprocessed",
"PRE",
"-",
"PREPAREs",
"and",
"PREPAREs",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L692-L717 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.is_primary_in_view | def is_primary_in_view(self, viewNo: int) -> Optional[bool]:
"""
Return whether this replica was primary in the given view
"""
if viewNo not in self.primaryNames:
return False
return self.primaryNames[viewNo] == self.name | python | def is_primary_in_view(self, viewNo: int) -> Optional[bool]:
"""
Return whether this replica was primary in the given view
"""
if viewNo not in self.primaryNames:
return False
return self.primaryNames[viewNo] == self.name | [
"def",
"is_primary_in_view",
"(",
"self",
",",
"viewNo",
":",
"int",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"if",
"viewNo",
"not",
"in",
"self",
".",
"primaryNames",
":",
"return",
"False",
"return",
"self",
".",
"primaryNames",
"[",
"viewNo",
"]"... | Return whether this replica was primary in the given view | [
"Return",
"whether",
"this",
"replica",
"was",
"primary",
"in",
"the",
"given",
"view"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L747-L753 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.processReqDuringBatch | def processReqDuringBatch(
self,
req: Request,
cons_time: int):
"""
This method will do dynamic validation and apply requests.
If there is any errors during validation it would be raised
"""
if self.isMaster:
self.node.doDynamicVali... | python | def processReqDuringBatch(
self,
req: Request,
cons_time: int):
"""
This method will do dynamic validation and apply requests.
If there is any errors during validation it would be raised
"""
if self.isMaster:
self.node.doDynamicVali... | [
"def",
"processReqDuringBatch",
"(",
"self",
",",
"req",
":",
"Request",
",",
"cons_time",
":",
"int",
")",
":",
"if",
"self",
".",
"isMaster",
":",
"self",
".",
"node",
".",
"doDynamicValidation",
"(",
"req",
")",
"self",
".",
"node",
".",
"applyReq",
... | This method will do dynamic validation and apply requests.
If there is any errors during validation it would be raised | [
"This",
"method",
"will",
"do",
"dynamic",
"validation",
"and",
"apply",
"requests",
".",
"If",
"there",
"is",
"any",
"errors",
"during",
"validation",
"it",
"would",
"be",
"raised"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L902-L912 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.serviceQueues | def serviceQueues(self, limit=None):
"""
Process `limit` number of messages in the inBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed
"""
# TODO should handle SuspiciousNode here
r = self.dequeue_... | python | def serviceQueues(self, limit=None):
"""
Process `limit` number of messages in the inBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed
"""
# TODO should handle SuspiciousNode here
r = self.dequeue_... | [
"def",
"serviceQueues",
"(",
"self",
",",
"limit",
"=",
"None",
")",
":",
"r",
"=",
"self",
".",
"dequeue_pre_prepares",
"(",
")",
"r",
"+=",
"self",
".",
"inBoxRouter",
".",
"handleAllSync",
"(",
"self",
".",
"inBox",
",",
"limit",
")",
"r",
"+=",
"... | Process `limit` number of messages in the inBox.
:param limit: the maximum number of messages to process
:return: the number of messages successfully processed | [
"Process",
"limit",
"number",
"of",
"messages",
"in",
"the",
"inBox",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1043-L1055 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.tryPrepare | def tryPrepare(self, pp: PrePrepare):
"""
Try to send the Prepare message if the PrePrepare message is ready to
be passed into the Prepare phase.
"""
rv, msg = self.canPrepare(pp)
if rv:
self.doPrepare(pp)
else:
self.logger.debug("{} cannot... | python | def tryPrepare(self, pp: PrePrepare):
"""
Try to send the Prepare message if the PrePrepare message is ready to
be passed into the Prepare phase.
"""
rv, msg = self.canPrepare(pp)
if rv:
self.doPrepare(pp)
else:
self.logger.debug("{} cannot... | [
"def",
"tryPrepare",
"(",
"self",
",",
"pp",
":",
"PrePrepare",
")",
":",
"rv",
",",
"msg",
"=",
"self",
".",
"canPrepare",
"(",
"pp",
")",
"if",
"rv",
":",
"self",
".",
"doPrepare",
"(",
"pp",
")",
"else",
":",
"self",
".",
"logger",
".",
"debug... | Try to send the Prepare message if the PrePrepare message is ready to
be passed into the Prepare phase. | [
"Try",
"to",
"send",
"the",
"Prepare",
"message",
"if",
"the",
"PrePrepare",
"message",
"is",
"ready",
"to",
"be",
"passed",
"into",
"the",
"Prepare",
"phase",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1293-L1302 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.processPrepare | def processPrepare(self, prepare: Prepare, sender: str) -> None:
"""
Validate and process the PREPARE specified.
If validation is successful, create a COMMIT and broadcast it.
:param prepare: a PREPARE msg
:param sender: name of the node that sent the PREPARE
"""
... | python | def processPrepare(self, prepare: Prepare, sender: str) -> None:
"""
Validate and process the PREPARE specified.
If validation is successful, create a COMMIT and broadcast it.
:param prepare: a PREPARE msg
:param sender: name of the node that sent the PREPARE
"""
... | [
"def",
"processPrepare",
"(",
"self",
",",
"prepare",
":",
"Prepare",
",",
"sender",
":",
"str",
")",
"->",
"None",
":",
"key",
"=",
"(",
"prepare",
".",
"viewNo",
",",
"prepare",
".",
"ppSeqNo",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"{} r... | Validate and process the PREPARE specified.
If validation is successful, create a COMMIT and broadcast it.
:param prepare: a PREPARE msg
:param sender: name of the node that sent the PREPARE | [
"Validate",
"and",
"process",
"the",
"PREPARE",
"specified",
".",
"If",
"validation",
"is",
"successful",
"create",
"a",
"COMMIT",
"and",
"broadcast",
"it",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1306-L1329 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.processCommit | def processCommit(self, commit: Commit, sender: str) -> None:
"""
Validate and process the COMMIT specified.
If validation is successful, return the message to the node.
:param commit: an incoming COMMIT message
:param sender: name of the node that sent the COMMIT
"""
... | python | def processCommit(self, commit: Commit, sender: str) -> None:
"""
Validate and process the COMMIT specified.
If validation is successful, return the message to the node.
:param commit: an incoming COMMIT message
:param sender: name of the node that sent the COMMIT
"""
... | [
"def",
"processCommit",
"(",
"self",
",",
"commit",
":",
"Commit",
",",
"sender",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"{} received COMMIT{} from {}\"",
".",
"format",
"(",
"self",
",",
"(",
"commit",
".",
"view... | Validate and process the COMMIT specified.
If validation is successful, return the message to the node.
:param commit: an incoming COMMIT message
:param sender: name of the node that sent the COMMIT | [
"Validate",
"and",
"process",
"the",
"COMMIT",
"specified",
".",
"If",
"validation",
"is",
"successful",
"return",
"the",
"message",
"to",
"the",
"node",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1333-L1348 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.tryCommit | def tryCommit(self, prepare: Prepare):
"""
Try to commit if the Prepare message is ready to be passed into the
commit phase.
"""
rv, reason = self.canCommit(prepare)
if rv:
self.doCommit(prepare)
else:
self.logger.debug("{} cannot send COMM... | python | def tryCommit(self, prepare: Prepare):
"""
Try to commit if the Prepare message is ready to be passed into the
commit phase.
"""
rv, reason = self.canCommit(prepare)
if rv:
self.doCommit(prepare)
else:
self.logger.debug("{} cannot send COMM... | [
"def",
"tryCommit",
"(",
"self",
",",
"prepare",
":",
"Prepare",
")",
":",
"rv",
",",
"reason",
"=",
"self",
".",
"canCommit",
"(",
"prepare",
")",
"if",
"rv",
":",
"self",
".",
"doCommit",
"(",
"prepare",
")",
"else",
":",
"self",
".",
"logger",
"... | Try to commit if the Prepare message is ready to be passed into the
commit phase. | [
"Try",
"to",
"commit",
"if",
"the",
"Prepare",
"message",
"is",
"ready",
"to",
"be",
"passed",
"into",
"the",
"commit",
"phase",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1350-L1359 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.tryOrder | def tryOrder(self, commit: Commit):
"""
Try to order if the Commit message is ready to be ordered.
"""
canOrder, reason = self.canOrder(commit)
if canOrder:
self.logger.trace("{} returning request to node".format(self))
self.doOrder(commit)
else:
... | python | def tryOrder(self, commit: Commit):
"""
Try to order if the Commit message is ready to be ordered.
"""
canOrder, reason = self.canOrder(commit)
if canOrder:
self.logger.trace("{} returning request to node".format(self))
self.doOrder(commit)
else:
... | [
"def",
"tryOrder",
"(",
"self",
",",
"commit",
":",
"Commit",
")",
":",
"canOrder",
",",
"reason",
"=",
"self",
".",
"canOrder",
"(",
"commit",
")",
"if",
"canOrder",
":",
"self",
".",
"logger",
".",
"trace",
"(",
"\"{} returning request to node\"",
".",
... | Try to order if the Commit message is ready to be ordered. | [
"Try",
"to",
"order",
"if",
"the",
"Commit",
"message",
"is",
"ready",
"to",
"be",
"ordered",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1361-L1371 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.nonFinalisedReqs | def nonFinalisedReqs(self, reqKeys: List[Tuple[str, int]]):
"""
Check if there are any requests which are not finalised, i.e for
which there are not enough PROPAGATEs
"""
return {key for key in reqKeys if not self.requests.is_finalised(key)} | python | def nonFinalisedReqs(self, reqKeys: List[Tuple[str, int]]):
"""
Check if there are any requests which are not finalised, i.e for
which there are not enough PROPAGATEs
"""
return {key for key in reqKeys if not self.requests.is_finalised(key)} | [
"def",
"nonFinalisedReqs",
"(",
"self",
",",
"reqKeys",
":",
"List",
"[",
"Tuple",
"[",
"str",
",",
"int",
"]",
"]",
")",
":",
"return",
"{",
"key",
"for",
"key",
"in",
"reqKeys",
"if",
"not",
"self",
".",
"requests",
".",
"is_finalised",
"(",
"key",... | Check if there are any requests which are not finalised, i.e for
which there are not enough PROPAGATEs | [
"Check",
"if",
"there",
"are",
"any",
"requests",
"which",
"are",
"not",
"finalised",
"i",
".",
"e",
"for",
"which",
"there",
"are",
"not",
"enough",
"PROPAGATEs"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1428-L1433 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica._can_process_pre_prepare | def _can_process_pre_prepare(self, pre_prepare: PrePrepare, sender: str) -> Optional[int]:
"""
Decide whether this replica is eligible to process a PRE-PREPARE.
:param pre_prepare: a PRE-PREPARE msg to process
:param sender: the name of the node that sent the PRE-PREPARE msg
"""... | python | def _can_process_pre_prepare(self, pre_prepare: PrePrepare, sender: str) -> Optional[int]:
"""
Decide whether this replica is eligible to process a PRE-PREPARE.
:param pre_prepare: a PRE-PREPARE msg to process
:param sender: the name of the node that sent the PRE-PREPARE msg
"""... | [
"def",
"_can_process_pre_prepare",
"(",
"self",
",",
"pre_prepare",
":",
"PrePrepare",
",",
"sender",
":",
"str",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"not",
"self",
".",
"isMsgFromPrimary",
"(",
"pre_prepare",
",",
"sender",
")",
":",
"retur... | Decide whether this replica is eligible to process a PRE-PREPARE.
:param pre_prepare: a PRE-PREPARE msg to process
:param sender: the name of the node that sent the PRE-PREPARE msg | [
"Decide",
"whether",
"this",
"replica",
"is",
"eligible",
"to",
"process",
"a",
"PRE",
"-",
"PREPARE",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1539-L1579 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.addToPrePrepares | def addToPrePrepares(self, pp: PrePrepare) -> None:
"""
Add the specified PRE-PREPARE to this replica's list of received
PRE-PREPAREs and try sending PREPARE
:param pp: the PRE-PREPARE to add to the list
"""
key = (pp.viewNo, pp.ppSeqNo)
self.prePrepares[key] = p... | python | def addToPrePrepares(self, pp: PrePrepare) -> None:
"""
Add the specified PRE-PREPARE to this replica's list of received
PRE-PREPAREs and try sending PREPARE
:param pp: the PRE-PREPARE to add to the list
"""
key = (pp.viewNo, pp.ppSeqNo)
self.prePrepares[key] = p... | [
"def",
"addToPrePrepares",
"(",
"self",
",",
"pp",
":",
"PrePrepare",
")",
"->",
"None",
":",
"key",
"=",
"(",
"pp",
".",
"viewNo",
",",
"pp",
".",
"ppSeqNo",
")",
"self",
".",
"prePrepares",
"[",
"key",
"]",
"=",
"pp",
"self",
".",
"lastPrePrepareSe... | Add the specified PRE-PREPARE to this replica's list of received
PRE-PREPAREs and try sending PREPARE
:param pp: the PRE-PREPARE to add to the list | [
"Add",
"the",
"specified",
"PRE",
"-",
"PREPARE",
"to",
"this",
"replica",
"s",
"list",
"of",
"received",
"PRE",
"-",
"PREPAREs",
"and",
"try",
"sending",
"PREPARE"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1581-L1595 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.canPrepare | def canPrepare(self, ppReq) -> (bool, str):
"""
Return whether the batch of requests in the PRE-PREPARE can
proceed to the PREPARE step.
:param ppReq: any object with identifier and requestId attributes
"""
if self.has_sent_prepare(ppReq):
return False, 'has ... | python | def canPrepare(self, ppReq) -> (bool, str):
"""
Return whether the batch of requests in the PRE-PREPARE can
proceed to the PREPARE step.
:param ppReq: any object with identifier and requestId attributes
"""
if self.has_sent_prepare(ppReq):
return False, 'has ... | [
"def",
"canPrepare",
"(",
"self",
",",
"ppReq",
")",
"->",
"(",
"bool",
",",
"str",
")",
":",
"if",
"self",
".",
"has_sent_prepare",
"(",
"ppReq",
")",
":",
"return",
"False",
",",
"'has already sent PREPARE for {}'",
".",
"format",
"(",
"ppReq",
")",
"r... | Return whether the batch of requests in the PRE-PREPARE can
proceed to the PREPARE step.
:param ppReq: any object with identifier and requestId attributes | [
"Return",
"whether",
"the",
"batch",
"of",
"requests",
"in",
"the",
"PRE",
"-",
"PREPARE",
"can",
"proceed",
"to",
"the",
"PREPARE",
"step",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1600-L1609 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.validatePrepare | def validatePrepare(self, prepare: Prepare, sender: str) -> bool:
"""
Return whether the PREPARE specified is valid.
:param prepare: the PREPARE to validate
:param sender: the name of the node that sent the PREPARE
:return: True if PREPARE is valid, False otherwise
"""
... | python | def validatePrepare(self, prepare: Prepare, sender: str) -> bool:
"""
Return whether the PREPARE specified is valid.
:param prepare: the PREPARE to validate
:param sender: the name of the node that sent the PREPARE
:return: True if PREPARE is valid, False otherwise
"""
... | [
"def",
"validatePrepare",
"(",
"self",
",",
"prepare",
":",
"Prepare",
",",
"sender",
":",
"str",
")",
"->",
"bool",
":",
"key",
"=",
"(",
"prepare",
".",
"viewNo",
",",
"prepare",
".",
"ppSeqNo",
")",
"primaryStatus",
"=",
"self",
".",
"isPrimaryForMsg"... | Return whether the PREPARE specified is valid.
:param prepare: the PREPARE to validate
:param sender: the name of the node that sent the PREPARE
:return: True if PREPARE is valid, False otherwise | [
"Return",
"whether",
"the",
"PREPARE",
"specified",
"is",
"valid",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1611-L1682 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.addToPrepares | def addToPrepares(self, prepare: Prepare, sender: str):
"""
Add the specified PREPARE to this replica's list of received
PREPAREs and try sending COMMIT
:param prepare: the PREPARE to add to the list
"""
# BLS multi-sig:
self._bls_bft_replica.process_prepare(prep... | python | def addToPrepares(self, prepare: Prepare, sender: str):
"""
Add the specified PREPARE to this replica's list of received
PREPAREs and try sending COMMIT
:param prepare: the PREPARE to add to the list
"""
# BLS multi-sig:
self._bls_bft_replica.process_prepare(prep... | [
"def",
"addToPrepares",
"(",
"self",
",",
"prepare",
":",
"Prepare",
",",
"sender",
":",
"str",
")",
":",
"self",
".",
"_bls_bft_replica",
".",
"process_prepare",
"(",
"prepare",
",",
"sender",
")",
"self",
".",
"prepares",
".",
"addVote",
"(",
"prepare",
... | Add the specified PREPARE to this replica's list of received
PREPAREs and try sending COMMIT
:param prepare: the PREPARE to add to the list | [
"Add",
"the",
"specified",
"PREPARE",
"to",
"this",
"replica",
"s",
"list",
"of",
"received",
"PREPAREs",
"and",
"try",
"sending",
"COMMIT"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1684-L1696 | train |
hyperledger/indy-plenum | plenum/server/replica.py | Replica.canCommit | def canCommit(self, prepare: Prepare) -> (bool, str):
"""
Return whether the specified PREPARE can proceed to the Commit
step.
Decision criteria:
- If this replica has got just n-f-1 PREPARE requests then commit request.
- If less than n-f-1 PREPARE requests then probab... | python | def canCommit(self, prepare: Prepare) -> (bool, str):
"""
Return whether the specified PREPARE can proceed to the Commit
step.
Decision criteria:
- If this replica has got just n-f-1 PREPARE requests then commit request.
- If less than n-f-1 PREPARE requests then probab... | [
"def",
"canCommit",
"(",
"self",
",",
"prepare",
":",
"Prepare",
")",
"->",
"(",
"bool",
",",
"str",
")",
":",
"quorum",
"=",
"self",
".",
"quorums",
".",
"prepare",
".",
"value",
"if",
"not",
"self",
".",
"prepares",
".",
"hasQuorum",
"(",
"prepare"... | Return whether the specified PREPARE can proceed to the Commit
step.
Decision criteria:
- If this replica has got just n-f-1 PREPARE requests then commit request.
- If less than n-f-1 PREPARE requests then probably there's no consensus on
the request; don't commit
-... | [
"Return",
"whether",
"the",
"specified",
"PREPARE",
"can",
"proceed",
"to",
"the",
"Commit",
"step",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica.py#L1740-L1759 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.