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 | plenum/client/wallet.py | Wallet.signRequest | def signRequest(self,
req: Request,
identifier: Identifier=None) -> Request:
"""
Signs request. Modifies reqId and signature. May modify identifier.
:param req: request
:param requestIdStore: request id generator
:param identifier: signer ... | python | def signRequest(self,
req: Request,
identifier: Identifier=None) -> Request:
"""
Signs request. Modifies reqId and signature. May modify identifier.
:param req: request
:param requestIdStore: request id generator
:param identifier: signer ... | [
"def",
"signRequest",
"(",
"self",
",",
"req",
":",
"Request",
",",
"identifier",
":",
"Identifier",
"=",
"None",
")",
"->",
"Request",
":",
"idr",
"=",
"self",
".",
"requiredIdr",
"(",
"idr",
"=",
"identifier",
"or",
"req",
".",
"_identifier",
")",
"r... | Signs request. Modifies reqId and signature. May modify identifier.
:param req: request
:param requestIdStore: request id generator
:param identifier: signer identifier
:return: signed request | [
"Signs",
"request",
".",
"Modifies",
"reqId",
"and",
"signature",
".",
"May",
"modify",
"identifier",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/client/wallet.py#L180-L204 | train |
hyperledger/indy-plenum | plenum/client/wallet.py | Wallet.signOp | def signOp(self,
op: Dict,
identifier: Identifier=None) -> Request:
"""
Signs the message if a signer is configured
:param identifier: signing identifier; if not supplied the default for
the wallet is used.
:param op: Operation to be signed
... | python | def signOp(self,
op: Dict,
identifier: Identifier=None) -> Request:
"""
Signs the message if a signer is configured
:param identifier: signing identifier; if not supplied the default for
the wallet is used.
:param op: Operation to be signed
... | [
"def",
"signOp",
"(",
"self",
",",
"op",
":",
"Dict",
",",
"identifier",
":",
"Identifier",
"=",
"None",
")",
"->",
"Request",
":",
"request",
"=",
"Request",
"(",
"operation",
"=",
"op",
",",
"protocolVersion",
"=",
"CURRENT_PROTOCOL_VERSION",
")",
"retur... | Signs the message if a signer is configured
:param identifier: signing identifier; if not supplied the default for
the wallet is used.
:param op: Operation to be signed
:return: a signed Request object | [
"Signs",
"the",
"message",
"if",
"a",
"signer",
"is",
"configured"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/client/wallet.py#L206-L219 | train |
hyperledger/indy-plenum | plenum/client/wallet.py | Wallet.listIds | def listIds(self, exclude=list()):
"""
For each signer in this wallet, return its alias if present else
return its identifier.
:param exclude:
:return: List of identifiers/aliases.
"""
lst = list(self.aliasesToIds.keys())
others = set(self.idsToSigners.ke... | python | def listIds(self, exclude=list()):
"""
For each signer in this wallet, return its alias if present else
return its identifier.
:param exclude:
:return: List of identifiers/aliases.
"""
lst = list(self.aliasesToIds.keys())
others = set(self.idsToSigners.ke... | [
"def",
"listIds",
"(",
"self",
",",
"exclude",
"=",
"list",
"(",
")",
")",
":",
"lst",
"=",
"list",
"(",
"self",
".",
"aliasesToIds",
".",
"keys",
"(",
")",
")",
"others",
"=",
"set",
"(",
"self",
".",
"idsToSigners",
".",
"keys",
"(",
")",
")",
... | For each signer in this wallet, return its alias if present else
return its identifier.
:param exclude:
:return: List of identifiers/aliases. | [
"For",
"each",
"signer",
"in",
"this",
"wallet",
"return",
"its",
"alias",
"if",
"present",
"else",
"return",
"its",
"identifier",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/client/wallet.py#L267-L281 | train |
hyperledger/indy-plenum | plenum/client/wallet.py | WalletStorageHelper.saveWallet | def saveWallet(self, wallet, fpath):
"""Save wallet into specified localtion.
Returns the canonical path for the ``fpath`` where ``wallet``
has been stored.
Error cases:
- ``fpath`` is not inside the keyrings base dir - ValueError raised
- directory part of ``fp... | python | def saveWallet(self, wallet, fpath):
"""Save wallet into specified localtion.
Returns the canonical path for the ``fpath`` where ``wallet``
has been stored.
Error cases:
- ``fpath`` is not inside the keyrings base dir - ValueError raised
- directory part of ``fp... | [
"def",
"saveWallet",
"(",
"self",
",",
"wallet",
",",
"fpath",
")",
":",
"if",
"not",
"fpath",
":",
"raise",
"ValueError",
"(",
"\"empty path\"",
")",
"_fpath",
"=",
"self",
".",
"_normalize",
"(",
"fpath",
")",
"_dpath",
"=",
"_fpath",
".",
"parent",
... | Save wallet into specified localtion.
Returns the canonical path for the ``fpath`` where ``wallet``
has been stored.
Error cases:
- ``fpath`` is not inside the keyrings base dir - ValueError raised
- directory part of ``fpath`` exists and it's not a directory -
... | [
"Save",
"wallet",
"into",
"specified",
"localtion",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/client/wallet.py#L351-L394 | train |
hyperledger/indy-plenum | plenum/client/wallet.py | WalletStorageHelper.loadWallet | def loadWallet(self, fpath):
"""Load wallet from specified localtion.
Returns loaded wallet.
Error cases:
- ``fpath`` is not inside the keyrings base dir - ValueError raised
- ``fpath`` exists and it's a directory - IsADirectoryError raised
:param fpath: wallet... | python | def loadWallet(self, fpath):
"""Load wallet from specified localtion.
Returns loaded wallet.
Error cases:
- ``fpath`` is not inside the keyrings base dir - ValueError raised
- ``fpath`` exists and it's a directory - IsADirectoryError raised
:param fpath: wallet... | [
"def",
"loadWallet",
"(",
"self",
",",
"fpath",
")",
":",
"if",
"not",
"fpath",
":",
"raise",
"ValueError",
"(",
"\"empty path\"",
")",
"_fpath",
"=",
"self",
".",
"_normalize",
"(",
"fpath",
")",
"_dpath",
"=",
"_fpath",
".",
"parent",
"try",
":",
"_d... | Load wallet from specified localtion.
Returns loaded wallet.
Error cases:
- ``fpath`` is not inside the keyrings base dir - ValueError raised
- ``fpath`` exists and it's a directory - IsADirectoryError raised
:param fpath: wallet file path, absolute or relative to
... | [
"Load",
"wallet",
"from",
"specified",
"localtion",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/client/wallet.py#L396-L424 | train |
hyperledger/indy-plenum | plenum/server/models.py | Prepares.addVote | def addVote(self, prepare: Prepare, voter: str) -> None:
"""
Add the specified PREPARE to this replica's list of received
PREPAREs.
:param prepare: the PREPARE to add to the list
:param voter: the name of the node who sent the PREPARE
"""
self._add_msg(prepare, v... | python | def addVote(self, prepare: Prepare, voter: str) -> None:
"""
Add the specified PREPARE to this replica's list of received
PREPAREs.
:param prepare: the PREPARE to add to the list
:param voter: the name of the node who sent the PREPARE
"""
self._add_msg(prepare, v... | [
"def",
"addVote",
"(",
"self",
",",
"prepare",
":",
"Prepare",
",",
"voter",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"_add_msg",
"(",
"prepare",
",",
"voter",
")"
] | Add the specified PREPARE to this replica's list of received
PREPAREs.
:param prepare: the PREPARE to add to the list
:param voter: the name of the node who sent the PREPARE | [
"Add",
"the",
"specified",
"PREPARE",
"to",
"this",
"replica",
"s",
"list",
"of",
"received",
"PREPAREs",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/models.py#L62-L70 | train |
hyperledger/indy-plenum | plenum/server/models.py | Commits.addVote | def addVote(self, commit: Commit, voter: str) -> None:
"""
Add the specified COMMIT to this replica's list of received
COMMITs.
:param commit: the COMMIT to add to the list
:param voter: the name of the replica who sent the COMMIT
"""
super()._add_msg(commit, vot... | python | def addVote(self, commit: Commit, voter: str) -> None:
"""
Add the specified COMMIT to this replica's list of received
COMMITs.
:param commit: the COMMIT to add to the list
:param voter: the name of the replica who sent the COMMIT
"""
super()._add_msg(commit, vot... | [
"def",
"addVote",
"(",
"self",
",",
"commit",
":",
"Commit",
",",
"voter",
":",
"str",
")",
"->",
"None",
":",
"super",
"(",
")",
".",
"_add_msg",
"(",
"commit",
",",
"voter",
")"
] | Add the specified COMMIT to this replica's list of received
COMMITs.
:param commit: the COMMIT to add to the list
:param voter: the name of the replica who sent the COMMIT | [
"Add",
"the",
"specified",
"COMMIT",
"to",
"this",
"replica",
"s",
"list",
"of",
"received",
"COMMITs",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/models.py#L96-L104 | train |
hyperledger/indy-plenum | plenum/common/message_processor.py | MessageProcessor.discard | def discard(self, msg, reason, logMethod=logging.error, cliOutput=False):
"""
Discard a message and log a reason using the specified `logMethod`.
:param msg: the message to discard
:param reason: the reason why this message is being discarded
:param logMethod: the logging functi... | python | def discard(self, msg, reason, logMethod=logging.error, cliOutput=False):
"""
Discard a message and log a reason using the specified `logMethod`.
:param msg: the message to discard
:param reason: the reason why this message is being discarded
:param logMethod: the logging functi... | [
"def",
"discard",
"(",
"self",
",",
"msg",
",",
"reason",
",",
"logMethod",
"=",
"logging",
".",
"error",
",",
"cliOutput",
"=",
"False",
")",
":",
"reason",
"=",
"\"\"",
"if",
"not",
"reason",
"else",
"\" because {}\"",
".",
"format",
"(",
"reason",
"... | Discard a message and log a reason using the specified `logMethod`.
:param msg: the message to discard
:param reason: the reason why this message is being discarded
:param logMethod: the logging function to be used
:param cliOutput: if truthy, informs a CLI that the logged msg should
... | [
"Discard",
"a",
"message",
"and",
"log",
"a",
"reason",
"using",
"the",
"specified",
"logMethod",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/message_processor.py#L18-L30 | train |
hyperledger/indy-plenum | plenum/common/message_processor.py | MessageProcessor.toDict | def toDict(self, msg: Dict) -> Dict:
"""
Return a dictionary form of the message
:param msg: the message to be sent
:raises: ValueError if msg cannot be converted to an appropriate format
for transmission
"""
if isinstance(msg, Request):
tmsg = m... | python | def toDict(self, msg: Dict) -> Dict:
"""
Return a dictionary form of the message
:param msg: the message to be sent
:raises: ValueError if msg cannot be converted to an appropriate format
for transmission
"""
if isinstance(msg, Request):
tmsg = m... | [
"def",
"toDict",
"(",
"self",
",",
"msg",
":",
"Dict",
")",
"->",
"Dict",
":",
"if",
"isinstance",
"(",
"msg",
",",
"Request",
")",
":",
"tmsg",
"=",
"msg",
".",
"as_dict",
"elif",
"hasattr",
"(",
"msg",
",",
"\"_asdict\"",
")",
":",
"tmsg",
"=",
... | Return a dictionary form of the message
:param msg: the message to be sent
:raises: ValueError if msg cannot be converted to an appropriate format
for transmission | [
"Return",
"a",
"dictionary",
"form",
"of",
"the",
"message"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/message_processor.py#L32-L52 | train |
hyperledger/indy-plenum | plenum/server/replica_freshness_checker.py | FreshnessChecker.update_freshness | def update_freshness(self, ledger_id, ts):
'''
Updates the time at which the ledger was updated.
Should be called whenever a txn for the ledger is ordered.
:param ledger_id: the ID of the ledgers a txn was ordered for
:param ts: the current time
:return: None
'''... | python | def update_freshness(self, ledger_id, ts):
'''
Updates the time at which the ledger was updated.
Should be called whenever a txn for the ledger is ordered.
:param ledger_id: the ID of the ledgers a txn was ordered for
:param ts: the current time
:return: None
'''... | [
"def",
"update_freshness",
"(",
"self",
",",
"ledger_id",
",",
"ts",
")",
":",
"if",
"ledger_id",
"in",
"self",
".",
"_ledger_freshness",
":",
"self",
".",
"_ledger_freshness",
"[",
"ledger_id",
"]",
".",
"last_updated",
"=",
"ts"
] | Updates the time at which the ledger was updated.
Should be called whenever a txn for the ledger is ordered.
:param ledger_id: the ID of the ledgers a txn was ordered for
:param ts: the current time
:return: None | [
"Updates",
"the",
"time",
"at",
"which",
"the",
"ledger",
"was",
"updated",
".",
"Should",
"be",
"called",
"whenever",
"a",
"txn",
"for",
"the",
"ledger",
"is",
"ordered",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica_freshness_checker.py#L50-L60 | train |
hyperledger/indy-plenum | plenum/server/replica_freshness_checker.py | FreshnessChecker.get_last_update_time | def get_last_update_time(self):
'''
Gets the time at which each ledger was updated.
Can be called at any time to get this information.
:return: an ordered dict of outdated ledgers sorted by last update time (from old to new)
and then by ledger ID (in case of equal update time)
... | python | def get_last_update_time(self):
'''
Gets the time at which each ledger was updated.
Can be called at any time to get this information.
:return: an ordered dict of outdated ledgers sorted by last update time (from old to new)
and then by ledger ID (in case of equal update time)
... | [
"def",
"get_last_update_time",
"(",
"self",
")",
":",
"last_updated",
"=",
"{",
"ledger_id",
":",
"freshness_state",
".",
"last_updated",
"for",
"ledger_id",
",",
"freshness_state",
"in",
"self",
".",
"_ledger_freshness",
".",
"items",
"(",
")",
"}",
"return",
... | Gets the time at which each ledger was updated.
Can be called at any time to get this information.
:return: an ordered dict of outdated ledgers sorted by last update time (from old to new)
and then by ledger ID (in case of equal update time) | [
"Gets",
"the",
"time",
"at",
"which",
"each",
"ledger",
"was",
"updated",
".",
"Can",
"be",
"called",
"at",
"any",
"time",
"to",
"get",
"this",
"information",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/replica_freshness_checker.py#L62-L77 | train |
hyperledger/indy-plenum | common/serializers/signing_serializer.py | SigningSerializer.serialize | def serialize(self, obj, level=0, objname=None, topLevelKeysToIgnore=None,
toBytes=True):
"""
Create a string representation of the given object.
Examples:
::
>>> serialize("str")
'str'
>>> serialize([1,2,3,4,5])
'1,2,3,4,5'
>>> ... | python | def serialize(self, obj, level=0, objname=None, topLevelKeysToIgnore=None,
toBytes=True):
"""
Create a string representation of the given object.
Examples:
::
>>> serialize("str")
'str'
>>> serialize([1,2,3,4,5])
'1,2,3,4,5'
>>> ... | [
"def",
"serialize",
"(",
"self",
",",
"obj",
",",
"level",
"=",
"0",
",",
"objname",
"=",
"None",
",",
"topLevelKeysToIgnore",
"=",
"None",
",",
"toBytes",
"=",
"True",
")",
":",
"res",
"=",
"None",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"accept... | Create a string representation of the given object.
Examples:
::
>>> serialize("str")
'str'
>>> serialize([1,2,3,4,5])
'1,2,3,4,5'
>>> signing.serlize({1:'a', 2:'b'})
'1:a|2:b'
>>> signing.serlize({1:'a', 2:'b', 3:[1,{2:'k'}]})
'1:a|2:b|3:... | [
"Create",
"a",
"string",
"representation",
"of",
"the",
"given",
"object",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/common/serializers/signing_serializer.py#L35-L92 | train |
hyperledger/indy-plenum | plenum/common/transaction_store.py | TransactionStore.reset | def reset(self):
"""
Clear the values of all attributes of the transaction store.
"""
self.getsCounter = 0
# dictionary of processed requests for each client. Value for each
# client is a dictionary with request id as key and transaction id as
# value
sel... | python | def reset(self):
"""
Clear the values of all attributes of the transaction store.
"""
self.getsCounter = 0
# dictionary of processed requests for each client. Value for each
# client is a dictionary with request id as key and transaction id as
# value
sel... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"getsCounter",
"=",
"0",
"self",
".",
"processedRequests",
"=",
"{",
"}",
"self",
".",
"responses",
"=",
"{",
"}",
"self",
".",
"transactions",
"=",
"{",
"}"
] | Clear the values of all attributes of the transaction store. | [
"Clear",
"the",
"values",
"of",
"all",
"attributes",
"of",
"the",
"transaction",
"store",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/transaction_store.py#L33-L50 | train |
hyperledger/indy-plenum | plenum/common/transaction_store.py | TransactionStore.stop | def stop(self, timeout: int = 5) -> None:
"""
Try to stop the transaction store in the given timeout or raise an
exception.
"""
self.running = False
start = time.perf_counter()
while True:
if self.getsCounter == 0:
return True
... | python | def stop(self, timeout: int = 5) -> None:
"""
Try to stop the transaction store in the given timeout or raise an
exception.
"""
self.running = False
start = time.perf_counter()
while True:
if self.getsCounter == 0:
return True
... | [
"def",
"stop",
"(",
"self",
",",
"timeout",
":",
"int",
"=",
"5",
")",
"->",
"None",
":",
"self",
".",
"running",
"=",
"False",
"start",
"=",
"time",
".",
"perf_counter",
"(",
")",
"while",
"True",
":",
"if",
"self",
".",
"getsCounter",
"==",
"0",
... | Try to stop the transaction store in the given timeout or raise an
exception. | [
"Try",
"to",
"stop",
"the",
"transaction",
"store",
"in",
"the",
"given",
"timeout",
"or",
"raise",
"an",
"exception",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/transaction_store.py#L57-L71 | train |
hyperledger/indy-plenum | plenum/common/transaction_store.py | TransactionStore.addToProcessedTxns | def addToProcessedTxns(self,
identifier: str,
txnId: str,
reply: Reply) -> None:
"""
Add a client request to the transaction store's list of processed
requests.
"""
self.transactions[txnId] = reply
... | python | def addToProcessedTxns(self,
identifier: str,
txnId: str,
reply: Reply) -> None:
"""
Add a client request to the transaction store's list of processed
requests.
"""
self.transactions[txnId] = reply
... | [
"def",
"addToProcessedTxns",
"(",
"self",
",",
"identifier",
":",
"str",
",",
"txnId",
":",
"str",
",",
"reply",
":",
"Reply",
")",
"->",
"None",
":",
"self",
".",
"transactions",
"[",
"txnId",
"]",
"=",
"reply",
"if",
"identifier",
"not",
"in",
"self"... | Add a client request to the transaction store's list of processed
requests. | [
"Add",
"a",
"client",
"request",
"to",
"the",
"transaction",
"store",
"s",
"list",
"of",
"processed",
"requests",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/transaction_store.py#L73-L84 | train |
hyperledger/indy-plenum | plenum/common/transaction_store.py | TransactionStore.append | async def append(self, reply: Reply) \
-> None:
"""
Add the given Reply to this transaction store's list of responses.
Also add to processedRequests if not added previously.
"""
result = reply.result
identifier = result.get(f.IDENTIFIER.nm)
txnId = res... | python | async def append(self, reply: Reply) \
-> None:
"""
Add the given Reply to this transaction store's list of responses.
Also add to processedRequests if not added previously.
"""
result = reply.result
identifier = result.get(f.IDENTIFIER.nm)
txnId = res... | [
"async",
"def",
"append",
"(",
"self",
",",
"reply",
":",
"Reply",
")",
"->",
"None",
":",
"result",
"=",
"reply",
".",
"result",
"identifier",
"=",
"result",
".",
"get",
"(",
"f",
".",
"IDENTIFIER",
".",
"nm",
")",
"txnId",
"=",
"result",
".",
"ge... | Add the given Reply to this transaction store's list of responses.
Also add to processedRequests if not added previously. | [
"Add",
"the",
"given",
"Reply",
"to",
"this",
"transaction",
"store",
"s",
"list",
"of",
"responses",
".",
"Also",
"add",
"to",
"processedRequests",
"if",
"not",
"added",
"previously",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/transaction_store.py#L86-L100 | train |
hyperledger/indy-plenum | plenum/common/transaction_store.py | TransactionStore._isNewTxn | def _isNewTxn(self, identifier, reply, txnId) -> bool:
"""
If client is not in `processedRequests` or requestId is not there in
processed requests and txnId is present then its a new reply
"""
return (identifier not in self.processedRequests or
reply.reqId not in ... | python | def _isNewTxn(self, identifier, reply, txnId) -> bool:
"""
If client is not in `processedRequests` or requestId is not there in
processed requests and txnId is present then its a new reply
"""
return (identifier not in self.processedRequests or
reply.reqId not in ... | [
"def",
"_isNewTxn",
"(",
"self",
",",
"identifier",
",",
"reply",
",",
"txnId",
")",
"->",
"bool",
":",
"return",
"(",
"identifier",
"not",
"in",
"self",
".",
"processedRequests",
"or",
"reply",
".",
"reqId",
"not",
"in",
"self",
".",
"processedRequests",
... | If client is not in `processedRequests` or requestId is not there in
processed requests and txnId is present then its a new reply | [
"If",
"client",
"is",
"not",
"in",
"processedRequests",
"or",
"requestId",
"is",
"not",
"there",
"in",
"processed",
"requests",
"and",
"txnId",
"is",
"present",
"then",
"its",
"a",
"new",
"reply"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/transaction_store.py#L110-L117 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.add | def add(self, req: Request):
"""
Add the specified request to this request store.
"""
key = req.key
if key not in self:
self[key] = ReqState(req)
return self[key] | python | def add(self, req: Request):
"""
Add the specified request to this request store.
"""
key = req.key
if key not in self:
self[key] = ReqState(req)
return self[key] | [
"def",
"add",
"(",
"self",
",",
"req",
":",
"Request",
")",
":",
"key",
"=",
"req",
".",
"key",
"if",
"key",
"not",
"in",
"self",
":",
"self",
"[",
"key",
"]",
"=",
"ReqState",
"(",
"req",
")",
"return",
"self",
"[",
"key",
"]"
] | Add the specified request to this request store. | [
"Add",
"the",
"specified",
"request",
"to",
"this",
"request",
"store",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L74-L81 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.ordered_by_replica | def ordered_by_replica(self, request_key):
"""
Should be called by each replica when request is ordered or replica is removed.
"""
state = self.get(request_key)
if not state:
return
state.unordered_by_replicas_num -= 1 | python | def ordered_by_replica(self, request_key):
"""
Should be called by each replica when request is ordered or replica is removed.
"""
state = self.get(request_key)
if not state:
return
state.unordered_by_replicas_num -= 1 | [
"def",
"ordered_by_replica",
"(",
"self",
",",
"request_key",
")",
":",
"state",
"=",
"self",
".",
"get",
"(",
"request_key",
")",
"if",
"not",
"state",
":",
"return",
"state",
".",
"unordered_by_replicas_num",
"-=",
"1"
] | Should be called by each replica when request is ordered or replica is removed. | [
"Should",
"be",
"called",
"by",
"each",
"replica",
"when",
"request",
"is",
"ordered",
"or",
"replica",
"is",
"removed",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L89-L96 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.mark_as_forwarded | def mark_as_forwarded(self, req: Request, to: int):
"""
Works together with 'mark_as_executed' and 'free' methods.
It marks request as forwarded to 'to' replicas.
To let request be removed, it should be marked as executed and each of
'to' replicas should call 'free'.
"""... | python | def mark_as_forwarded(self, req: Request, to: int):
"""
Works together with 'mark_as_executed' and 'free' methods.
It marks request as forwarded to 'to' replicas.
To let request be removed, it should be marked as executed and each of
'to' replicas should call 'free'.
"""... | [
"def",
"mark_as_forwarded",
"(",
"self",
",",
"req",
":",
"Request",
",",
"to",
":",
"int",
")",
":",
"self",
"[",
"req",
".",
"key",
"]",
".",
"forwarded",
"=",
"True",
"self",
"[",
"req",
".",
"key",
"]",
".",
"forwardedTo",
"=",
"to",
"self",
... | Works together with 'mark_as_executed' and 'free' methods.
It marks request as forwarded to 'to' replicas.
To let request be removed, it should be marked as executed and each of
'to' replicas should call 'free'. | [
"Works",
"together",
"with",
"mark_as_executed",
"and",
"free",
"methods",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L98-L108 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.add_propagate | def add_propagate(self, req: Request, sender: str):
"""
Add the specified request to the list of received
PROPAGATEs.
:param req: the REQUEST to add
:param sender: the name of the node sending the msg
"""
data = self.add(req)
data.propagates[sender] = req | python | def add_propagate(self, req: Request, sender: str):
"""
Add the specified request to the list of received
PROPAGATEs.
:param req: the REQUEST to add
:param sender: the name of the node sending the msg
"""
data = self.add(req)
data.propagates[sender] = req | [
"def",
"add_propagate",
"(",
"self",
",",
"req",
":",
"Request",
",",
"sender",
":",
"str",
")",
":",
"data",
"=",
"self",
".",
"add",
"(",
"req",
")",
"data",
".",
"propagates",
"[",
"sender",
"]",
"=",
"req"
] | Add the specified request to the list of received
PROPAGATEs.
:param req: the REQUEST to add
:param sender: the name of the node sending the msg | [
"Add",
"the",
"specified",
"request",
"to",
"the",
"list",
"of",
"received",
"PROPAGATEs",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L110-L119 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.votes | def votes(self, req) -> int:
"""
Get the number of propagates for a given reqId and identifier.
"""
try:
votes = len(self[req.key].propagates)
except KeyError:
votes = 0
return votes | python | def votes(self, req) -> int:
"""
Get the number of propagates for a given reqId and identifier.
"""
try:
votes = len(self[req.key].propagates)
except KeyError:
votes = 0
return votes | [
"def",
"votes",
"(",
"self",
",",
"req",
")",
"->",
"int",
":",
"try",
":",
"votes",
"=",
"len",
"(",
"self",
"[",
"req",
".",
"key",
"]",
".",
"propagates",
")",
"except",
"KeyError",
":",
"votes",
"=",
"0",
"return",
"votes"
] | Get the number of propagates for a given reqId and identifier. | [
"Get",
"the",
"number",
"of",
"propagates",
"for",
"a",
"given",
"reqId",
"and",
"identifier",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L121-L129 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.mark_as_executed | def mark_as_executed(self, req: Request):
"""
Works together with 'mark_as_forwarded' and 'free' methods.
It makes request to be removed if all replicas request was
forwarded to freed it.
"""
state = self[req.key]
state.executed = True
self._clean(state) | python | def mark_as_executed(self, req: Request):
"""
Works together with 'mark_as_forwarded' and 'free' methods.
It makes request to be removed if all replicas request was
forwarded to freed it.
"""
state = self[req.key]
state.executed = True
self._clean(state) | [
"def",
"mark_as_executed",
"(",
"self",
",",
"req",
":",
"Request",
")",
":",
"state",
"=",
"self",
"[",
"req",
".",
"key",
"]",
"state",
".",
"executed",
"=",
"True",
"self",
".",
"_clean",
"(",
"state",
")"
] | Works together with 'mark_as_forwarded' and 'free' methods.
It makes request to be removed if all replicas request was
forwarded to freed it. | [
"Works",
"together",
"with",
"mark_as_forwarded",
"and",
"free",
"methods",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L141-L150 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.free | def free(self, request_key):
"""
Works together with 'mark_as_forwarded' and
'mark_as_executed' methods.
It makes request to be removed if all replicas request was
forwarded to freed it and if request executor marked it as executed.
"""
state = self.get(request_k... | python | def free(self, request_key):
"""
Works together with 'mark_as_forwarded' and
'mark_as_executed' methods.
It makes request to be removed if all replicas request was
forwarded to freed it and if request executor marked it as executed.
"""
state = self.get(request_k... | [
"def",
"free",
"(",
"self",
",",
"request_key",
")",
":",
"state",
"=",
"self",
".",
"get",
"(",
"request_key",
")",
"if",
"not",
"state",
":",
"return",
"state",
".",
"forwardedTo",
"-=",
"1",
"self",
".",
"_clean",
"(",
"state",
")"
] | Works together with 'mark_as_forwarded' and
'mark_as_executed' methods.
It makes request to be removed if all replicas request was
forwarded to freed it and if request executor marked it as executed. | [
"Works",
"together",
"with",
"mark_as_forwarded",
"and",
"mark_as_executed",
"methods",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L152-L164 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Requests.has_propagated | def has_propagated(self, req: Request, sender: str) -> bool:
"""
Check whether the request specified has already been propagated.
"""
return req.key in self and sender in self[req.key].propagates | python | def has_propagated(self, req: Request, sender: str) -> bool:
"""
Check whether the request specified has already been propagated.
"""
return req.key in self and sender in self[req.key].propagates | [
"def",
"has_propagated",
"(",
"self",
",",
"req",
":",
"Request",
",",
"sender",
":",
"str",
")",
"->",
"bool",
":",
"return",
"req",
".",
"key",
"in",
"self",
"and",
"sender",
"in",
"self",
"[",
"req",
".",
"key",
"]",
".",
"propagates"
] | Check whether the request specified has already been propagated. | [
"Check",
"whether",
"the",
"request",
"specified",
"has",
"already",
"been",
"propagated",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L180-L184 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Propagator.propagate | def propagate(self, request: Request, clientName):
"""
Broadcast a PROPAGATE to all other nodes
:param request: the REQUEST to propagate
"""
if self.requests.has_propagated(request, self.name):
logger.trace("{} already propagated {}".format(self, request))
el... | python | def propagate(self, request: Request, clientName):
"""
Broadcast a PROPAGATE to all other nodes
:param request: the REQUEST to propagate
"""
if self.requests.has_propagated(request, self.name):
logger.trace("{} already propagated {}".format(self, request))
el... | [
"def",
"propagate",
"(",
"self",
",",
"request",
":",
"Request",
",",
"clientName",
")",
":",
"if",
"self",
".",
"requests",
".",
"has_propagated",
"(",
"request",
",",
"self",
".",
"name",
")",
":",
"logger",
".",
"trace",
"(",
"\"{} already propagated {}... | Broadcast a PROPAGATE to all other nodes
:param request: the REQUEST to propagate | [
"Broadcast",
"a",
"PROPAGATE",
"to",
"all",
"other",
"nodes"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L203-L217 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Propagator.createPropagate | def createPropagate(
request: Union[Request, dict], client_name) -> Propagate:
"""
Create a new PROPAGATE for the given REQUEST.
:param request: the client REQUEST
:return: a new PROPAGATE msg
"""
if not isinstance(request, (Request, dict)):
logge... | python | def createPropagate(
request: Union[Request, dict], client_name) -> Propagate:
"""
Create a new PROPAGATE for the given REQUEST.
:param request: the client REQUEST
:return: a new PROPAGATE msg
"""
if not isinstance(request, (Request, dict)):
logge... | [
"def",
"createPropagate",
"(",
"request",
":",
"Union",
"[",
"Request",
",",
"dict",
"]",
",",
"client_name",
")",
"->",
"Propagate",
":",
"if",
"not",
"isinstance",
"(",
"request",
",",
"(",
"Request",
",",
"dict",
")",
")",
":",
"logger",
".",
"error... | Create a new PROPAGATE for the given REQUEST.
:param request: the client REQUEST
:return: a new PROPAGATE msg | [
"Create",
"a",
"new",
"PROPAGATE",
"for",
"the",
"given",
"REQUEST",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L220-L237 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Propagator.forward | def forward(self, request: Request):
"""
Forward the specified client REQUEST to the other replicas on this node
:param request: the REQUEST to propagate
"""
key = request.key
num_replicas = self.replicas.num_replicas
logger.debug('{} forwarding request {} to {} ... | python | def forward(self, request: Request):
"""
Forward the specified client REQUEST to the other replicas on this node
:param request: the REQUEST to propagate
"""
key = request.key
num_replicas = self.replicas.num_replicas
logger.debug('{} forwarding request {} to {} ... | [
"def",
"forward",
"(",
"self",
",",
"request",
":",
"Request",
")",
":",
"key",
"=",
"request",
".",
"key",
"num_replicas",
"=",
"self",
".",
"replicas",
".",
"num_replicas",
"logger",
".",
"debug",
"(",
"'{} forwarding request {} to {} replicas'",
".",
"forma... | Forward the specified client REQUEST to the other replicas on this node
:param request: the REQUEST to propagate | [
"Forward",
"the",
"specified",
"client",
"REQUEST",
"to",
"the",
"other",
"replicas",
"on",
"this",
"node"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L273-L285 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Propagator.recordAndPropagate | def recordAndPropagate(self, request: Request, clientName):
"""
Record the request in the list of requests and propagate.
:param request:
:param clientName:
"""
self.requests.add(request)
self.propagate(request, clientName)
self.tryForwarding(request) | python | def recordAndPropagate(self, request: Request, clientName):
"""
Record the request in the list of requests and propagate.
:param request:
:param clientName:
"""
self.requests.add(request)
self.propagate(request, clientName)
self.tryForwarding(request) | [
"def",
"recordAndPropagate",
"(",
"self",
",",
"request",
":",
"Request",
",",
"clientName",
")",
":",
"self",
".",
"requests",
".",
"add",
"(",
"request",
")",
"self",
".",
"propagate",
"(",
"request",
",",
"clientName",
")",
"self",
".",
"tryForwarding",... | Record the request in the list of requests and propagate.
:param request:
:param clientName: | [
"Record",
"the",
"request",
"in",
"the",
"list",
"of",
"requests",
"and",
"propagate",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L288-L297 | train |
hyperledger/indy-plenum | plenum/server/propagator.py | Propagator.tryForwarding | def tryForwarding(self, request: Request):
"""
Try to forward the request if the required conditions are met.
See the method `canForward` for the conditions to check before
forwarding a request.
"""
cannot_reason_msg = self.canForward(request)
if cannot_reason_msg... | python | def tryForwarding(self, request: Request):
"""
Try to forward the request if the required conditions are met.
See the method `canForward` for the conditions to check before
forwarding a request.
"""
cannot_reason_msg = self.canForward(request)
if cannot_reason_msg... | [
"def",
"tryForwarding",
"(",
"self",
",",
"request",
":",
"Request",
")",
":",
"cannot_reason_msg",
"=",
"self",
".",
"canForward",
"(",
"request",
")",
"if",
"cannot_reason_msg",
"is",
"None",
":",
"self",
".",
"forward",
"(",
"request",
")",
"else",
":",... | Try to forward the request if the required conditions are met.
See the method `canForward` for the conditions to check before
forwarding a request. | [
"Try",
"to",
"forward",
"the",
"request",
"if",
"the",
"required",
"conditions",
"are",
"met",
".",
"See",
"the",
"method",
"canForward",
"for",
"the",
"conditions",
"to",
"check",
"before",
"forwarding",
"a",
"request",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/propagator.py#L299-L313 | train |
hyperledger/indy-plenum | stp_zmq/zstack.py | ZStack.removeRemote | def removeRemote(self, remote: Remote, clear=True):
"""
Currently not using clear
"""
name = remote.name
pkey = remote.publicKey
vkey = remote.verKey
if name in self.remotes:
self.remotes.pop(name)
self.remotesByKeys.pop(pkey, None)
... | python | def removeRemote(self, remote: Remote, clear=True):
"""
Currently not using clear
"""
name = remote.name
pkey = remote.publicKey
vkey = remote.verKey
if name in self.remotes:
self.remotes.pop(name)
self.remotesByKeys.pop(pkey, None)
... | [
"def",
"removeRemote",
"(",
"self",
",",
"remote",
":",
"Remote",
",",
"clear",
"=",
"True",
")",
":",
"name",
"=",
"remote",
".",
"name",
"pkey",
"=",
"remote",
".",
"publicKey",
"vkey",
"=",
"remote",
".",
"verKey",
"if",
"name",
"in",
"self",
".",... | Currently not using clear | [
"Currently",
"not",
"using",
"clear"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/zstack.py#L153-L165 | train |
hyperledger/indy-plenum | stp_zmq/zstack.py | ZStack.service | async def service(self, limit=None, quota: Optional[Quota] = None) -> int:
"""
Service `limit` number of received messages in this stack.
:param limit: the maximum number of messages to be processed. If None,
processes all of the messages in rxMsgs.
:return: the number of messag... | python | async def service(self, limit=None, quota: Optional[Quota] = None) -> int:
"""
Service `limit` number of received messages in this stack.
:param limit: the maximum number of messages to be processed. If None,
processes all of the messages in rxMsgs.
:return: the number of messag... | [
"async",
"def",
"service",
"(",
"self",
",",
"limit",
"=",
"None",
",",
"quota",
":",
"Optional",
"[",
"Quota",
"]",
"=",
"None",
")",
"->",
"int",
":",
"if",
"self",
".",
"listener",
":",
"await",
"self",
".",
"_serviceStack",
"(",
"self",
".",
"a... | Service `limit` number of received messages in this stack.
:param limit: the maximum number of messages to be processed. If None,
processes all of the messages in rxMsgs.
:return: the number of messages processed. | [
"Service",
"limit",
"number",
"of",
"received",
"messages",
"in",
"this",
"stack",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/zstack.py#L445-L462 | train |
hyperledger/indy-plenum | stp_zmq/zstack.py | ZStack.connect | def connect(self,
name=None,
remoteId=None,
ha=None,
verKeyRaw=None,
publicKeyRaw=None):
"""
Connect to the node specified by name.
"""
if not name:
raise ValueError('Remote name should be specifi... | python | def connect(self,
name=None,
remoteId=None,
ha=None,
verKeyRaw=None,
publicKeyRaw=None):
"""
Connect to the node specified by name.
"""
if not name:
raise ValueError('Remote name should be specifi... | [
"def",
"connect",
"(",
"self",
",",
"name",
"=",
"None",
",",
"remoteId",
"=",
"None",
",",
"ha",
"=",
"None",
",",
"verKeyRaw",
"=",
"None",
",",
"publicKeyRaw",
"=",
"None",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"'Remote n... | Connect to the node specified by name. | [
"Connect",
"to",
"the",
"node",
"specified",
"by",
"name",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/zstack.py#L584-L629 | train |
hyperledger/indy-plenum | stp_zmq/zstack.py | ZStack.reconnectRemote | def reconnectRemote(self, remote):
"""
Disconnect remote and connect to it again
:param remote: instance of Remote from self.remotes
:param remoteName: name of remote
:return:
"""
if not isinstance(remote, Remote):
raise PlenumTypeError('remote', remo... | python | def reconnectRemote(self, remote):
"""
Disconnect remote and connect to it again
:param remote: instance of Remote from self.remotes
:param remoteName: name of remote
:return:
"""
if not isinstance(remote, Remote):
raise PlenumTypeError('remote', remo... | [
"def",
"reconnectRemote",
"(",
"self",
",",
"remote",
")",
":",
"if",
"not",
"isinstance",
"(",
"remote",
",",
"Remote",
")",
":",
"raise",
"PlenumTypeError",
"(",
"'remote'",
",",
"remote",
",",
"Remote",
")",
"logger",
".",
"info",
"(",
"'{} reconnecting... | Disconnect remote and connect to it again
:param remote: instance of Remote from self.remotes
:param remoteName: name of remote
:return: | [
"Disconnect",
"remote",
"and",
"connect",
"to",
"it",
"again"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/zstack.py#L631-L645 | train |
hyperledger/indy-plenum | plenum/persistence/db_hash_store.py | DbHashStore._readMultiple | def _readMultiple(self, start, end, db):
"""
Returns a list of hashes with serial numbers between start
and end, both inclusive.
"""
self._validatePos(start, end)
# Converting any bytearray to bytes
return [bytes(db.get(str(pos))) for pos in range(start, end + 1... | python | def _readMultiple(self, start, end, db):
"""
Returns a list of hashes with serial numbers between start
and end, both inclusive.
"""
self._validatePos(start, end)
# Converting any bytearray to bytes
return [bytes(db.get(str(pos))) for pos in range(start, end + 1... | [
"def",
"_readMultiple",
"(",
"self",
",",
"start",
",",
"end",
",",
"db",
")",
":",
"self",
".",
"_validatePos",
"(",
"start",
",",
"end",
")",
"return",
"[",
"bytes",
"(",
"db",
".",
"get",
"(",
"str",
"(",
"pos",
")",
")",
")",
"for",
"pos",
... | Returns a list of hashes with serial numbers between start
and end, both inclusive. | [
"Returns",
"a",
"list",
"of",
"hashes",
"with",
"serial",
"numbers",
"between",
"start",
"and",
"end",
"both",
"inclusive",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/persistence/db_hash_store.py#L67-L74 | train |
hyperledger/indy-plenum | state/trie/pruning_trie.py | pack_nibbles | def pack_nibbles(nibbles):
"""pack nibbles to binary
:param nibbles: a nibbles sequence. may have a terminator
"""
if nibbles[-1] == NIBBLE_TERMINATOR:
flags = 2
nibbles = nibbles[:-1]
else:
flags = 0
oddlen = len(nibbles) % 2
flags |= oddlen # set lowest bit if ... | python | def pack_nibbles(nibbles):
"""pack nibbles to binary
:param nibbles: a nibbles sequence. may have a terminator
"""
if nibbles[-1] == NIBBLE_TERMINATOR:
flags = 2
nibbles = nibbles[:-1]
else:
flags = 0
oddlen = len(nibbles) % 2
flags |= oddlen # set lowest bit if ... | [
"def",
"pack_nibbles",
"(",
"nibbles",
")",
":",
"if",
"nibbles",
"[",
"-",
"1",
"]",
"==",
"NIBBLE_TERMINATOR",
":",
"flags",
"=",
"2",
"nibbles",
"=",
"nibbles",
"[",
":",
"-",
"1",
"]",
"else",
":",
"flags",
"=",
"0",
"oddlen",
"=",
"len",
"(",
... | pack nibbles to binary
:param nibbles: a nibbles sequence. may have a terminator | [
"pack",
"nibbles",
"to",
"binary"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/state/trie/pruning_trie.py#L140-L161 | train |
hyperledger/indy-plenum | state/trie/pruning_trie.py | Trie._get_last_node_for_prfx | def _get_last_node_for_prfx(self, node, key_prfx, seen_prfx):
""" get last node for the given prefix, also update `seen_prfx` to track the path already traversed
:param node: node in form of list, or BLANK_NODE
:param key_prfx: prefix to look for
:param seen_prfx: prefix already seen, u... | python | def _get_last_node_for_prfx(self, node, key_prfx, seen_prfx):
""" get last node for the given prefix, also update `seen_prfx` to track the path already traversed
:param node: node in form of list, or BLANK_NODE
:param key_prfx: prefix to look for
:param seen_prfx: prefix already seen, u... | [
"def",
"_get_last_node_for_prfx",
"(",
"self",
",",
"node",
",",
"key_prfx",
",",
"seen_prfx",
")",
":",
"node_type",
"=",
"self",
".",
"_get_node_type",
"(",
"node",
")",
"if",
"node_type",
"==",
"NODE_TYPE_BLANK",
":",
"return",
"BLANK_NODE",
"if",
"node_typ... | get last node for the given prefix, also update `seen_prfx` to track the path already traversed
:param node: node in form of list, or BLANK_NODE
:param key_prfx: prefix to look for
:param seen_prfx: prefix already seen, updates with each call
:return:
BLANK_NODE if does not ... | [
"get",
"last",
"node",
"for",
"the",
"given",
"prefix",
"also",
"update",
"seen_prfx",
"to",
"track",
"the",
"path",
"already",
"traversed"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/state/trie/pruning_trie.py#L410-L459 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.metrics | def metrics(self):
"""
Calculate and return the metrics.
"""
masterThrp, backupThrp = self.getThroughputs(self.instances.masterId)
r = self.instance_throughput_ratio(self.instances.masterId)
m = [
("{} Monitor metrics:".format(self), None),
("Delta... | python | def metrics(self):
"""
Calculate and return the metrics.
"""
masterThrp, backupThrp = self.getThroughputs(self.instances.masterId)
r = self.instance_throughput_ratio(self.instances.masterId)
m = [
("{} Monitor metrics:".format(self), None),
("Delta... | [
"def",
"metrics",
"(",
"self",
")",
":",
"masterThrp",
",",
"backupThrp",
"=",
"self",
".",
"getThroughputs",
"(",
"self",
".",
"instances",
".",
"masterId",
")",
"r",
"=",
"self",
".",
"instance_throughput_ratio",
"(",
"self",
".",
"instances",
".",
"mast... | Calculate and return the metrics. | [
"Calculate",
"and",
"return",
"the",
"metrics",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L256-L281 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.prettymetrics | def prettymetrics(self) -> str:
"""
Pretty printing for metrics
"""
rendered = ["{}: {}".format(*m) for m in self.metrics()]
return "\n ".join(rendered) | python | def prettymetrics(self) -> str:
"""
Pretty printing for metrics
"""
rendered = ["{}: {}".format(*m) for m in self.metrics()]
return "\n ".join(rendered) | [
"def",
"prettymetrics",
"(",
"self",
")",
"->",
"str",
":",
"rendered",
"=",
"[",
"\"{}: {}\"",
".",
"format",
"(",
"*",
"m",
")",
"for",
"m",
"in",
"self",
".",
"metrics",
"(",
")",
"]",
"return",
"\"\\n \"",
".",
"join",
"(",
"rendered",
... | Pretty printing for metrics | [
"Pretty",
"printing",
"for",
"metrics"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L284-L289 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.reset | def reset(self):
"""
Reset the monitor. Sets all monitored values to defaults.
"""
logger.debug("{}'s Monitor being reset".format(self))
instances_ids = self.instances.started.keys()
self.numOrderedRequests = {inst_id: (0, 0) for inst_id in instances_ids}
self.req... | python | def reset(self):
"""
Reset the monitor. Sets all monitored values to defaults.
"""
logger.debug("{}'s Monitor being reset".format(self))
instances_ids = self.instances.started.keys()
self.numOrderedRequests = {inst_id: (0, 0) for inst_id in instances_ids}
self.req... | [
"def",
"reset",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"{}'s Monitor being reset\"",
".",
"format",
"(",
"self",
")",
")",
"instances_ids",
"=",
"self",
".",
"instances",
".",
"started",
".",
"keys",
"(",
")",
"self",
".",
"numOrderedRequest... | Reset the monitor. Sets all monitored values to defaults. | [
"Reset",
"the",
"monitor",
".",
"Sets",
"all",
"monitored",
"values",
"to",
"defaults",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L308-L326 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.addInstance | def addInstance(self, inst_id):
"""
Add one protocol instance for monitoring.
"""
self.instances.add(inst_id)
self.requestTracker.add_instance(inst_id)
self.numOrderedRequests[inst_id] = (0, 0)
rm = self.create_throughput_measurement(self.config)
self.thr... | python | def addInstance(self, inst_id):
"""
Add one protocol instance for monitoring.
"""
self.instances.add(inst_id)
self.requestTracker.add_instance(inst_id)
self.numOrderedRequests[inst_id] = (0, 0)
rm = self.create_throughput_measurement(self.config)
self.thr... | [
"def",
"addInstance",
"(",
"self",
",",
"inst_id",
")",
":",
"self",
".",
"instances",
".",
"add",
"(",
"inst_id",
")",
"self",
".",
"requestTracker",
".",
"add_instance",
"(",
"inst_id",
")",
"self",
".",
"numOrderedRequests",
"[",
"inst_id",
"]",
"=",
... | Add one protocol instance for monitoring. | [
"Add",
"one",
"protocol",
"instance",
"for",
"monitoring",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L328-L341 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.requestOrdered | def requestOrdered(self, reqIdrs: List[str], instId: int,
requests, byMaster: bool = False) -> Dict:
"""
Measure the time taken for ordering of a request and return it. Monitor
might have been reset due to view change due to which this method
returns None
"... | python | def requestOrdered(self, reqIdrs: List[str], instId: int,
requests, byMaster: bool = False) -> Dict:
"""
Measure the time taken for ordering of a request and return it. Monitor
might have been reset due to view change due to which this method
returns None
"... | [
"def",
"requestOrdered",
"(",
"self",
",",
"reqIdrs",
":",
"List",
"[",
"str",
"]",
",",
"instId",
":",
"int",
",",
"requests",
",",
"byMaster",
":",
"bool",
"=",
"False",
")",
"->",
"Dict",
":",
"now",
"=",
"time",
".",
"perf_counter",
"(",
")",
"... | Measure the time taken for ordering of a request and return it. Monitor
might have been reset due to view change due to which this method
returns None | [
"Measure",
"the",
"time",
"taken",
"for",
"ordering",
"of",
"a",
"request",
"and",
"return",
"it",
".",
"Monitor",
"might",
"have",
"been",
"reset",
"due",
"to",
"view",
"change",
"due",
"to",
"which",
"this",
"method",
"returns",
"None"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L353-L400 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.requestUnOrdered | def requestUnOrdered(self, key: str):
"""
Record the time at which request ordering started.
"""
now = time.perf_counter()
if self.acc_monitor:
self.acc_monitor.update_time(now)
self.acc_monitor.request_received(key)
self.requestTracker.start(key, ... | python | def requestUnOrdered(self, key: str):
"""
Record the time at which request ordering started.
"""
now = time.perf_counter()
if self.acc_monitor:
self.acc_monitor.update_time(now)
self.acc_monitor.request_received(key)
self.requestTracker.start(key, ... | [
"def",
"requestUnOrdered",
"(",
"self",
",",
"key",
":",
"str",
")",
":",
"now",
"=",
"time",
".",
"perf_counter",
"(",
")",
"if",
"self",
".",
"acc_monitor",
":",
"self",
".",
"acc_monitor",
".",
"update_time",
"(",
"now",
")",
"self",
".",
"acc_monit... | Record the time at which request ordering started. | [
"Record",
"the",
"time",
"at",
"which",
"request",
"ordering",
"started",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L402-L410 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.isMasterDegraded | def isMasterDegraded(self):
"""
Return whether the master instance is slow.
"""
if self.acc_monitor:
self.acc_monitor.update_time(time.perf_counter())
return self.acc_monitor.is_master_degraded()
else:
return (self.instances.masterId is not Non... | python | def isMasterDegraded(self):
"""
Return whether the master instance is slow.
"""
if self.acc_monitor:
self.acc_monitor.update_time(time.perf_counter())
return self.acc_monitor.is_master_degraded()
else:
return (self.instances.masterId is not Non... | [
"def",
"isMasterDegraded",
"(",
"self",
")",
":",
"if",
"self",
".",
"acc_monitor",
":",
"self",
".",
"acc_monitor",
".",
"update_time",
"(",
"time",
".",
"perf_counter",
"(",
")",
")",
"return",
"self",
".",
"acc_monitor",
".",
"is_master_degraded",
"(",
... | Return whether the master instance is slow. | [
"Return",
"whether",
"the",
"master",
"instance",
"is",
"slow",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L425-L439 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.areBackupsDegraded | def areBackupsDegraded(self):
"""
Return slow instance.
"""
slow_instances = []
if self.acc_monitor:
for instance in self.instances.backupIds:
if self.acc_monitor.is_instance_degraded(instance):
slow_instances.append(instance)
... | python | def areBackupsDegraded(self):
"""
Return slow instance.
"""
slow_instances = []
if self.acc_monitor:
for instance in self.instances.backupIds:
if self.acc_monitor.is_instance_degraded(instance):
slow_instances.append(instance)
... | [
"def",
"areBackupsDegraded",
"(",
"self",
")",
":",
"slow_instances",
"=",
"[",
"]",
"if",
"self",
".",
"acc_monitor",
":",
"for",
"instance",
"in",
"self",
".",
"instances",
".",
"backupIds",
":",
"if",
"self",
".",
"acc_monitor",
".",
"is_instance_degraded... | Return slow instance. | [
"Return",
"slow",
"instance",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L441-L454 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.instance_throughput_ratio | def instance_throughput_ratio(self, inst_id):
"""
The relative throughput of an instance compared to the backup
instances.
"""
inst_thrp, otherThrp = self.getThroughputs(inst_id)
# Backup throughput may be 0 so moving ahead only if it is not 0
r = inst_thrp / oth... | python | def instance_throughput_ratio(self, inst_id):
"""
The relative throughput of an instance compared to the backup
instances.
"""
inst_thrp, otherThrp = self.getThroughputs(inst_id)
# Backup throughput may be 0 so moving ahead only if it is not 0
r = inst_thrp / oth... | [
"def",
"instance_throughput_ratio",
"(",
"self",
",",
"inst_id",
")",
":",
"inst_thrp",
",",
"otherThrp",
"=",
"self",
".",
"getThroughputs",
"(",
"inst_id",
")",
"r",
"=",
"inst_thrp",
"/",
"otherThrp",
"if",
"otherThrp",
"and",
"inst_thrp",
"is",
"not",
"N... | The relative throughput of an instance compared to the backup
instances. | [
"The",
"relative",
"throughput",
"of",
"an",
"instance",
"compared",
"to",
"the",
"backup",
"instances",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L456-L466 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.is_instance_throughput_too_low | def is_instance_throughput_too_low(self, inst_id):
"""
Return whether the throughput of the master instance is greater than the
acceptable threshold
"""
r = self.instance_throughput_ratio(inst_id)
if r is None:
logger.debug("{} instance {} throughput is not "
... | python | def is_instance_throughput_too_low(self, inst_id):
"""
Return whether the throughput of the master instance is greater than the
acceptable threshold
"""
r = self.instance_throughput_ratio(inst_id)
if r is None:
logger.debug("{} instance {} throughput is not "
... | [
"def",
"is_instance_throughput_too_low",
"(",
"self",
",",
"inst_id",
")",
":",
"r",
"=",
"self",
".",
"instance_throughput_ratio",
"(",
"inst_id",
")",
"if",
"r",
"is",
"None",
":",
"logger",
".",
"debug",
"(",
"\"{} instance {} throughput is not \"",
"\"measurab... | Return whether the throughput of the master instance is greater than the
acceptable threshold | [
"Return",
"whether",
"the",
"throughput",
"of",
"the",
"master",
"instance",
"is",
"greater",
"than",
"the",
"acceptable",
"threshold"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L475-L492 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.isMasterReqLatencyTooHigh | def isMasterReqLatencyTooHigh(self):
"""
Return whether the request latency of the master instance is greater
than the acceptable threshold
"""
# TODO for now, view_change procedure can take more that 15 minutes
# (5 minutes for catchup and 10 minutes for primary's answer... | python | def isMasterReqLatencyTooHigh(self):
"""
Return whether the request latency of the master instance is greater
than the acceptable threshold
"""
# TODO for now, view_change procedure can take more that 15 minutes
# (5 minutes for catchup and 10 minutes for primary's answer... | [
"def",
"isMasterReqLatencyTooHigh",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"masterReqLatencyTooHigh",
"or",
"next",
"(",
"(",
"(",
"key",
",",
"lat",
")",
"for",
"key",
",",
"lat",
"in",
"self",
".",
"masterReqLatencies",
".",
"items",
"(",
")",
... | Return whether the request latency of the master instance is greater
than the acceptable threshold | [
"Return",
"whether",
"the",
"request",
"latency",
"of",
"the",
"master",
"instance",
"is",
"greater",
"than",
"the",
"acceptable",
"threshold"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L494-L512 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.is_instance_avg_req_latency_too_high | def is_instance_avg_req_latency_too_high(self, inst_id):
"""
Return whether the average request latency of an instance is
greater than the acceptable threshold
"""
avg_lat, avg_lat_others = self.getLatencies()
if not avg_lat or not avg_lat_others:
return False... | python | def is_instance_avg_req_latency_too_high(self, inst_id):
"""
Return whether the average request latency of an instance is
greater than the acceptable threshold
"""
avg_lat, avg_lat_others = self.getLatencies()
if not avg_lat or not avg_lat_others:
return False... | [
"def",
"is_instance_avg_req_latency_too_high",
"(",
"self",
",",
"inst_id",
")",
":",
"avg_lat",
",",
"avg_lat_others",
"=",
"self",
".",
"getLatencies",
"(",
")",
"if",
"not",
"avg_lat",
"or",
"not",
"avg_lat_others",
":",
"return",
"False",
"d",
"=",
"avg_la... | Return whether the average request latency of an instance is
greater than the acceptable threshold | [
"Return",
"whether",
"the",
"average",
"request",
"latency",
"of",
"an",
"instance",
"is",
"greater",
"than",
"the",
"acceptable",
"threshold"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L521-L541 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.getThroughputs | def getThroughputs(self, desired_inst_id: int):
"""
Return a tuple of the throughput of the given instance and the average
throughput of the remaining instances.
:param instId: the id of the protocol instance
"""
instance_thrp = self.getThroughput(desired_inst_id)
... | python | def getThroughputs(self, desired_inst_id: int):
"""
Return a tuple of the throughput of the given instance and the average
throughput of the remaining instances.
:param instId: the id of the protocol instance
"""
instance_thrp = self.getThroughput(desired_inst_id)
... | [
"def",
"getThroughputs",
"(",
"self",
",",
"desired_inst_id",
":",
"int",
")",
":",
"instance_thrp",
"=",
"self",
".",
"getThroughput",
"(",
"desired_inst_id",
")",
"totalReqs",
",",
"totalTm",
"=",
"self",
".",
"getInstanceMetrics",
"(",
"forAllExcept",
"=",
... | Return a tuple of the throughput of the given instance and the average
throughput of the remaining instances.
:param instId: the id of the protocol instance | [
"Return",
"a",
"tuple",
"of",
"the",
"throughput",
"of",
"the",
"given",
"instance",
"and",
"the",
"average",
"throughput",
"of",
"the",
"remaining",
"instances",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L543-L577 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.getThroughput | def getThroughput(self, instId: int) -> float:
"""
Return the throughput of the specified instance.
:param instId: the id of the protocol instance
"""
# We are using the instanceStarted time in the denominator instead of
# a time interval. This is alright for now as all ... | python | def getThroughput(self, instId: int) -> float:
"""
Return the throughput of the specified instance.
:param instId: the id of the protocol instance
"""
# We are using the instanceStarted time in the denominator instead of
# a time interval. This is alright for now as all ... | [
"def",
"getThroughput",
"(",
"self",
",",
"instId",
":",
"int",
")",
"->",
"float",
":",
"if",
"instId",
"not",
"in",
"self",
".",
"instances",
".",
"ids",
":",
"return",
"None",
"perf_time",
"=",
"time",
".",
"perf_counter",
"(",
")",
"throughput",
"=... | Return the throughput of the specified instance.
:param instId: the id of the protocol instance | [
"Return",
"the",
"throughput",
"of",
"the",
"specified",
"instance",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L579-L592 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.getInstanceMetrics | def getInstanceMetrics(
self, forAllExcept: int) -> Tuple[Optional[int], Optional[float]]:
"""
Calculate and return the average throughput of all the instances except
the one specified as `forAllExcept`.
"""
m = [(reqs, tm) for i, (reqs, tm)
in self.numOr... | python | def getInstanceMetrics(
self, forAllExcept: int) -> Tuple[Optional[int], Optional[float]]:
"""
Calculate and return the average throughput of all the instances except
the one specified as `forAllExcept`.
"""
m = [(reqs, tm) for i, (reqs, tm)
in self.numOr... | [
"def",
"getInstanceMetrics",
"(",
"self",
",",
"forAllExcept",
":",
"int",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"int",
"]",
",",
"Optional",
"[",
"float",
"]",
"]",
":",
"m",
"=",
"[",
"(",
"reqs",
",",
"tm",
")",
"for",
"i",
",",
"(",
"reqs... | Calculate and return the average throughput of all the instances except
the one specified as `forAllExcept`. | [
"Calculate",
"and",
"return",
"the",
"average",
"throughput",
"of",
"all",
"the",
"instances",
"except",
"the",
"one",
"specified",
"as",
"forAllExcept",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L594-L607 | train |
hyperledger/indy-plenum | plenum/server/monitor.py | Monitor.getLatency | def getLatency(self, instId: int) -> float:
"""
Return a dict with client identifier as a key and calculated latency as a value
"""
if len(self.clientAvgReqLatencies) == 0:
return 0.0
return self.clientAvgReqLatencies[instId].get_avg_latency() | python | def getLatency(self, instId: int) -> float:
"""
Return a dict with client identifier as a key and calculated latency as a value
"""
if len(self.clientAvgReqLatencies) == 0:
return 0.0
return self.clientAvgReqLatencies[instId].get_avg_latency() | [
"def",
"getLatency",
"(",
"self",
",",
"instId",
":",
"int",
")",
"->",
"float",
":",
"if",
"len",
"(",
"self",
".",
"clientAvgReqLatencies",
")",
"==",
"0",
":",
"return",
"0.0",
"return",
"self",
".",
"clientAvgReqLatencies",
"[",
"instId",
"]",
".",
... | Return a dict with client identifier as a key and calculated latency as a value | [
"Return",
"a",
"dict",
"with",
"client",
"identifier",
"as",
"a",
"key",
"and",
"calculated",
"latency",
"as",
"a",
"value"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/monitor.py#L624-L630 | train |
hyperledger/indy-plenum | plenum/common/batched.py | Batched._enqueue | def _enqueue(self, msg: Any, rid: int, signer: Signer) -> None:
"""
Enqueue the message into the remote's queue.
:param msg: the message to enqueue
:param rid: the id of the remote node
"""
if rid not in self.outBoxes:
self.outBoxes[rid] = deque()
sel... | python | def _enqueue(self, msg: Any, rid: int, signer: Signer) -> None:
"""
Enqueue the message into the remote's queue.
:param msg: the message to enqueue
:param rid: the id of the remote node
"""
if rid not in self.outBoxes:
self.outBoxes[rid] = deque()
sel... | [
"def",
"_enqueue",
"(",
"self",
",",
"msg",
":",
"Any",
",",
"rid",
":",
"int",
",",
"signer",
":",
"Signer",
")",
"->",
"None",
":",
"if",
"rid",
"not",
"in",
"self",
".",
"outBoxes",
":",
"self",
".",
"outBoxes",
"[",
"rid",
"]",
"=",
"deque",
... | Enqueue the message into the remote's queue.
:param msg: the message to enqueue
:param rid: the id of the remote node | [
"Enqueue",
"the",
"message",
"into",
"the",
"remote",
"s",
"queue",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/batched.py#L36-L45 | train |
hyperledger/indy-plenum | plenum/common/batched.py | Batched._enqueueIntoAllRemotes | def _enqueueIntoAllRemotes(self, msg: Any, signer: Signer) -> None:
"""
Enqueue the specified message into all the remotes in the nodestack.
:param msg: the message to enqueue
"""
for rid in self.remotes.keys():
self._enqueue(msg, rid, signer) | python | def _enqueueIntoAllRemotes(self, msg: Any, signer: Signer) -> None:
"""
Enqueue the specified message into all the remotes in the nodestack.
:param msg: the message to enqueue
"""
for rid in self.remotes.keys():
self._enqueue(msg, rid, signer) | [
"def",
"_enqueueIntoAllRemotes",
"(",
"self",
",",
"msg",
":",
"Any",
",",
"signer",
":",
"Signer",
")",
"->",
"None",
":",
"for",
"rid",
"in",
"self",
".",
"remotes",
".",
"keys",
"(",
")",
":",
"self",
".",
"_enqueue",
"(",
"msg",
",",
"rid",
","... | Enqueue the specified message into all the remotes in the nodestack.
:param msg: the message to enqueue | [
"Enqueue",
"the",
"specified",
"message",
"into",
"all",
"the",
"remotes",
"in",
"the",
"nodestack",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/batched.py#L47-L54 | train |
hyperledger/indy-plenum | plenum/common/batched.py | Batched.send | def send(self,
msg: Any, *
rids: Iterable[int],
signer: Signer = None,
message_splitter=None) -> None:
"""
Enqueue the given message into the outBoxes of the specified remotes
or into the outBoxes of all the remotes if rids is None
:pa... | python | def send(self,
msg: Any, *
rids: Iterable[int],
signer: Signer = None,
message_splitter=None) -> None:
"""
Enqueue the given message into the outBoxes of the specified remotes
or into the outBoxes of all the remotes if rids is None
:pa... | [
"def",
"send",
"(",
"self",
",",
"msg",
":",
"Any",
",",
"*",
"rids",
":",
"Iterable",
"[",
"int",
"]",
",",
"signer",
":",
"Signer",
"=",
"None",
",",
"message_splitter",
"=",
"None",
")",
"->",
"None",
":",
"message_parts",
",",
"err_msg",
"=",
"... | Enqueue the given message into the outBoxes of the specified remotes
or into the outBoxes of all the remotes if rids is None
:param msg: the message to enqueue
:param rids: ids of the remotes to whose outBoxes
this message must be enqueued
:param message_splitter: callable t... | [
"Enqueue",
"the",
"given",
"message",
"into",
"the",
"outBoxes",
"of",
"the",
"specified",
"remotes",
"or",
"into",
"the",
"outBoxes",
"of",
"all",
"the",
"remotes",
"if",
"rids",
"is",
"None"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/batched.py#L56-L88 | train |
hyperledger/indy-plenum | plenum/common/batched.py | Batched.flushOutBoxes | def flushOutBoxes(self) -> None:
"""
Clear the outBoxes and transmit batched messages to remotes.
"""
removedRemotes = []
for rid, msgs in self.outBoxes.items():
try:
dest = self.remotes[rid].name
except KeyError:
removedRem... | python | def flushOutBoxes(self) -> None:
"""
Clear the outBoxes and transmit batched messages to remotes.
"""
removedRemotes = []
for rid, msgs in self.outBoxes.items():
try:
dest = self.remotes[rid].name
except KeyError:
removedRem... | [
"def",
"flushOutBoxes",
"(",
"self",
")",
"->",
"None",
":",
"removedRemotes",
"=",
"[",
"]",
"for",
"rid",
",",
"msgs",
"in",
"self",
".",
"outBoxes",
".",
"items",
"(",
")",
":",
"try",
":",
"dest",
"=",
"self",
".",
"remotes",
"[",
"rid",
"]",
... | Clear the outBoxes and transmit batched messages to remotes. | [
"Clear",
"the",
"outBoxes",
"and",
"transmit",
"batched",
"messages",
"to",
"remotes",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/batched.py#L90-L147 | train |
hyperledger/indy-plenum | stp_core/loop/looper.py | Looper.prodAllOnce | async def prodAllOnce(self):
"""
Call `prod` once for each Prodable in this Looper
:return: the sum of the number of events executed successfully
"""
# TODO: looks like limit is always None???
limit = None
s = 0
for n in self.prodables:
s += a... | python | async def prodAllOnce(self):
"""
Call `prod` once for each Prodable in this Looper
:return: the sum of the number of events executed successfully
"""
# TODO: looks like limit is always None???
limit = None
s = 0
for n in self.prodables:
s += a... | [
"async",
"def",
"prodAllOnce",
"(",
"self",
")",
":",
"limit",
"=",
"None",
"s",
"=",
"0",
"for",
"n",
"in",
"self",
".",
"prodables",
":",
"s",
"+=",
"await",
"n",
".",
"prod",
"(",
"limit",
")",
"return",
"s"
] | Call `prod` once for each Prodable in this Looper
:return: the sum of the number of events executed successfully | [
"Call",
"prod",
"once",
"for",
"each",
"Prodable",
"in",
"this",
"Looper"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/looper.py#L142-L153 | train |
hyperledger/indy-plenum | stp_core/loop/looper.py | Looper.add | def add(self, prodable: Prodable) -> None:
"""
Add one Prodable object to this Looper's list of Prodables
:param prodable: the Prodable object to add
"""
if prodable.name in [p.name for p in self.prodables]:
raise ProdableAlreadyAdded("Prodable {} already added.".
... | python | def add(self, prodable: Prodable) -> None:
"""
Add one Prodable object to this Looper's list of Prodables
:param prodable: the Prodable object to add
"""
if prodable.name in [p.name for p in self.prodables]:
raise ProdableAlreadyAdded("Prodable {} already added.".
... | [
"def",
"add",
"(",
"self",
",",
"prodable",
":",
"Prodable",
")",
"->",
"None",
":",
"if",
"prodable",
".",
"name",
"in",
"[",
"p",
".",
"name",
"for",
"p",
"in",
"self",
".",
"prodables",
"]",
":",
"raise",
"ProdableAlreadyAdded",
"(",
"\"Prodable {} ... | Add one Prodable object to this Looper's list of Prodables
:param prodable: the Prodable object to add | [
"Add",
"one",
"Prodable",
"object",
"to",
"this",
"Looper",
"s",
"list",
"of",
"Prodables"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/looper.py#L155-L166 | train |
hyperledger/indy-plenum | stp_core/loop/looper.py | Looper.removeProdable | def removeProdable(self, prodable: Prodable=None, name: str=None) -> Optional[Prodable]:
"""
Remove the specified Prodable object from this Looper's list of Prodables
:param prodable: the Prodable to remove
"""
if prodable:
self.prodables.remove(prodable)
... | python | def removeProdable(self, prodable: Prodable=None, name: str=None) -> Optional[Prodable]:
"""
Remove the specified Prodable object from this Looper's list of Prodables
:param prodable: the Prodable to remove
"""
if prodable:
self.prodables.remove(prodable)
... | [
"def",
"removeProdable",
"(",
"self",
",",
"prodable",
":",
"Prodable",
"=",
"None",
",",
"name",
":",
"str",
"=",
"None",
")",
"->",
"Optional",
"[",
"Prodable",
"]",
":",
"if",
"prodable",
":",
"self",
".",
"prodables",
".",
"remove",
"(",
"prodable"... | Remove the specified Prodable object from this Looper's list of Prodables
:param prodable: the Prodable to remove | [
"Remove",
"the",
"specified",
"Prodable",
"object",
"from",
"this",
"Looper",
"s",
"list",
"of",
"Prodables"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/looper.py#L168-L189 | train |
hyperledger/indy-plenum | stp_core/loop/looper.py | Looper.runOnceNicely | async def runOnceNicely(self):
"""
Execute `runOnce` with a small tolerance of 0.01 seconds so that the Prodables
can complete their other asynchronous tasks not running on the event-loop.
"""
start = time.perf_counter()
msgsProcessed = await self.prodAllOnce()
if... | python | async def runOnceNicely(self):
"""
Execute `runOnce` with a small tolerance of 0.01 seconds so that the Prodables
can complete their other asynchronous tasks not running on the event-loop.
"""
start = time.perf_counter()
msgsProcessed = await self.prodAllOnce()
if... | [
"async",
"def",
"runOnceNicely",
"(",
"self",
")",
":",
"start",
"=",
"time",
".",
"perf_counter",
"(",
")",
"msgsProcessed",
"=",
"await",
"self",
".",
"prodAllOnce",
"(",
")",
"if",
"msgsProcessed",
"==",
"0",
":",
"await",
"asyncio",
".",
"sleep",
"("... | Execute `runOnce` with a small tolerance of 0.01 seconds so that the Prodables
can complete their other asynchronous tasks not running on the event-loop. | [
"Execute",
"runOnce",
"with",
"a",
"small",
"tolerance",
"of",
"0",
".",
"01",
"seconds",
"so",
"that",
"the",
"Prodables",
"can",
"complete",
"their",
"other",
"asynchronous",
"tasks",
"not",
"running",
"on",
"the",
"event",
"-",
"loop",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/looper.py#L204-L217 | train |
hyperledger/indy-plenum | stp_core/loop/looper.py | Looper.run | def run(self, *coros: CoroWrapper):
"""
Runs an arbitrary list of coroutines in order and then quits the loop,
if not running as a context manager.
"""
if not self.running:
raise RuntimeError("not running!")
async def wrapper():
results = []
... | python | def run(self, *coros: CoroWrapper):
"""
Runs an arbitrary list of coroutines in order and then quits the loop,
if not running as a context manager.
"""
if not self.running:
raise RuntimeError("not running!")
async def wrapper():
results = []
... | [
"def",
"run",
"(",
"self",
",",
"*",
"coros",
":",
"CoroWrapper",
")",
":",
"if",
"not",
"self",
".",
"running",
":",
"raise",
"RuntimeError",
"(",
"\"not running!\"",
")",
"async",
"def",
"wrapper",
"(",
")",
":",
"results",
"=",
"[",
"]",
"for",
"c... | Runs an arbitrary list of coroutines in order and then quits the loop,
if not running as a context manager. | [
"Runs",
"an",
"arbitrary",
"list",
"of",
"coroutines",
"in",
"order",
"and",
"then",
"quits",
"the",
"loop",
"if",
"not",
"running",
"as",
"a",
"context",
"manager",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/looper.py#L229-L263 | train |
hyperledger/indy-plenum | stp_core/loop/looper.py | Looper.shutdown | async def shutdown(self):
"""
Shut down this Looper.
"""
logger.display("Looper shutting down now...", extra={"cli": False})
self.running = False
start = time.perf_counter()
if not self.runFut.done():
await self.runFut
self.stopall()
lo... | python | async def shutdown(self):
"""
Shut down this Looper.
"""
logger.display("Looper shutting down now...", extra={"cli": False})
self.running = False
start = time.perf_counter()
if not self.runFut.done():
await self.runFut
self.stopall()
lo... | [
"async",
"def",
"shutdown",
"(",
"self",
")",
":",
"logger",
".",
"display",
"(",
"\"Looper shutting down now...\"",
",",
"extra",
"=",
"{",
"\"cli\"",
":",
"False",
"}",
")",
"self",
".",
"running",
"=",
"False",
"start",
"=",
"time",
".",
"perf_counter",... | Shut down this Looper. | [
"Shut",
"down",
"this",
"Looper",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/loop/looper.py#L271-L287 | train |
hyperledger/indy-plenum | plenum/bls/bls_bft_factory.py | create_default_bls_bft_factory | def create_default_bls_bft_factory(node):
'''
Creates a default BLS factory to instantiate BLS BFT classes.
:param node: Node instance
:return: BLS factory instance
'''
bls_keys_dir = os.path.join(node.keys_dir, node.name)
bls_crypto_factory = create_default_bls_crypto_factory(bls_keys_dir)... | python | def create_default_bls_bft_factory(node):
'''
Creates a default BLS factory to instantiate BLS BFT classes.
:param node: Node instance
:return: BLS factory instance
'''
bls_keys_dir = os.path.join(node.keys_dir, node.name)
bls_crypto_factory = create_default_bls_crypto_factory(bls_keys_dir)... | [
"def",
"create_default_bls_bft_factory",
"(",
"node",
")",
":",
"bls_keys_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"node",
".",
"keys_dir",
",",
"node",
".",
"name",
")",
"bls_crypto_factory",
"=",
"create_default_bls_crypto_factory",
"(",
"bls_keys_dir",
... | Creates a default BLS factory to instantiate BLS BFT classes.
:param node: Node instance
:return: BLS factory instance | [
"Creates",
"a",
"default",
"BLS",
"factory",
"to",
"instantiate",
"BLS",
"BFT",
"classes",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/bls/bls_bft_factory.py#L32-L41 | train |
hyperledger/indy-plenum | stp_core/crypto/nacl_wrappers.py | SigningKey.sign | def sign(self, message, encoder=encoding.RawEncoder):
"""
Sign a message using this key.
:param message: [:class:`bytes`] The data to be signed.
:param encoder: A class that is used to encode the signed message.
:rtype: :class:`~SignedMessage`
"""
raw_signed = li... | python | def sign(self, message, encoder=encoding.RawEncoder):
"""
Sign a message using this key.
:param message: [:class:`bytes`] The data to be signed.
:param encoder: A class that is used to encode the signed message.
:rtype: :class:`~SignedMessage`
"""
raw_signed = li... | [
"def",
"sign",
"(",
"self",
",",
"message",
",",
"encoder",
"=",
"encoding",
".",
"RawEncoder",
")",
":",
"raw_signed",
"=",
"libnacl",
".",
"crypto_sign",
"(",
"message",
",",
"self",
".",
"_signing_key",
")",
"signature",
"=",
"encoder",
".",
"encode",
... | Sign a message using this key.
:param message: [:class:`bytes`] The data to be signed.
:param encoder: A class that is used to encode the signed message.
:rtype: :class:`~SignedMessage` | [
"Sign",
"a",
"message",
"using",
"this",
"key",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L162-L176 | train |
hyperledger/indy-plenum | stp_core/crypto/nacl_wrappers.py | Verifier.verify | def verify(self, signature, msg):
'''
Verify the message
'''
if not self.key:
return False
try:
self.key.verify(signature + msg)
except ValueError:
return False
return True | python | def verify(self, signature, msg):
'''
Verify the message
'''
if not self.key:
return False
try:
self.key.verify(signature + msg)
except ValueError:
return False
return True | [
"def",
"verify",
"(",
"self",
",",
"signature",
",",
"msg",
")",
":",
"if",
"not",
"self",
".",
"key",
":",
"return",
"False",
"try",
":",
"self",
".",
"key",
".",
"verify",
"(",
"signature",
"+",
"msg",
")",
"except",
"ValueError",
":",
"return",
... | Verify the message | [
"Verify",
"the",
"message"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L232-L242 | train |
hyperledger/indy-plenum | stp_core/crypto/nacl_wrappers.py | Box.encrypt | def encrypt(self, plaintext, nonce, encoder=encoding.RawEncoder):
"""
Encrypts the plaintext message using the given `nonce` and returns
the ciphertext encoded with the encoder.
.. warning:: It is **VITALLY** important that the nonce is a nonce,
i.e. it is a number used only... | python | def encrypt(self, plaintext, nonce, encoder=encoding.RawEncoder):
"""
Encrypts the plaintext message using the given `nonce` and returns
the ciphertext encoded with the encoder.
.. warning:: It is **VITALLY** important that the nonce is a nonce,
i.e. it is a number used only... | [
"def",
"encrypt",
"(",
"self",
",",
"plaintext",
",",
"nonce",
",",
"encoder",
"=",
"encoding",
".",
"RawEncoder",
")",
":",
"if",
"len",
"(",
"nonce",
")",
"!=",
"self",
".",
"NONCE_SIZE",
":",
"raise",
"ValueError",
"(",
"\"The nonce must be exactly %s byt... | Encrypts the plaintext message using the given `nonce` and returns
the ciphertext encoded with the encoder.
.. warning:: It is **VITALLY** important that the nonce is a nonce,
i.e. it is a number used only once for any given key. If you fail
to do this, you compromise the privac... | [
"Encrypts",
"the",
"plaintext",
"message",
"using",
"the",
"given",
"nonce",
"and",
"returns",
"the",
"ciphertext",
"encoded",
"with",
"the",
"encoder",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L357-L388 | train |
hyperledger/indy-plenum | stp_core/crypto/nacl_wrappers.py | Box.decrypt | def decrypt(self, ciphertext, nonce=None, encoder=encoding.RawEncoder):
"""
Decrypts the ciphertext using the given nonce and returns the
plaintext message.
:param ciphertext: [:class:`bytes`] The encrypted message to decrypt
:param nonce: [:class:`bytes`] The nonce used when en... | python | def decrypt(self, ciphertext, nonce=None, encoder=encoding.RawEncoder):
"""
Decrypts the ciphertext using the given nonce and returns the
plaintext message.
:param ciphertext: [:class:`bytes`] The encrypted message to decrypt
:param nonce: [:class:`bytes`] The nonce used when en... | [
"def",
"decrypt",
"(",
"self",
",",
"ciphertext",
",",
"nonce",
"=",
"None",
",",
"encoder",
"=",
"encoding",
".",
"RawEncoder",
")",
":",
"ciphertext",
"=",
"encoder",
".",
"decode",
"(",
"ciphertext",
")",
"if",
"nonce",
"is",
"None",
":",
"nonce",
"... | Decrypts the ciphertext using the given nonce and returns the
plaintext message.
:param ciphertext: [:class:`bytes`] The encrypted message to decrypt
:param nonce: [:class:`bytes`] The nonce used when encrypting the
ciphertext
:param encoder: The encoder used to decode the c... | [
"Decrypts",
"the",
"ciphertext",
"using",
"the",
"given",
"nonce",
"and",
"returns",
"the",
"plaintext",
"message",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L390-L419 | train |
hyperledger/indy-plenum | stp_core/crypto/nacl_wrappers.py | Privateer.decrypt | def decrypt(self, cipher, nonce, pubkey, dehex=False):
'''
Return decrypted msg contained in cypher using nonce and shared key
generated from .key and pubkey.
If pubkey is hex encoded it is converted first
If dehex is True then use HexEncoder otherwise use RawEncoder
Int... | python | def decrypt(self, cipher, nonce, pubkey, dehex=False):
'''
Return decrypted msg contained in cypher using nonce and shared key
generated from .key and pubkey.
If pubkey is hex encoded it is converted first
If dehex is True then use HexEncoder otherwise use RawEncoder
Int... | [
"def",
"decrypt",
"(",
"self",
",",
"cipher",
",",
"nonce",
",",
"pubkey",
",",
"dehex",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"pubkey",
",",
"PublicKey",
")",
":",
"if",
"len",
"(",
"pubkey",
")",
"==",
"32",
":",
"pubkey",
"=",
... | Return decrypted msg contained in cypher using nonce and shared key
generated from .key and pubkey.
If pubkey is hex encoded it is converted first
If dehex is True then use HexEncoder otherwise use RawEncoder
Intended for the owner of .key
cypher is string
nonce is stri... | [
"Return",
"decrypted",
"msg",
"contained",
"in",
"cypher",
"using",
"nonce",
"and",
"shared",
"key",
"generated",
"from",
".",
"key",
"and",
"pubkey",
".",
"If",
"pubkey",
"is",
"hex",
"encoded",
"it",
"is",
"converted",
"first",
"If",
"dehex",
"is",
"True... | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/crypto/nacl_wrappers.py#L496-L518 | train |
hyperledger/indy-plenum | plenum/common/config_util.py | getInstalledConfig | def getInstalledConfig(installDir, configFile):
"""
Reads config from the installation directory of Plenum.
:param installDir: installation directory of Plenum
:param configFile: name of the configuration file
:raises: FileNotFoundError
:return: the configuration as a python object
"""
... | python | def getInstalledConfig(installDir, configFile):
"""
Reads config from the installation directory of Plenum.
:param installDir: installation directory of Plenum
:param configFile: name of the configuration file
:raises: FileNotFoundError
:return: the configuration as a python object
"""
... | [
"def",
"getInstalledConfig",
"(",
"installDir",
",",
"configFile",
")",
":",
"configPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"installDir",
",",
"configFile",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"configPath",
")",
":",
"raise"... | Reads config from the installation directory of Plenum.
:param installDir: installation directory of Plenum
:param configFile: name of the configuration file
:raises: FileNotFoundError
:return: the configuration as a python object | [
"Reads",
"config",
"from",
"the",
"installation",
"directory",
"of",
"Plenum",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/config_util.py#L11-L27 | train |
hyperledger/indy-plenum | plenum/common/config_util.py | _getConfig | def _getConfig(general_config_dir: str = None):
"""
Reads a file called config.py in the project directory
:raises: FileNotFoundError
:return: the configuration as a python object
"""
stp_config = STPConfig()
plenum_config = import_module("plenum.config")
config = stp_config
config.... | python | def _getConfig(general_config_dir: str = None):
"""
Reads a file called config.py in the project directory
:raises: FileNotFoundError
:return: the configuration as a python object
"""
stp_config = STPConfig()
plenum_config = import_module("plenum.config")
config = stp_config
config.... | [
"def",
"_getConfig",
"(",
"general_config_dir",
":",
"str",
"=",
"None",
")",
":",
"stp_config",
"=",
"STPConfig",
"(",
")",
"plenum_config",
"=",
"import_module",
"(",
"\"plenum.config\"",
")",
"config",
"=",
"stp_config",
"config",
".",
"__dict__",
".",
"upd... | Reads a file called config.py in the project directory
:raises: FileNotFoundError
:return: the configuration as a python object | [
"Reads",
"a",
"file",
"called",
"config",
".",
"py",
"in",
"the",
"project",
"directory"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/config_util.py#L68-L95 | train |
hyperledger/indy-plenum | plenum/server/router.py | Router.getFunc | def getFunc(self, o: Any) -> Callable:
"""
Get the next function from the list of routes that is capable of
processing o's type.
:param o: the object to process
:return: the next function
"""
for cls, func in self.routes.items():
if isinstance(o, cls)... | python | def getFunc(self, o: Any) -> Callable:
"""
Get the next function from the list of routes that is capable of
processing o's type.
:param o: the object to process
:return: the next function
"""
for cls, func in self.routes.items():
if isinstance(o, cls)... | [
"def",
"getFunc",
"(",
"self",
",",
"o",
":",
"Any",
")",
"->",
"Callable",
":",
"for",
"cls",
",",
"func",
"in",
"self",
".",
"routes",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"cls",
")",
":",
"return",
"func",
"logger",
... | Get the next function from the list of routes that is capable of
processing o's type.
:param o: the object to process
:return: the next function | [
"Get",
"the",
"next",
"function",
"from",
"the",
"list",
"of",
"routes",
"that",
"is",
"capable",
"of",
"processing",
"o",
"s",
"type",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/router.py#L46-L60 | train |
hyperledger/indy-plenum | plenum/server/router.py | Router.handleSync | def handleSync(self, msg: Any) -> Any:
"""
Pass the message as an argument to the function defined in `routes`.
If the msg is a tuple, pass the values as multiple arguments to the function.
:param msg: tuple of object and callable
"""
# If a plain python tuple and not a ... | python | def handleSync(self, msg: Any) -> Any:
"""
Pass the message as an argument to the function defined in `routes`.
If the msg is a tuple, pass the values as multiple arguments to the function.
:param msg: tuple of object and callable
"""
# If a plain python tuple and not a ... | [
"def",
"handleSync",
"(",
"self",
",",
"msg",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"msg",
",",
"tuple",
")",
"and",
"len",
"(",
"msg",
")",
"==",
"2",
"and",
"not",
"hasattr",
"(",
"msg",
",",
"'_field_types'",
")",
":",
"r... | Pass the message as an argument to the function defined in `routes`.
If the msg is a tuple, pass the values as multiple arguments to the function.
:param msg: tuple of object and callable | [
"Pass",
"the",
"message",
"as",
"an",
"argument",
"to",
"the",
"function",
"defined",
"in",
"routes",
".",
"If",
"the",
"msg",
"is",
"a",
"tuple",
"pass",
"the",
"values",
"as",
"multiple",
"arguments",
"to",
"the",
"function",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/router.py#L63-L77 | train |
hyperledger/indy-plenum | plenum/server/router.py | Router.handle | async def handle(self, msg: Any) -> Any:
"""
Handle both sync and async functions.
:param msg: a message
:return: the result of execution of the function corresponding to this message's type
"""
res = self.handleSync(msg)
if isawaitable(res):
return a... | python | async def handle(self, msg: Any) -> Any:
"""
Handle both sync and async functions.
:param msg: a message
:return: the result of execution of the function corresponding to this message's type
"""
res = self.handleSync(msg)
if isawaitable(res):
return a... | [
"async",
"def",
"handle",
"(",
"self",
",",
"msg",
":",
"Any",
")",
"->",
"Any",
":",
"res",
"=",
"self",
".",
"handleSync",
"(",
"msg",
")",
"if",
"isawaitable",
"(",
"res",
")",
":",
"return",
"await",
"res",
"else",
":",
"return",
"res"
] | Handle both sync and async functions.
:param msg: a message
:return: the result of execution of the function corresponding to this message's type | [
"Handle",
"both",
"sync",
"and",
"async",
"functions",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/router.py#L79-L90 | train |
hyperledger/indy-plenum | plenum/server/router.py | Router.handleAll | async def handleAll(self, deq: deque, limit=None) -> int:
"""
Handle all items in a deque. Can call asynchronous handlers.
:param deq: a deque of items to be handled by this router
:param limit: the number of items in the deque to the handled
:return: the number of items handled... | python | async def handleAll(self, deq: deque, limit=None) -> int:
"""
Handle all items in a deque. Can call asynchronous handlers.
:param deq: a deque of items to be handled by this router
:param limit: the number of items in the deque to the handled
:return: the number of items handled... | [
"async",
"def",
"handleAll",
"(",
"self",
",",
"deq",
":",
"deque",
",",
"limit",
"=",
"None",
")",
"->",
"int",
":",
"count",
"=",
"0",
"while",
"deq",
"and",
"(",
"not",
"limit",
"or",
"count",
"<",
"limit",
")",
":",
"count",
"+=",
"1",
"item"... | Handle all items in a deque. Can call asynchronous handlers.
:param deq: a deque of items to be handled by this router
:param limit: the number of items in the deque to the handled
:return: the number of items handled successfully | [
"Handle",
"all",
"items",
"in",
"a",
"deque",
".",
"Can",
"call",
"asynchronous",
"handlers",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/router.py#L92-L105 | train |
hyperledger/indy-plenum | plenum/server/router.py | Router.handleAllSync | def handleAllSync(self, deq: deque, limit=None) -> int:
"""
Synchronously handle all items in a deque.
:param deq: a deque of items to be handled by this router
:param limit: the number of items in the deque to the handled
:return: the number of items handled successfully
... | python | def handleAllSync(self, deq: deque, limit=None) -> int:
"""
Synchronously handle all items in a deque.
:param deq: a deque of items to be handled by this router
:param limit: the number of items in the deque to the handled
:return: the number of items handled successfully
... | [
"def",
"handleAllSync",
"(",
"self",
",",
"deq",
":",
"deque",
",",
"limit",
"=",
"None",
")",
"->",
"int",
":",
"count",
"=",
"0",
"while",
"deq",
"and",
"(",
"not",
"limit",
"or",
"count",
"<",
"limit",
")",
":",
"count",
"+=",
"1",
"msg",
"=",... | Synchronously handle all items in a deque.
:param deq: a deque of items to be handled by this router
:param limit: the number of items in the deque to the handled
:return: the number of items handled successfully | [
"Synchronously",
"handle",
"all",
"items",
"in",
"a",
"deque",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/router.py#L107-L120 | train |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | CompactMerkleTree.load | def load(self, other: merkle_tree.MerkleTree):
"""Load this tree from a dumb data object for serialisation.
The object must have attributes tree_size:int and hashes:list.
"""
self._update(other.tree_size, other.hashes) | python | def load(self, other: merkle_tree.MerkleTree):
"""Load this tree from a dumb data object for serialisation.
The object must have attributes tree_size:int and hashes:list.
"""
self._update(other.tree_size, other.hashes) | [
"def",
"load",
"(",
"self",
",",
"other",
":",
"merkle_tree",
".",
"MerkleTree",
")",
":",
"self",
".",
"_update",
"(",
"other",
".",
"tree_size",
",",
"other",
".",
"hashes",
")"
] | Load this tree from a dumb data object for serialisation.
The object must have attributes tree_size:int and hashes:list. | [
"Load",
"this",
"tree",
"from",
"a",
"dumb",
"data",
"object",
"for",
"serialisation",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L47-L52 | train |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | CompactMerkleTree.save | def save(self, other: merkle_tree.MerkleTree):
"""Save this tree into a dumb data object for serialisation.
The object must have attributes tree_size:int and hashes:list.
"""
other.__tree_size = self.__tree_size
other.__hashes = self.__hashes | python | def save(self, other: merkle_tree.MerkleTree):
"""Save this tree into a dumb data object for serialisation.
The object must have attributes tree_size:int and hashes:list.
"""
other.__tree_size = self.__tree_size
other.__hashes = self.__hashes | [
"def",
"save",
"(",
"self",
",",
"other",
":",
"merkle_tree",
".",
"MerkleTree",
")",
":",
"other",
".",
"__tree_size",
"=",
"self",
".",
"__tree_size",
"other",
".",
"__hashes",
"=",
"self",
".",
"__hashes"
] | Save this tree into a dumb data object for serialisation.
The object must have attributes tree_size:int and hashes:list. | [
"Save",
"this",
"tree",
"into",
"a",
"dumb",
"data",
"object",
"for",
"serialisation",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L54-L60 | train |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | CompactMerkleTree.append | def append(self, new_leaf: bytes) -> List[bytes]:
"""Append a new leaf onto the end of this tree and return the
audit path"""
auditPath = list(reversed(self.__hashes))
self._push_subtree([new_leaf])
return auditPath | python | def append(self, new_leaf: bytes) -> List[bytes]:
"""Append a new leaf onto the end of this tree and return the
audit path"""
auditPath = list(reversed(self.__hashes))
self._push_subtree([new_leaf])
return auditPath | [
"def",
"append",
"(",
"self",
",",
"new_leaf",
":",
"bytes",
")",
"->",
"List",
"[",
"bytes",
"]",
":",
"auditPath",
"=",
"list",
"(",
"reversed",
"(",
"self",
".",
"__hashes",
")",
")",
"self",
".",
"_push_subtree",
"(",
"[",
"new_leaf",
"]",
")",
... | Append a new leaf onto the end of this tree and return the
audit path | [
"Append",
"a",
"new",
"leaf",
"onto",
"the",
"end",
"of",
"this",
"tree",
"and",
"return",
"the",
"audit",
"path"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L155-L160 | train |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | CompactMerkleTree.extend | def extend(self, new_leaves: List[bytes]):
"""Extend this tree with new_leaves on the end.
The algorithm works by using _push_subtree() as a primitive, calling
it with the maximum number of allowed leaves until we can add the
remaining leaves as a valid entire (non-full) subtree in one ... | python | def extend(self, new_leaves: List[bytes]):
"""Extend this tree with new_leaves on the end.
The algorithm works by using _push_subtree() as a primitive, calling
it with the maximum number of allowed leaves until we can add the
remaining leaves as a valid entire (non-full) subtree in one ... | [
"def",
"extend",
"(",
"self",
",",
"new_leaves",
":",
"List",
"[",
"bytes",
"]",
")",
":",
"size",
"=",
"len",
"(",
"new_leaves",
")",
"final_size",
"=",
"self",
".",
"tree_size",
"+",
"size",
"idx",
"=",
"0",
"while",
"True",
":",
"max_h",
"=",
"s... | Extend this tree with new_leaves on the end.
The algorithm works by using _push_subtree() as a primitive, calling
it with the maximum number of allowed leaves until we can add the
remaining leaves as a valid entire (non-full) subtree in one go. | [
"Extend",
"this",
"tree",
"with",
"new_leaves",
"on",
"the",
"end",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L162-L185 | train |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | CompactMerkleTree.extended | def extended(self, new_leaves: List[bytes]):
"""Returns a new tree equal to this tree extended with new_leaves."""
new_tree = self.__copy__()
new_tree.extend(new_leaves)
return new_tree | python | def extended(self, new_leaves: List[bytes]):
"""Returns a new tree equal to this tree extended with new_leaves."""
new_tree = self.__copy__()
new_tree.extend(new_leaves)
return new_tree | [
"def",
"extended",
"(",
"self",
",",
"new_leaves",
":",
"List",
"[",
"bytes",
"]",
")",
":",
"new_tree",
"=",
"self",
".",
"__copy__",
"(",
")",
"new_tree",
".",
"extend",
"(",
"new_leaves",
")",
"return",
"new_tree"
] | Returns a new tree equal to this tree extended with new_leaves. | [
"Returns",
"a",
"new",
"tree",
"equal",
"to",
"this",
"tree",
"extended",
"with",
"new_leaves",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L187-L191 | train |
hyperledger/indy-plenum | ledger/compact_merkle_tree.py | CompactMerkleTree.verify_consistency | def verify_consistency(self, expected_leaf_count) -> bool:
"""
Check that the tree has same leaf count as expected and the
number of nodes are also as expected
"""
if expected_leaf_count != self.leafCount:
raise ConsistencyVerificationFailed()
if self.get_expe... | python | def verify_consistency(self, expected_leaf_count) -> bool:
"""
Check that the tree has same leaf count as expected and the
number of nodes are also as expected
"""
if expected_leaf_count != self.leafCount:
raise ConsistencyVerificationFailed()
if self.get_expe... | [
"def",
"verify_consistency",
"(",
"self",
",",
"expected_leaf_count",
")",
"->",
"bool",
":",
"if",
"expected_leaf_count",
"!=",
"self",
".",
"leafCount",
":",
"raise",
"ConsistencyVerificationFailed",
"(",
")",
"if",
"self",
".",
"get_expected_node_count",
"(",
"... | Check that the tree has same leaf count as expected and the
number of nodes are also as expected | [
"Check",
"that",
"the",
"tree",
"has",
"same",
"leaf",
"count",
"as",
"expected",
"and",
"the",
"number",
"of",
"nodes",
"are",
"also",
"as",
"expected"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/compact_merkle_tree.py#L280-L289 | train |
hyperledger/indy-plenum | state/util/utils.py | isHex | def isHex(val: str) -> bool:
"""
Return whether the given str represents a hex value or not
:param val: the string to check
:return: whether the given str represents a hex value
"""
if isinstance(val, bytes):
# only decodes utf-8 string
try:
val = val.decode()
... | python | def isHex(val: str) -> bool:
"""
Return whether the given str represents a hex value or not
:param val: the string to check
:return: whether the given str represents a hex value
"""
if isinstance(val, bytes):
# only decodes utf-8 string
try:
val = val.decode()
... | [
"def",
"isHex",
"(",
"val",
":",
"str",
")",
"->",
"bool",
":",
"if",
"isinstance",
"(",
"val",
",",
"bytes",
")",
":",
"try",
":",
"val",
"=",
"val",
".",
"decode",
"(",
")",
"except",
"ValueError",
":",
"return",
"False",
"return",
"isinstance",
... | Return whether the given str represents a hex value or not
:param val: the string to check
:return: whether the given str represents a hex value | [
"Return",
"whether",
"the",
"given",
"str",
"represents",
"a",
"hex",
"value",
"or",
"not"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/state/util/utils.py#L80-L93 | train |
hyperledger/indy-plenum | plenum/common/latency_measurements.py | EMALatencyMeasurementForEachClient._accumulate | def _accumulate(self, old_accum, next_val):
"""
Implement exponential moving average
"""
return old_accum * (1 - self.alpha) + next_val * self.alpha | python | def _accumulate(self, old_accum, next_val):
"""
Implement exponential moving average
"""
return old_accum * (1 - self.alpha) + next_val * self.alpha | [
"def",
"_accumulate",
"(",
"self",
",",
"old_accum",
",",
"next_val",
")",
":",
"return",
"old_accum",
"*",
"(",
"1",
"-",
"self",
".",
"alpha",
")",
"+",
"next_val",
"*",
"self",
".",
"alpha"
] | Implement exponential moving average | [
"Implement",
"exponential",
"moving",
"average"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/common/latency_measurements.py#L36-L40 | train |
hyperledger/indy-plenum | ledger/hash_stores/hash_store.py | HashStore.getNodePosition | def getNodePosition(cls, start, height=None) -> int:
"""
Calculates node position based on start and height
:param start: The sequence number of the first leaf under this tree.
:param height: Height of this node in the merkle tree
:return: the node's position
"""
... | python | def getNodePosition(cls, start, height=None) -> int:
"""
Calculates node position based on start and height
:param start: The sequence number of the first leaf under this tree.
:param height: Height of this node in the merkle tree
:return: the node's position
"""
... | [
"def",
"getNodePosition",
"(",
"cls",
",",
"start",
",",
"height",
"=",
"None",
")",
"->",
"int",
":",
"pwr",
"=",
"highest_bit_set",
"(",
"start",
")",
"-",
"1",
"height",
"=",
"height",
"or",
"pwr",
"if",
"count_bits_set",
"(",
"start",
")",
"==",
... | Calculates node position based on start and height
:param start: The sequence number of the first leaf under this tree.
:param height: Height of this node in the merkle tree
:return: the node's position | [
"Calculates",
"node",
"position",
"based",
"on",
"start",
"and",
"height"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/hash_stores/hash_store.py#L88-L104 | train |
hyperledger/indy-plenum | ledger/hash_stores/hash_store.py | HashStore.getPath | def getPath(cls, seqNo, offset=0):
"""
Get the audit path of the leaf at the position specified by serNo.
:param seqNo: sequence number of the leaf to calculate the path for
:param offset: the sequence number of the node from where the path
should begin.
:return: tuple ... | python | def getPath(cls, seqNo, offset=0):
"""
Get the audit path of the leaf at the position specified by serNo.
:param seqNo: sequence number of the leaf to calculate the path for
:param offset: the sequence number of the node from where the path
should begin.
:return: tuple ... | [
"def",
"getPath",
"(",
"cls",
",",
"seqNo",
",",
"offset",
"=",
"0",
")",
":",
"if",
"offset",
">=",
"seqNo",
":",
"raise",
"ValueError",
"(",
"\"Offset should be less than serial number\"",
")",
"pwr",
"=",
"highest_bit_set",
"(",
"seqNo",
"-",
"1",
"-",
... | Get the audit path of the leaf at the position specified by serNo.
:param seqNo: sequence number of the leaf to calculate the path for
:param offset: the sequence number of the node from where the path
should begin.
:return: tuple of leafs and nodes | [
"Get",
"the",
"audit",
"path",
"of",
"the",
"leaf",
"at",
"the",
"position",
"specified",
"by",
"serNo",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/hash_stores/hash_store.py#L107-L127 | train |
hyperledger/indy-plenum | ledger/hash_stores/hash_store.py | HashStore.readNodeByTree | def readNodeByTree(self, start, height=None):
"""
Fetches nodeHash based on start leaf and height of the node in the tree.
:return: the nodeHash
"""
pos = self.getNodePosition(start, height)
return self.readNode(pos) | python | def readNodeByTree(self, start, height=None):
"""
Fetches nodeHash based on start leaf and height of the node in the tree.
:return: the nodeHash
"""
pos = self.getNodePosition(start, height)
return self.readNode(pos) | [
"def",
"readNodeByTree",
"(",
"self",
",",
"start",
",",
"height",
"=",
"None",
")",
":",
"pos",
"=",
"self",
".",
"getNodePosition",
"(",
"start",
",",
"height",
")",
"return",
"self",
".",
"readNode",
"(",
"pos",
")"
] | Fetches nodeHash based on start leaf and height of the node in the tree.
:return: the nodeHash | [
"Fetches",
"nodeHash",
"based",
"on",
"start",
"leaf",
"and",
"height",
"of",
"the",
"node",
"in",
"the",
"tree",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/hash_stores/hash_store.py#L129-L136 | train |
hyperledger/indy-plenum | ledger/hash_stores/hash_store.py | HashStore.is_consistent | def is_consistent(self) -> bool:
"""
Returns True if number of nodes are consistent with number of leaves
"""
from ledger.compact_merkle_tree import CompactMerkleTree
return self.nodeCount == CompactMerkleTree.get_expected_node_count(
self.leafCount) | python | def is_consistent(self) -> bool:
"""
Returns True if number of nodes are consistent with number of leaves
"""
from ledger.compact_merkle_tree import CompactMerkleTree
return self.nodeCount == CompactMerkleTree.get_expected_node_count(
self.leafCount) | [
"def",
"is_consistent",
"(",
"self",
")",
"->",
"bool",
":",
"from",
"ledger",
".",
"compact_merkle_tree",
"import",
"CompactMerkleTree",
"return",
"self",
".",
"nodeCount",
"==",
"CompactMerkleTree",
".",
"get_expected_node_count",
"(",
"self",
".",
"leafCount",
... | Returns True if number of nodes are consistent with number of leaves | [
"Returns",
"True",
"if",
"number",
"of",
"nodes",
"are",
"consistent",
"with",
"number",
"of",
"leaves"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/ledger/hash_stores/hash_store.py#L139-L145 | train |
hyperledger/indy-plenum | storage/chunked_file_store.py | ChunkedFileStore._startNextChunk | def _startNextChunk(self) -> None:
"""
Close current and start next chunk
"""
if self.currentChunk is None:
self._useLatestChunk()
else:
self._useChunk(self.currentChunkIndex + self.chunkSize) | python | def _startNextChunk(self) -> None:
"""
Close current and start next chunk
"""
if self.currentChunk is None:
self._useLatestChunk()
else:
self._useChunk(self.currentChunkIndex + self.chunkSize) | [
"def",
"_startNextChunk",
"(",
"self",
")",
"->",
"None",
":",
"if",
"self",
".",
"currentChunk",
"is",
"None",
":",
"self",
".",
"_useLatestChunk",
"(",
")",
"else",
":",
"self",
".",
"_useChunk",
"(",
"self",
".",
"currentChunkIndex",
"+",
"self",
".",... | Close current and start next chunk | [
"Close",
"current",
"and",
"start",
"next",
"chunk"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/storage/chunked_file_store.py#L108-L115 | train |
hyperledger/indy-plenum | storage/chunked_file_store.py | ChunkedFileStore.get | def get(self, key) -> str:
"""
Determines the file to retrieve the data from and retrieves the data.
:return: value corresponding to specified key
"""
# TODO: get is creating files when a key is given which is more than
# the store size
chunk_no, offset = self._g... | python | def get(self, key) -> str:
"""
Determines the file to retrieve the data from and retrieves the data.
:return: value corresponding to specified key
"""
# TODO: get is creating files when a key is given which is more than
# the store size
chunk_no, offset = self._g... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
"->",
"str",
":",
"chunk_no",
",",
"offset",
"=",
"self",
".",
"_get_key_location",
"(",
"key",
")",
"with",
"self",
".",
"_openChunk",
"(",
"chunk_no",
")",
"as",
"chunk",
":",
"return",
"chunk",
".",
"get... | Determines the file to retrieve the data from and retrieves the data.
:return: value corresponding to specified key | [
"Determines",
"the",
"file",
"to",
"retrieve",
"the",
"data",
"from",
"and",
"retrieves",
"the",
"data",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/storage/chunked_file_store.py#L168-L178 | train |
hyperledger/indy-plenum | storage/chunked_file_store.py | ChunkedFileStore.reset | def reset(self) -> None:
"""
Clear all data in file storage.
"""
self.close()
for f in os.listdir(self.dataDir):
os.remove(os.path.join(self.dataDir, f))
self._useLatestChunk() | python | def reset(self) -> None:
"""
Clear all data in file storage.
"""
self.close()
for f in os.listdir(self.dataDir):
os.remove(os.path.join(self.dataDir, f))
self._useLatestChunk() | [
"def",
"reset",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"close",
"(",
")",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"dataDir",
")",
":",
"os",
".",
"remove",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"d... | Clear all data in file storage. | [
"Clear",
"all",
"data",
"in",
"file",
"storage",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/storage/chunked_file_store.py#L180-L187 | train |
hyperledger/indy-plenum | storage/chunked_file_store.py | ChunkedFileStore._listChunks | def _listChunks(self):
"""
Lists stored chunks
:return: sorted list of available chunk indices
"""
chunks = []
for fileName in os.listdir(self.dataDir):
index = ChunkedFileStore._fileNameToChunkIndex(fileName)
if index is not None:
... | python | def _listChunks(self):
"""
Lists stored chunks
:return: sorted list of available chunk indices
"""
chunks = []
for fileName in os.listdir(self.dataDir):
index = ChunkedFileStore._fileNameToChunkIndex(fileName)
if index is not None:
... | [
"def",
"_listChunks",
"(",
"self",
")",
":",
"chunks",
"=",
"[",
"]",
"for",
"fileName",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"dataDir",
")",
":",
"index",
"=",
"ChunkedFileStore",
".",
"_fileNameToChunkIndex",
"(",
"fileName",
")",
"if",
"index... | Lists stored chunks
:return: sorted list of available chunk indices | [
"Lists",
"stored",
"chunks"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/storage/chunked_file_store.py#L216-L227 | train |
hyperledger/indy-plenum | plenum/server/primary_decider.py | PrimaryDecider.filterMsgs | def filterMsgs(self, wrappedMsgs: deque) -> deque:
"""
Filters messages by view number so that only the messages that have the
current view number are retained.
:param wrappedMsgs: the messages to filter
"""
filtered = deque()
while wrappedMsgs:
wrapp... | python | def filterMsgs(self, wrappedMsgs: deque) -> deque:
"""
Filters messages by view number so that only the messages that have the
current view number are retained.
:param wrappedMsgs: the messages to filter
"""
filtered = deque()
while wrappedMsgs:
wrapp... | [
"def",
"filterMsgs",
"(",
"self",
",",
"wrappedMsgs",
":",
"deque",
")",
"->",
"deque",
":",
"filtered",
"=",
"deque",
"(",
")",
"while",
"wrappedMsgs",
":",
"wrappedMsg",
"=",
"wrappedMsgs",
".",
"popleft",
"(",
")",
"msg",
",",
"sender",
"=",
"wrappedM... | Filters messages by view number so that only the messages that have the
current view number are retained.
:param wrappedMsgs: the messages to filter | [
"Filters",
"messages",
"by",
"view",
"number",
"so",
"that",
"only",
"the",
"messages",
"that",
"have",
"the",
"current",
"view",
"number",
"are",
"retained",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/primary_decider.py#L74-L97 | train |
hyperledger/indy-plenum | plenum/server/plugin_loader.py | PluginLoader.get | def get(self, name):
"""Retrieve a plugin by name."""
try:
return self.plugins[name]
except KeyError:
raise RuntimeError("plugin {} does not exist".format(name)) | python | def get(self, name):
"""Retrieve a plugin by name."""
try:
return self.plugins[name]
except KeyError:
raise RuntimeError("plugin {} does not exist".format(name)) | [
"def",
"get",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"return",
"self",
".",
"plugins",
"[",
"name",
"]",
"except",
"KeyError",
":",
"raise",
"RuntimeError",
"(",
"\"plugin {} does not exist\"",
".",
"format",
"(",
"name",
")",
")"
] | Retrieve a plugin by name. | [
"Retrieve",
"a",
"plugin",
"by",
"name",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/plugin_loader.py#L65-L70 | train |
hyperledger/indy-plenum | common/version.py | VersionBase.cmp | def cmp(cls, v1: 'VersionBase', v2: 'VersionBase') -> int:
""" Compares two instances. """
# TODO types checking
if v1._version > v2._version:
return 1
elif v1._version == v2._version:
return 0
else:
return -1 | python | def cmp(cls, v1: 'VersionBase', v2: 'VersionBase') -> int:
""" Compares two instances. """
# TODO types checking
if v1._version > v2._version:
return 1
elif v1._version == v2._version:
return 0
else:
return -1 | [
"def",
"cmp",
"(",
"cls",
",",
"v1",
":",
"'VersionBase'",
",",
"v2",
":",
"'VersionBase'",
")",
"->",
"int",
":",
"if",
"v1",
".",
"_version",
">",
"v2",
".",
"_version",
":",
"return",
"1",
"elif",
"v1",
".",
"_version",
"==",
"v2",
".",
"_versio... | Compares two instances. | [
"Compares",
"two",
"instances",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/common/version.py#L39-L47 | train |
hyperledger/indy-plenum | stp_zmq/kit_zstack.py | KITZStack.maintainConnections | def maintainConnections(self, force=False):
"""
Ensure appropriate connections.
"""
now = time.perf_counter()
if now < self.nextCheck and not force:
return False
self.nextCheck = now + (self.config.RETRY_TIMEOUT_NOT_RESTRICTED
... | python | def maintainConnections(self, force=False):
"""
Ensure appropriate connections.
"""
now = time.perf_counter()
if now < self.nextCheck and not force:
return False
self.nextCheck = now + (self.config.RETRY_TIMEOUT_NOT_RESTRICTED
... | [
"def",
"maintainConnections",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"now",
"=",
"time",
".",
"perf_counter",
"(",
")",
"if",
"now",
"<",
"self",
".",
"nextCheck",
"and",
"not",
"force",
":",
"return",
"False",
"self",
".",
"nextCheck",
"="... | Ensure appropriate connections. | [
"Ensure",
"appropriate",
"connections",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/kit_zstack.py#L54-L69 | train |
hyperledger/indy-plenum | stp_zmq/kit_zstack.py | KITZStack.connectToMissing | def connectToMissing(self) -> set:
"""
Try to connect to the missing nodes
"""
missing = self.reconcileNodeReg()
if not missing:
return missing
logger.info("{}{} found the following missing connections: {}".
format(CONNECTION_PREFIX, self... | python | def connectToMissing(self) -> set:
"""
Try to connect to the missing nodes
"""
missing = self.reconcileNodeReg()
if not missing:
return missing
logger.info("{}{} found the following missing connections: {}".
format(CONNECTION_PREFIX, self... | [
"def",
"connectToMissing",
"(",
"self",
")",
"->",
"set",
":",
"missing",
"=",
"self",
".",
"reconcileNodeReg",
"(",
")",
"if",
"not",
"missing",
":",
"return",
"missing",
"logger",
".",
"info",
"(",
"\"{}{} found the following missing connections: {}\"",
".",
"... | Try to connect to the missing nodes | [
"Try",
"to",
"connect",
"to",
"the",
"missing",
"nodes"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/kit_zstack.py#L107-L125 | train |
hyperledger/indy-plenum | stp_core/common/logging/handlers.py | CallbackHandler.emit | def emit(self, record):
"""
Passes the log record back to the CLI for rendering
"""
should_cb = None
attr_val = None
if hasattr(record, self.typestr):
attr_val = getattr(record, self.typestr)
should_cb = bool(attr_val)
if should_cb is None ... | python | def emit(self, record):
"""
Passes the log record back to the CLI for rendering
"""
should_cb = None
attr_val = None
if hasattr(record, self.typestr):
attr_val = getattr(record, self.typestr)
should_cb = bool(attr_val)
if should_cb is None ... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"should_cb",
"=",
"None",
"attr_val",
"=",
"None",
"if",
"hasattr",
"(",
"record",
",",
"self",
".",
"typestr",
")",
":",
"attr_val",
"=",
"getattr",
"(",
"record",
",",
"self",
".",
"typestr",
")"... | Passes the log record back to the CLI for rendering | [
"Passes",
"the",
"log",
"record",
"back",
"to",
"the",
"CLI",
"for",
"rendering"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/common/logging/handlers.py#L18-L39 | train |
hyperledger/indy-plenum | stp_core/network/keep_in_touch.py | KITNetworkInterface.conns | def conns(self, value: Set[str]) -> None:
"""
Updates the connection count of this node if not already done.
"""
if not self._conns == value:
old = self._conns
self._conns = value
ins = value - old
outs = old - value
logger.disp... | python | def conns(self, value: Set[str]) -> None:
"""
Updates the connection count of this node if not already done.
"""
if not self._conns == value:
old = self._conns
self._conns = value
ins = value - old
outs = old - value
logger.disp... | [
"def",
"conns",
"(",
"self",
",",
"value",
":",
"Set",
"[",
"str",
"]",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"_conns",
"==",
"value",
":",
"old",
"=",
"self",
".",
"_conns",
"self",
".",
"_conns",
"=",
"value",
"ins",
"=",
"value",
... | Updates the connection count of this node if not already done. | [
"Updates",
"the",
"connection",
"count",
"of",
"this",
"node",
"if",
"not",
"already",
"done",
"."
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/network/keep_in_touch.py#L57-L67 | train |
hyperledger/indy-plenum | stp_core/network/keep_in_touch.py | KITNetworkInterface.findInNodeRegByHA | def findInNodeRegByHA(self, remoteHa):
"""
Returns the name of the remote by HA if found in the node registry, else
returns None
"""
regName = [nm for nm, ha in self.registry.items()
if self.sameAddr(ha, remoteHa)]
if len(regName) > 1:
raise... | python | def findInNodeRegByHA(self, remoteHa):
"""
Returns the name of the remote by HA if found in the node registry, else
returns None
"""
regName = [nm for nm, ha in self.registry.items()
if self.sameAddr(ha, remoteHa)]
if len(regName) > 1:
raise... | [
"def",
"findInNodeRegByHA",
"(",
"self",
",",
"remoteHa",
")",
":",
"regName",
"=",
"[",
"nm",
"for",
"nm",
",",
"ha",
"in",
"self",
".",
"registry",
".",
"items",
"(",
")",
"if",
"self",
".",
"sameAddr",
"(",
"ha",
",",
"remoteHa",
")",
"]",
"if",... | Returns the name of the remote by HA if found in the node registry, else
returns None | [
"Returns",
"the",
"name",
"of",
"the",
"remote",
"by",
"HA",
"if",
"found",
"in",
"the",
"node",
"registry",
"else",
"returns",
"None"
] | dcd144e238af7f17a869ffc9412f13dc488b7020 | https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_core/network/keep_in_touch.py#L110-L122 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.