partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
RouteHandler._send_request
Uses an executor to send an asynchronous ZMQ request to the validator with the handler's Connection
rest_api/sawtooth_rest_api/route_handlers.py
async def _send_request(self, request_type, payload): """Uses an executor to send an asynchronous ZMQ request to the validator with the handler's Connection """ try: return await self._connection.send( message_type=request_type, message_content...
async def _send_request(self, request_type, payload): """Uses an executor to send an asynchronous ZMQ request to the validator with the handler's Connection """ try: return await self._connection.send( message_type=request_type, message_content...
[ "Uses", "an", "executor", "to", "send", "an", "asynchronous", "ZMQ", "request", "to", "the", "validator", "with", "the", "handler", "s", "Connection" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L617-L634
[ "async", "def", "_send_request", "(", "self", ",", "request_type", ",", "payload", ")", ":", "try", ":", "return", "await", "self", ".", "_connection", ".", "send", "(", "message_type", "=", "request_type", ",", "message_content", "=", "payload", ",", "timeo...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._parse_response
Parses the content from a validator response Message.
rest_api/sawtooth_rest_api/route_handlers.py
def _parse_response(proto, response): """Parses the content from a validator response Message. """ try: content = proto() content.ParseFromString(response.content) return content except (DecodeError, AttributeError): LOGGER.error('Validator...
def _parse_response(proto, response): """Parses the content from a validator response Message. """ try: content = proto() content.ParseFromString(response.content) return content except (DecodeError, AttributeError): LOGGER.error('Validator...
[ "Parses", "the", "content", "from", "a", "validator", "response", "Message", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L660-L669
[ "def", "_parse_response", "(", "proto", ",", "response", ")", ":", "try", ":", "content", "=", "proto", "(", ")", "content", ".", "ParseFromString", "(", "response", ".", "content", ")", "return", "content", "except", "(", "DecodeError", ",", "AttributeError...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._check_status_errors
Raises HTTPErrors based on error statuses sent from validator. Checks for common statuses and runs route specific error traps.
rest_api/sawtooth_rest_api/route_handlers.py
def _check_status_errors(proto, content, error_traps=None): """Raises HTTPErrors based on error statuses sent from validator. Checks for common statuses and runs route specific error traps. """ if content.status == proto.OK: return try: if content.status ...
def _check_status_errors(proto, content, error_traps=None): """Raises HTTPErrors based on error statuses sent from validator. Checks for common statuses and runs route specific error traps. """ if content.status == proto.OK: return try: if content.status ...
[ "Raises", "HTTPErrors", "based", "on", "error", "statuses", "sent", "from", "validator", ".", "Checks", "for", "common", "statuses", "and", "runs", "route", "specific", "error", "traps", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L672-L713
[ "def", "_check_status_errors", "(", "proto", ",", "content", ",", "error_traps", "=", "None", ")", ":", "if", "content", ".", "status", "==", "proto", ".", "OK", ":", "return", "try", ":", "if", "content", ".", "status", "==", "proto", ".", "INTERNAL_ERR...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._wrap_response
Creates the JSON response envelope to be sent back to the client.
rest_api/sawtooth_rest_api/route_handlers.py
def _wrap_response(request, data=None, metadata=None, status=200): """Creates the JSON response envelope to be sent back to the client. """ envelope = metadata or {} if data is not None: envelope['data'] = data return web.Response( status=status, ...
def _wrap_response(request, data=None, metadata=None, status=200): """Creates the JSON response envelope to be sent back to the client. """ envelope = metadata or {} if data is not None: envelope['data'] = data return web.Response( status=status, ...
[ "Creates", "the", "JSON", "response", "envelope", "to", "be", "sent", "back", "to", "the", "client", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L716-L731
[ "def", "_wrap_response", "(", "request", ",", "data", "=", "None", ",", "metadata", "=", "None", ",", "status", "=", "200", ")", ":", "envelope", "=", "metadata", "or", "{", "}", "if", "data", "is", "not", "None", ":", "envelope", "[", "'data'", "]",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._wrap_paginated_response
Builds the metadata for a pagingated response and wraps everying in a JSON encoded web.Response
rest_api/sawtooth_rest_api/route_handlers.py
def _wrap_paginated_response(cls, request, response, controls, data, head=None): """Builds the metadata for a pagingated response and wraps everying in a JSON encoded web.Response """ paging_response = response['paging'] if head is None: ...
def _wrap_paginated_response(cls, request, response, controls, data, head=None): """Builds the metadata for a pagingated response and wraps everying in a JSON encoded web.Response """ paging_response = response['paging'] if head is None: ...
[ "Builds", "the", "metadata", "for", "a", "pagingated", "response", "and", "wraps", "everying", "in", "a", "JSON", "encoded", "web", ".", "Response" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L734-L780
[ "def", "_wrap_paginated_response", "(", "cls", ",", "request", ",", "response", ",", "controls", ",", "data", ",", "head", "=", "None", ")", ":", "paging_response", "=", "response", "[", "'paging'", "]", "if", "head", "is", "None", ":", "head", "=", "res...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._get_metadata
Parses out the head and link properties based on the HTTP Request from the client, and the Protobuf response from the validator.
rest_api/sawtooth_rest_api/route_handlers.py
def _get_metadata(cls, request, response, head=None): """Parses out the head and link properties based on the HTTP Request from the client, and the Protobuf response from the validator. """ head = response.get('head_id', head) metadata = {'link': cls._build_url(request, head=head...
def _get_metadata(cls, request, response, head=None): """Parses out the head and link properties based on the HTTP Request from the client, and the Protobuf response from the validator. """ head = response.get('head_id', head) metadata = {'link': cls._build_url(request, head=head...
[ "Parses", "out", "the", "head", "and", "link", "properties", "based", "on", "the", "HTTP", "Request", "from", "the", "client", "and", "the", "Protobuf", "response", "from", "the", "validator", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L783-L792
[ "def", "_get_metadata", "(", "cls", ",", "request", ",", "response", ",", "head", "=", "None", ")", ":", "head", "=", "response", ".", "get", "(", "'head_id'", ",", "head", ")", "metadata", "=", "{", "'link'", ":", "cls", ".", "_build_url", "(", "req...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._build_url
Builds a response URL by overriding the original queries with specified change queries. Change queries set to None will not be used. Setting a change query to False will remove it even if there is an original query with a value.
rest_api/sawtooth_rest_api/route_handlers.py
def _build_url(cls, request, path=None, **changes): """Builds a response URL by overriding the original queries with specified change queries. Change queries set to None will not be used. Setting a change query to False will remove it even if there is an original query with a value. ...
def _build_url(cls, request, path=None, **changes): """Builds a response URL by overriding the original queries with specified change queries. Change queries set to None will not be used. Setting a change query to False will remove it even if there is an original query with a value. ...
[ "Builds", "a", "response", "URL", "by", "overriding", "the", "original", "queries", "with", "specified", "change", "queries", ".", "Change", "queries", "set", "to", "None", "will", "not", "be", "used", ".", "Setting", "a", "change", "query", "to", "False", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L795-L838
[ "def", "_build_url", "(", "cls", ",", "request", ",", "path", "=", "None", ",", "*", "*", "changes", ")", ":", "changes", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "changes", ".", "items", "(", ")", "if", "v", "is", "not", "None", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._get_forwarded
Gets a forwarded value from the `Forwarded` header if present, or the equivalent `X-Forwarded-` header if not. If neither is present, returns an empty string.
rest_api/sawtooth_rest_api/route_handlers.py
def _get_forwarded(request, key): """Gets a forwarded value from the `Forwarded` header if present, or the equivalent `X-Forwarded-` header if not. If neither is present, returns an empty string. """ forwarded = request.headers.get('Forwarded', '') match = re.search( ...
def _get_forwarded(request, key): """Gets a forwarded value from the `Forwarded` header if present, or the equivalent `X-Forwarded-` header if not. If neither is present, returns an empty string. """ forwarded = request.headers.get('Forwarded', '') match = re.search( ...
[ "Gets", "a", "forwarded", "value", "from", "the", "Forwarded", "header", "if", "present", "or", "the", "equivalent", "X", "-", "Forwarded", "-", "header", "if", "not", ".", "If", "neither", "is", "present", "returns", "an", "empty", "string", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L841-L860
[ "def", "_get_forwarded", "(", "request", ",", "key", ")", ":", "forwarded", "=", "request", ".", "headers", ".", "get", "(", "'Forwarded'", ",", "''", ")", "match", "=", "re", ".", "search", "(", "r'(?<={}=).+?(?=[\\s,;]|$)'", ".", "format", "(", "key", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._expand_block
Deserializes a Block's header, and the header of its Batches.
rest_api/sawtooth_rest_api/route_handlers.py
def _expand_block(cls, block): """Deserializes a Block's header, and the header of its Batches. """ cls._parse_header(BlockHeader, block) if 'batches' in block: block['batches'] = [cls._expand_batch(b) for b in block['batches']] return block
def _expand_block(cls, block): """Deserializes a Block's header, and the header of its Batches. """ cls._parse_header(BlockHeader, block) if 'batches' in block: block['batches'] = [cls._expand_batch(b) for b in block['batches']] return block
[ "Deserializes", "a", "Block", "s", "header", "and", "the", "header", "of", "its", "Batches", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L863-L869
[ "def", "_expand_block", "(", "cls", ",", "block", ")", ":", "cls", ".", "_parse_header", "(", "BlockHeader", ",", "block", ")", "if", "'batches'", "in", "block", ":", "block", "[", "'batches'", "]", "=", "[", "cls", ".", "_expand_batch", "(", "b", ")",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._expand_batch
Deserializes a Batch's header, and the header of its Transactions.
rest_api/sawtooth_rest_api/route_handlers.py
def _expand_batch(cls, batch): """Deserializes a Batch's header, and the header of its Transactions. """ cls._parse_header(BatchHeader, batch) if 'transactions' in batch: batch['transactions'] = [ cls._expand_transaction(t) for t in batch['transactions']] ...
def _expand_batch(cls, batch): """Deserializes a Batch's header, and the header of its Transactions. """ cls._parse_header(BatchHeader, batch) if 'transactions' in batch: batch['transactions'] = [ cls._expand_transaction(t) for t in batch['transactions']] ...
[ "Deserializes", "a", "Batch", "s", "header", "and", "the", "header", "of", "its", "Transactions", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L872-L879
[ "def", "_expand_batch", "(", "cls", ",", "batch", ")", ":", "cls", ".", "_parse_header", "(", "BatchHeader", ",", "batch", ")", "if", "'transactions'", "in", "batch", ":", "batch", "[", "'transactions'", "]", "=", "[", "cls", ".", "_expand_transaction", "(...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._parse_header
Deserializes a resource's base64 encoded Protobuf header.
rest_api/sawtooth_rest_api/route_handlers.py
def _parse_header(cls, header_proto, resource): """Deserializes a resource's base64 encoded Protobuf header. """ header = header_proto() try: header_bytes = base64.b64decode(resource['header']) header.ParseFromString(header_bytes) except (KeyError, TypeErr...
def _parse_header(cls, header_proto, resource): """Deserializes a resource's base64 encoded Protobuf header. """ header = header_proto() try: header_bytes = base64.b64decode(resource['header']) header.ParseFromString(header_bytes) except (KeyError, TypeErr...
[ "Deserializes", "a", "resource", "s", "base64", "encoded", "Protobuf", "header", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L888-L904
[ "def", "_parse_header", "(", "cls", ",", "header_proto", ",", "resource", ")", ":", "header", "=", "header_proto", "(", ")", "try", ":", "header_bytes", "=", "base64", ".", "b64decode", "(", "resource", "[", "'header'", "]", ")", "header", ".", "ParseFromS...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._get_paging_controls
Parses start and/or limit queries into a paging controls dict.
rest_api/sawtooth_rest_api/route_handlers.py
def _get_paging_controls(request): """Parses start and/or limit queries into a paging controls dict. """ start = request.url.query.get('start', None) limit = request.url.query.get('limit', None) controls = {} if limit is not None: try: control...
def _get_paging_controls(request): """Parses start and/or limit queries into a paging controls dict. """ start = request.url.query.get('start', None) limit = request.url.query.get('limit', None) controls = {} if limit is not None: try: control...
[ "Parses", "start", "and", "/", "or", "limit", "queries", "into", "a", "paging", "controls", "dict", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L907-L928
[ "def", "_get_paging_controls", "(", "request", ")", ":", "start", "=", "request", ".", "url", ".", "query", ".", "get", "(", "'start'", ",", "None", ")", "limit", "=", "request", ".", "url", ".", "query", ".", "get", "(", "'limit'", ",", "None", ")",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._make_paging_message
Turns a raw paging controls dict into Protobuf ClientPagingControls.
rest_api/sawtooth_rest_api/route_handlers.py
def _make_paging_message(controls): """Turns a raw paging controls dict into Protobuf ClientPagingControls. """ return client_list_control_pb2.ClientPagingControls( start=controls.get('start', None), limit=controls.get('limit', None))
def _make_paging_message(controls): """Turns a raw paging controls dict into Protobuf ClientPagingControls. """ return client_list_control_pb2.ClientPagingControls( start=controls.get('start', None), limit=controls.get('limit', None))
[ "Turns", "a", "raw", "paging", "controls", "dict", "into", "Protobuf", "ClientPagingControls", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L931-L937
[ "def", "_make_paging_message", "(", "controls", ")", ":", "return", "client_list_control_pb2", ".", "ClientPagingControls", "(", "start", "=", "controls", ".", "get", "(", "'start'", ",", "None", ")", ",", "limit", "=", "controls", ".", "get", "(", "'limit'", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._get_sorting_message
Parses the reverse query into a list of ClientSortControls protobuf messages.
rest_api/sawtooth_rest_api/route_handlers.py
def _get_sorting_message(request, key): """Parses the reverse query into a list of ClientSortControls protobuf messages. """ control_list = [] reverse = request.url.query.get('reverse', None) if reverse is None: return control_list if reverse.lower() ...
def _get_sorting_message(request, key): """Parses the reverse query into a list of ClientSortControls protobuf messages. """ control_list = [] reverse = request.url.query.get('reverse', None) if reverse is None: return control_list if reverse.lower() ...
[ "Parses", "the", "reverse", "query", "into", "a", "list", "of", "ClientSortControls", "protobuf", "messages", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L940-L960
[ "def", "_get_sorting_message", "(", "request", ",", "key", ")", ":", "control_list", "=", "[", "]", "reverse", "=", "request", ".", "url", ".", "query", ".", "get", "(", "'reverse'", ",", "None", ")", "if", "reverse", "is", "None", ":", "return", "cont...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._set_wait
Parses the `wait` query parameter, and sets the corresponding `wait` and `timeout` properties in the validator query.
rest_api/sawtooth_rest_api/route_handlers.py
def _set_wait(self, request, validator_query): """Parses the `wait` query parameter, and sets the corresponding `wait` and `timeout` properties in the validator query. """ wait = request.url.query.get('wait', 'false') if wait.lower() != 'false': validator_query.wait =...
def _set_wait(self, request, validator_query): """Parses the `wait` query parameter, and sets the corresponding `wait` and `timeout` properties in the validator query. """ wait = request.url.query.get('wait', 'false') if wait.lower() != 'false': validator_query.wait =...
[ "Parses", "the", "wait", "query", "parameter", "and", "sets", "the", "corresponding", "wait", "and", "timeout", "properties", "in", "the", "validator", "query", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L962-L973
[ "def", "_set_wait", "(", "self", ",", "request", ",", "validator_query", ")", ":", "wait", "=", "request", ".", "url", ".", "query", ".", "get", "(", "'wait'", ",", "'false'", ")", "if", "wait", ".", "lower", "(", ")", "!=", "'false'", ":", "validato...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._drop_empty_props
Remove properties with empty strings from nested dicts.
rest_api/sawtooth_rest_api/route_handlers.py
def _drop_empty_props(self, item): """Remove properties with empty strings from nested dicts. """ if isinstance(item, list): return [self._drop_empty_props(i) for i in item] if isinstance(item, dict): return { k: self._drop_empty_props(v) ...
def _drop_empty_props(self, item): """Remove properties with empty strings from nested dicts. """ if isinstance(item, list): return [self._drop_empty_props(i) for i in item] if isinstance(item, dict): return { k: self._drop_empty_props(v) ...
[ "Remove", "properties", "with", "empty", "strings", "from", "nested", "dicts", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L975-L985
[ "def", "_drop_empty_props", "(", "self", ",", "item", ")", ":", "if", "isinstance", "(", "item", ",", "list", ")", ":", "return", "[", "self", ".", "_drop_empty_props", "(", "i", ")", "for", "i", "in", "item", "]", "if", "isinstance", "(", "item", ",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._drop_id_prefixes
Rename keys ending in 'id', to just be 'id' for nested dicts.
rest_api/sawtooth_rest_api/route_handlers.py
def _drop_id_prefixes(self, item): """Rename keys ending in 'id', to just be 'id' for nested dicts. """ if isinstance(item, list): return [self._drop_id_prefixes(i) for i in item] if isinstance(item, dict): return { 'id' if k.endswith('id') else k:...
def _drop_id_prefixes(self, item): """Rename keys ending in 'id', to just be 'id' for nested dicts. """ if isinstance(item, list): return [self._drop_id_prefixes(i) for i in item] if isinstance(item, dict): return { 'id' if k.endswith('id') else k:...
[ "Rename", "keys", "ending", "in", "id", "to", "just", "be", "id", "for", "nested", "dicts", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L987-L997
[ "def", "_drop_id_prefixes", "(", "self", ",", "item", ")", ":", "if", "isinstance", "(", "item", ",", "list", ")", ":", "return", "[", "self", ".", "_drop_id_prefixes", "(", "i", ")", "for", "i", "in", "item", "]", "if", "isinstance", "(", "item", ",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._get_head_id
Fetches the request's head query, and validates if present.
rest_api/sawtooth_rest_api/route_handlers.py
def _get_head_id(cls, request): """Fetches the request's head query, and validates if present. """ head_id = request.url.query.get('head', None) if head_id is not None: cls._validate_id(head_id) return head_id
def _get_head_id(cls, request): """Fetches the request's head query, and validates if present. """ head_id = request.url.query.get('head', None) if head_id is not None: cls._validate_id(head_id) return head_id
[ "Fetches", "the", "request", "s", "head", "query", "and", "validates", "if", "present", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L1000-L1008
[ "def", "_get_head_id", "(", "cls", ",", "request", ")", ":", "head_id", "=", "request", ".", "url", ".", "query", ".", "get", "(", "'head'", ",", "None", ")", "if", "head_id", "is", "not", "None", ":", "cls", ".", "_validate_id", "(", "head_id", ")",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RouteHandler._get_filter_ids
Parses the `id` filter paramter from the url query.
rest_api/sawtooth_rest_api/route_handlers.py
def _get_filter_ids(cls, request): """Parses the `id` filter paramter from the url query. """ id_query = request.url.query.get('id', None) if id_query is None: return None filter_ids = id_query.split(',') for filter_id in filter_ids: cls._validat...
def _get_filter_ids(cls, request): """Parses the `id` filter paramter from the url query. """ id_query = request.url.query.get('id', None) if id_query is None: return None filter_ids = id_query.split(',') for filter_id in filter_ids: cls._validat...
[ "Parses", "the", "id", "filter", "paramter", "from", "the", "url", "query", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/route_handlers.py#L1011-L1023
[ "def", "_get_filter_ids", "(", "cls", ",", "request", ")", ":", "id_query", "=", "request", ".", "url", ".", "query", ".", "get", "(", "'id'", ",", "None", ")", "if", "id_query", "is", "None", ":", "return", "None", "filter_ids", "=", "id_query", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
StateViewFactory.create_view
Creates a StateView for the given state root hash. Args: state_root_hash (str): The state root hash of the state view to return. If None, returns the state view for the Returns: StateView: state view locked to the given root hash.
validator/sawtooth_validator/state/state_view.py
def create_view(self, state_root_hash=None): """Creates a StateView for the given state root hash. Args: state_root_hash (str): The state root hash of the state view to return. If None, returns the state view for the Returns: StateView: state view locked...
def create_view(self, state_root_hash=None): """Creates a StateView for the given state root hash. Args: state_root_hash (str): The state root hash of the state view to return. If None, returns the state view for the Returns: StateView: state view locked...
[ "Creates", "a", "StateView", "for", "the", "given", "state", "root", "hash", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/state_view.py#L39-L56
[ "def", "create_view", "(", "self", ",", "state_root_hash", "=", "None", ")", ":", "# Create a default Merkle database and if we have a state root hash,", "# update the Merkle database's root to that", "if", "state_root_hash", "is", "None", ":", "state_root_hash", "=", "INIT_ROO...
8cf473bc2207e51f02bd182d825158a57d72b098
train
EventBroadcaster.add_subscriber
Register the subscriber for the given event subscriptions. Raises: InvalidFilterError One of the filters in the subscriptions is invalid.
validator/sawtooth_validator/server/events/broadcaster.py
def add_subscriber(self, connection_id, subscriptions, last_known_block_id): """Register the subscriber for the given event subscriptions. Raises: InvalidFilterError One of the filters in the subscriptions is invalid. """ with self._sub...
def add_subscriber(self, connection_id, subscriptions, last_known_block_id): """Register the subscriber for the given event subscriptions. Raises: InvalidFilterError One of the filters in the subscriptions is invalid. """ with self._sub...
[ "Register", "the", "subscriber", "for", "the", "given", "event", "subscriptions", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/events/broadcaster.py#L44-L58
[ "def", "add_subscriber", "(", "self", ",", "connection_id", ",", "subscriptions", ",", "last_known_block_id", ")", ":", "with", "self", ".", "_subscribers_cv", ":", "self", ".", "_subscribers", "[", "connection_id", "]", "=", "EventSubscriber", "(", "connection_id...
8cf473bc2207e51f02bd182d825158a57d72b098
train
EventBroadcaster.catchup_subscriber
Send an event list with all events that are in the given subscriptions from all blocks since that latest block in the current chain that is in the given last known block ids. Raises: PossibleForkDetectedError A possible fork was detected while building the event list...
validator/sawtooth_validator/server/events/broadcaster.py
def catchup_subscriber(self, connection_id): """Send an event list with all events that are in the given subscriptions from all blocks since that latest block in the current chain that is in the given last known block ids. Raises: PossibleForkDetectedError A ...
def catchup_subscriber(self, connection_id): """Send an event list with all events that are in the given subscriptions from all blocks since that latest block in the current chain that is in the given last known block ids. Raises: PossibleForkDetectedError A ...
[ "Send", "an", "event", "list", "with", "all", "events", "that", "are", "in", "the", "given", "subscriptions", "from", "all", "blocks", "since", "that", "latest", "block", "in", "the", "current", "chain", "that", "is", "in", "the", "given", "last", "known",...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/events/broadcaster.py#L60-L87
[ "def", "catchup_subscriber", "(", "self", ",", "connection_id", ")", ":", "with", "self", ".", "_subscribers_cv", ":", "subscriber", "=", "self", ".", "_subscribers", "[", "connection_id", "]", "last_known_block_id", "=", "subscriber", ".", "get_last_known_block_id"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
EventBroadcaster.get_catchup_block_ids
Raises: PossibleForkDetectedError
validator/sawtooth_validator/server/events/broadcaster.py
def get_catchup_block_ids(self, last_known_block_id): ''' Raises: PossibleForkDetectedError ''' # If latest known block is not the current chain head, catch up catchup_up_blocks = [] chain_head = self._block_store.chain_head if chain_head and last_know...
def get_catchup_block_ids(self, last_known_block_id): ''' Raises: PossibleForkDetectedError ''' # If latest known block is not the current chain head, catch up catchup_up_blocks = [] chain_head = self._block_store.chain_head if chain_head and last_know...
[ "Raises", ":", "PossibleForkDetectedError" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/events/broadcaster.py#L109-L127
[ "def", "get_catchup_block_ids", "(", "self", ",", "last_known_block_id", ")", ":", "# If latest known block is not the current chain head, catch up", "catchup_up_blocks", "=", "[", "]", "chain_head", "=", "self", ".", "_block_store", ".", "chain_head", "if", "chain_head", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
EventBroadcaster.get_events_for_block_ids
Get a list of events associated with all the block ids. Args: block_ids (list of str): The block ids to search for events that match each subscription. subscriptions (list of EventSubscriptions): EventFilter and event type to filter events. Retur...
validator/sawtooth_validator/server/events/broadcaster.py
def get_events_for_block_ids(self, block_ids, subscriptions): """Get a list of events associated with all the block ids. Args: block_ids (list of str): The block ids to search for events that match each subscription. subscriptions (list of EventSubscriptions): Ev...
def get_events_for_block_ids(self, block_ids, subscriptions): """Get a list of events associated with all the block ids. Args: block_ids (list of str): The block ids to search for events that match each subscription. subscriptions (list of EventSubscriptions): Ev...
[ "Get", "a", "list", "of", "events", "associated", "with", "all", "the", "block", "ids", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/events/broadcaster.py#L158-L176
[ "def", "get_events_for_block_ids", "(", "self", ",", "block_ids", ",", "subscriptions", ")", ":", "blocks", "=", "[", "self", ".", "_block_store", "[", "block_id", "]", "for", "block_id", "in", "block_ids", "]", "return", "self", ".", "get_events_for_blocks", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
EventBroadcaster.get_events_for_blocks
Get a list of events associated with all the blocks. Args: blocks (list of BlockWrapper): The blocks to search for events that match each subscription. subscriptions (list of EventSubscriptions): EventFilter and event type to filter events. Retur...
validator/sawtooth_validator/server/events/broadcaster.py
def get_events_for_blocks(self, blocks, subscriptions): """Get a list of events associated with all the blocks. Args: blocks (list of BlockWrapper): The blocks to search for events that match each subscription. subscriptions (list of EventSubscriptions): EventFil...
def get_events_for_blocks(self, blocks, subscriptions): """Get a list of events associated with all the blocks. Args: blocks (list of BlockWrapper): The blocks to search for events that match each subscription. subscriptions (list of EventSubscriptions): EventFil...
[ "Get", "a", "list", "of", "events", "associated", "with", "all", "the", "blocks", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/events/broadcaster.py#L182-L200
[ "def", "get_events_for_blocks", "(", "self", ",", "blocks", ",", "subscriptions", ")", ":", "events", "=", "[", "]", "for", "blkw", "in", "blocks", ":", "events", ".", "extend", "(", "self", ".", "get_events_for_block", "(", "blkw", ",", "subscriptions", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusFactory.get_consensus_module
Returns a consensus module by name. Args: module_name (str): The name of the module to load. Returns: module: The consensus module. Raises: UnknownConsensusModuleError: Raised if the given module_name does not correspond to a consensus imple...
validator/sawtooth_validator/journal/consensus/consensus_factory.py
def get_consensus_module(module_name): """Returns a consensus module by name. Args: module_name (str): The name of the module to load. Returns: module: The consensus module. Raises: UnknownConsensusModuleError: Raised if the given module_name does ...
def get_consensus_module(module_name): """Returns a consensus module by name. Args: module_name (str): The name of the module to load. Returns: module: The consensus module. Raises: UnknownConsensusModuleError: Raised if the given module_name does ...
[ "Returns", "a", "consensus", "module", "by", "name", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/consensus_factory.py#L27-L56
[ "def", "get_consensus_module", "(", "module_name", ")", ":", "module_package", "=", "module_name", "if", "module_name", "==", "'genesis'", ":", "module_package", "=", "(", "'sawtooth_validator.journal.consensus.genesis.'", "'genesis_consensus'", ")", "elif", "module_name", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusFactory.get_configured_consensus_module
Returns the consensus_module based on the consensus module set by the "sawtooth_settings" transaction family. Args: block_id (str): the block id associated with the current state_view state_view (:obj:`StateView`): the current state view to use for setting values...
validator/sawtooth_validator/journal/consensus/consensus_factory.py
def get_configured_consensus_module(block_id, state_view): """Returns the consensus_module based on the consensus module set by the "sawtooth_settings" transaction family. Args: block_id (str): the block id associated with the current state_view state_view (:obj:`StateVi...
def get_configured_consensus_module(block_id, state_view): """Returns the consensus_module based on the consensus module set by the "sawtooth_settings" transaction family. Args: block_id (str): the block id associated with the current state_view state_view (:obj:`StateVi...
[ "Returns", "the", "consensus_module", "based", "on", "the", "consensus", "module", "set", "by", "the", "sawtooth_settings", "transaction", "family", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/consensus_factory.py#L59-L78
[ "def", "get_configured_consensus_module", "(", "block_id", ",", "state_view", ")", ":", "settings_view", "=", "SettingsView", "(", "state_view", ")", "default_consensus", "=", "'genesis'", "if", "block_id", "==", "NULL_BLOCK_IDENTIFIER", "else", "'devmode'", "consensus_...
8cf473bc2207e51f02bd182d825158a57d72b098
train
parse_args
Parse command line flags added to `rest_api` command.
rest_api/sawtooth_rest_api/rest_api.py
def parse_args(args): """Parse command line flags added to `rest_api` command. """ parser = argparse.ArgumentParser( description='Starts the REST API application and connects to a ' 'specified validator.') parser.add_argument('-B', '--bind', help='identify host a...
def parse_args(args): """Parse command line flags added to `rest_api` command. """ parser = argparse.ArgumentParser( description='Starts the REST API application and connects to a ' 'specified validator.') parser.add_argument('-B', '--bind', help='identify host a...
[ "Parse", "command", "line", "flags", "added", "to", "rest_api", "command", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/rest_api.py#L49-L90
[ "def", "parse_args", "(", "args", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Starts the REST API application and connects to a '", "'specified validator.'", ")", "parser", ".", "add_argument", "(", "'-B'", ",", "'--bind'", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
start_rest_api
Builds the web app, adds route handlers, and finally starts the app.
rest_api/sawtooth_rest_api/rest_api.py
def start_rest_api(host, port, connection, timeout, registry, client_max_size=None): """Builds the web app, adds route handlers, and finally starts the app. """ loop = asyncio.get_event_loop() connection.open() app = web.Application(loop=loop, client_max_size=client_max_size) ...
def start_rest_api(host, port, connection, timeout, registry, client_max_size=None): """Builds the web app, adds route handlers, and finally starts the app. """ loop = asyncio.get_event_loop() connection.open() app = web.Application(loop=loop, client_max_size=client_max_size) ...
[ "Builds", "the", "web", "app", "adds", "route", "handlers", "and", "finally", "starts", "the", "app", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/rest_api.py#L93-L143
[ "def", "start_rest_api", "(", "host", ",", "port", ",", "connection", ",", "timeout", ",", "registry", ",", "client_max_size", "=", "None", ")", ":", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "connection", ".", "open", "(", ")", "app", "="...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_genesis_parser
Creates the arg parsers needed for the genesis command.
cli/sawtooth_cli/admin_command/genesis.py
def add_genesis_parser(subparsers, parent_parser): """Creates the arg parsers needed for the genesis command. """ parser = subparsers.add_parser( 'genesis', help='Creates the genesis.batch file for initializing the validator', description='Generates the genesis.batch file for ' ...
def add_genesis_parser(subparsers, parent_parser): """Creates the arg parsers needed for the genesis command. """ parser = subparsers.add_parser( 'genesis', help='Creates the genesis.batch file for initializing the validator', description='Generates the genesis.batch file for ' ...
[ "Creates", "the", "arg", "parsers", "needed", "for", "the", "genesis", "command", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/admin_command/genesis.py#L27-L55
[ "def", "add_genesis_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'genesis'", ",", "help", "=", "'Creates the genesis.batch file for initializing the validator'", ",", "description", "=", "'Generates the ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_genesis
Given the command args, take an series of input files containing GenesisData, combine all the batches into one GenesisData, and output the result into a new file.
cli/sawtooth_cli/admin_command/genesis.py
def do_genesis(args, data_dir=None): """Given the command args, take an series of input files containing GenesisData, combine all the batches into one GenesisData, and output the result into a new file. """ if data_dir is None: data_dir = get_data_dir() if not os.path.exists(data_dir):...
def do_genesis(args, data_dir=None): """Given the command args, take an series of input files containing GenesisData, combine all the batches into one GenesisData, and output the result into a new file. """ if data_dir is None: data_dir = get_data_dir() if not os.path.exists(data_dir):...
[ "Given", "the", "command", "args", "take", "an", "series", "of", "input", "files", "containing", "GenesisData", "combine", "all", "the", "batches", "into", "one", "GenesisData", "and", "output", "the", "result", "into", "a", "new", "file", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/admin_command/genesis.py#L58-L94
[ "def", "do_genesis", "(", "args", ",", "data_dir", "=", "None", ")", ":", "if", "data_dir", "is", "None", ":", "data_dir", "=", "get_data_dir", "(", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "data_dir", ")", ":", "raise", "CliException",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_validate_depedencies
Validates the transaction dependencies for the transactions contained within the sequence of batches. Given that all the batches are expected to to be executed for the genesis blocks, it is assumed that any dependent transaction will proceed the depending transaction.
cli/sawtooth_cli/admin_command/genesis.py
def _validate_depedencies(batches): """Validates the transaction dependencies for the transactions contained within the sequence of batches. Given that all the batches are expected to to be executed for the genesis blocks, it is assumed that any dependent transaction will proceed the depending transacti...
def _validate_depedencies(batches): """Validates the transaction dependencies for the transactions contained within the sequence of batches. Given that all the batches are expected to to be executed for the genesis blocks, it is assumed that any dependent transaction will proceed the depending transacti...
[ "Validates", "the", "transaction", "dependencies", "for", "the", "transactions", "contained", "within", "the", "sequence", "of", "batches", ".", "Given", "that", "all", "the", "batches", "are", "expected", "to", "to", "be", "executed", "for", "the", "genesis", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/admin_command/genesis.py#L97-L119
[ "def", "_validate_depedencies", "(", "batches", ")", ":", "transaction_ids", "=", "set", "(", ")", "for", "batch", "in", "batches", ":", "for", "txn", "in", "batch", ".", "transactions", ":", "txn_header", "=", "TransactionHeader", "(", ")", "txn_header", "....
8cf473bc2207e51f02bd182d825158a57d72b098
train
_check_required_settings
Ensure that all settings required at genesis are set.
cli/sawtooth_cli/admin_command/genesis.py
def _check_required_settings(batches): """Ensure that all settings required at genesis are set.""" required_settings = [ 'sawtooth.consensus.algorithm.name', 'sawtooth.consensus.algorithm.version'] for batch in batches: for txn in batch.transactions: txn_header = Transac...
def _check_required_settings(batches): """Ensure that all settings required at genesis are set.""" required_settings = [ 'sawtooth.consensus.algorithm.name', 'sawtooth.consensus.algorithm.version'] for batch in batches: for txn in batch.transactions: txn_header = Transac...
[ "Ensure", "that", "all", "settings", "required", "at", "genesis", "are", "set", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/admin_command/genesis.py#L122-L144
[ "def", "_check_required_settings", "(", "batches", ")", ":", "required_settings", "=", "[", "'sawtooth.consensus.algorithm.name'", ",", "'sawtooth.consensus.algorithm.version'", "]", "for", "batch", "in", "batches", ":", "for", "txn", "in", "batch", ".", "transactions",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Database.get
Retrieves a value associated with a key from the database Args: key (str): The key to retrieve
validator/sawtooth_validator/database/database.py
def get(self, key, index=None): """Retrieves a value associated with a key from the database Args: key (str): The key to retrieve """ records = self.get_multi([key], index=index) try: return records[0][1] # return the value from the key/value tuple ...
def get(self, key, index=None): """Retrieves a value associated with a key from the database Args: key (str): The key to retrieve """ records = self.get_multi([key], index=index) try: return records[0][1] # return the value from the key/value tuple ...
[ "Retrieves", "a", "value", "associated", "with", "a", "key", "from", "the", "database" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/database/database.py#L53-L64
[ "def", "get", "(", "self", ",", "key", ",", "index", "=", "None", ")", ":", "records", "=", "self", ".", "get_multi", "(", "[", "key", "]", ",", "index", "=", "index", ")", "try", ":", "return", "records", "[", "0", "]", "[", "1", "]", "# retur...
8cf473bc2207e51f02bd182d825158a57d72b098
train
StateDeltaSubscriberHandler.on_shutdown
Cleans up any outstanding subscriptions.
rest_api/sawtooth_rest_api/state_delta_subscription_handler.py
async def on_shutdown(self): """ Cleans up any outstanding subscriptions. """ await self._unregister_subscriptions() self._accepting = False for (ws, _) in self._subscribers: await ws.close(code=aiohttp.WSCloseCode.GOING_AWAY, mess...
async def on_shutdown(self): """ Cleans up any outstanding subscriptions. """ await self._unregister_subscriptions() self._accepting = False for (ws, _) in self._subscribers: await ws.close(code=aiohttp.WSCloseCode.GOING_AWAY, mess...
[ "Cleans", "up", "any", "outstanding", "subscriptions", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/state_delta_subscription_handler.py#L76-L86
[ "async", "def", "on_shutdown", "(", "self", ")", ":", "await", "self", ".", "_unregister_subscriptions", "(", ")", "self", ".", "_accepting", "=", "False", "for", "(", "ws", ",", "_", ")", "in", "self", ".", "_subscribers", ":", "await", "ws", ".", "cl...
8cf473bc2207e51f02bd182d825158a57d72b098
train
StateDeltaSubscriberHandler.subscriptions
Handles requests for new subscription websockets. Args: request (aiohttp.Request): the incoming request Returns: aiohttp.web.WebSocketResponse: the websocket response, when the resulting websocket is closed
rest_api/sawtooth_rest_api/state_delta_subscription_handler.py
async def subscriptions(self, request): """ Handles requests for new subscription websockets. Args: request (aiohttp.Request): the incoming request Returns: aiohttp.web.WebSocketResponse: the websocket response, when the resulting websocket is cl...
async def subscriptions(self, request): """ Handles requests for new subscription websockets. Args: request (aiohttp.Request): the incoming request Returns: aiohttp.web.WebSocketResponse: the websocket response, when the resulting websocket is cl...
[ "Handles", "requests", "for", "new", "subscription", "websockets", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/state_delta_subscription_handler.py#L88-L117
[ "async", "def", "subscriptions", "(", "self", ",", "request", ")", ":", "if", "not", "self", ".", "_accepting", ":", "return", "web", ".", "Response", "(", "status", "=", "503", ")", "web_sock", "=", "web", ".", "WebSocketResponse", "(", ")", "await", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
TransactionExecutorThread._future_done_callback
:param request (bytes):the serialized request :param result (FutureResult):
validator/sawtooth_validator/execution/executor.py
def _future_done_callback(self, request, result): """ :param request (bytes):the serialized request :param result (FutureResult): """ self._in_process_transactions_count.dec() req = processor_pb2.TpProcessRequest() req.ParseFromString(request) response = p...
def _future_done_callback(self, request, result): """ :param request (bytes):the serialized request :param result (FutureResult): """ self._in_process_transactions_count.dec() req = processor_pb2.TpProcessRequest() req.ParseFromString(request) response = p...
[ ":", "param", "request", "(", "bytes", ")", ":", "the", "serialized", "request", ":", "param", "result", "(", "FutureResult", ")", ":" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/executor.py#L98-L173
[ "def", "_future_done_callback", "(", "self", ",", "request", ",", "result", ")", ":", "self", ".", "_in_process_transactions_count", ".", "dec", "(", ")", "req", "=", "processor_pb2", ".", "TpProcessRequest", "(", ")", "req", ".", "ParseFromString", "(", "requ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_batch_parser
Adds arguments parsers for the batch list, batch show and batch status commands Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object
cli/sawtooth_cli/batch.py
def add_batch_parser(subparsers, parent_parser): """Adds arguments parsers for the batch list, batch show and batch status commands Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object """ parser = subparsers.add...
def add_batch_parser(subparsers, parent_parser): """Adds arguments parsers for the batch list, batch show and batch status commands Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object """ parser = subparsers.add...
[ "Adds", "arguments", "parsers", "for", "the", "batch", "list", "batch", "show", "and", "batch", "status", "commands" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/batch.py#L30-L50
[ "def", "add_batch_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'batch'", ",", "help", "=", "'Displays information about batches and submit new batches'", ",", "description", "=", "'Provides subcommands t...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_batch
Runs the batch list, batch show or batch status command, printing output to the console Args: args: The parsed arguments sent to the command at runtime
cli/sawtooth_cli/batch.py
def do_batch(args): """Runs the batch list, batch show or batch status command, printing output to the console Args: args: The parsed arguments sent to the command at runtime """ if args.subcommand == 'list': do_batch_list(args) if args.subcommand == 'show': do_...
def do_batch(args): """Runs the batch list, batch show or batch status command, printing output to the console Args: args: The parsed arguments sent to the command at runtime """ if args.subcommand == 'list': do_batch_list(args) if args.subcommand == 'show': do_...
[ "Runs", "the", "batch", "list", "batch", "show", "or", "batch", "status", "command", "printing", "output", "to", "the", "console" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/batch.py#L136-L153
[ "def", "do_batch", "(", "args", ")", ":", "if", "args", ".", "subcommand", "==", "'list'", ":", "do_batch_list", "(", "args", ")", "if", "args", ".", "subcommand", "==", "'show'", ":", "do_batch_show", "(", "args", ")", "if", "args", ".", "subcommand", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_batch_status
Runs the batch-status command, printing output to the console Args: args: The parsed arguments sent to the command at runtime
cli/sawtooth_cli/batch.py
def do_batch_status(args): """Runs the batch-status command, printing output to the console Args: args: The parsed arguments sent to the command at runtime """ rest_client = RestClient(args.url, args.user) batch_ids = args.batch_ids.split(',') if args.wait and args.wait > 0: ...
def do_batch_status(args): """Runs the batch-status command, printing output to the console Args: args: The parsed arguments sent to the command at runtime """ rest_client = RestClient(args.url, args.user) batch_ids = args.batch_ids.split(',') if args.wait and args.wait > 0: ...
[ "Runs", "the", "batch", "-", "status", "command", "printing", "output", "to", "the", "console" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/batch.py#L210-L229
[ "def", "do_batch_status", "(", "args", ")", ":", "rest_client", "=", "RestClient", "(", "args", ".", "url", ",", "args", ".", "user", ")", "batch_ids", "=", "args", ".", "batch_ids", ".", "split", "(", "','", ")", "if", "args", ".", "wait", "and", "a...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Completer._complete_block
Check the block to see if it is complete and if it can be passed to the journal. If the block's predecessor is not in the block_manager the predecessor is requested and the current block is added to the the incomplete_block cache. If the block.batches and block.header.bat...
validator/sawtooth_validator/journal/completer.py
def _complete_block(self, block): """ Check the block to see if it is complete and if it can be passed to the journal. If the block's predecessor is not in the block_manager the predecessor is requested and the current block is added to the the incomplete_block cache. If the ...
def _complete_block(self, block): """ Check the block to see if it is complete and if it can be passed to the journal. If the block's predecessor is not in the block_manager the predecessor is requested and the current block is added to the the incomplete_block cache. If the ...
[ "Check", "the", "block", "to", "see", "if", "it", "is", "complete", "and", "if", "it", "can", "be", "passed", "to", "the", "journal", ".", "If", "the", "block", "s", "predecessor", "is", "not", "in", "the", "block_manager", "the", "predecessor", "is", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/completer.py#L145-L246
[ "def", "_complete_block", "(", "self", ",", "block", ")", ":", "if", "block", ".", "header_signature", "in", "self", ".", "_block_manager", ":", "LOGGER", ".", "debug", "(", "\"Drop duplicate block: %s\"", ",", "block", ")", "return", "None", "# NOTE: We cannot ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_state
Runs the batch list or batch show command, printing output to the console Args: args: The parsed arguments sent to the command at runtime
cli/sawtooth_cli/state.py
def do_state(args): """Runs the batch list or batch show command, printing output to the console Args: args: The parsed arguments sent to the command at runtime """ rest_client = RestClient(args.url, args.user) if args.subcommand == 'list': response = rest_client.list_s...
def do_state(args): """Runs the batch list or batch show command, printing output to the console Args: args: The parsed arguments sent to the command at runtime """ rest_client = RestClient(args.url, args.user) if args.subcommand == 'list': response = rest_client.list_s...
[ "Runs", "the", "batch", "list", "or", "batch", "show", "command", "printing", "output", "to", "the", "console" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/state.py#L82-L135
[ "def", "do_state", "(", "args", ")", ":", "rest_client", "=", "RestClient", "(", "args", ".", "url", ",", "args", ".", "user", ")", "if", "args", ".", "subcommand", "==", "'list'", ":", "response", "=", "rest_client", ".", "list_state", "(", "args", "....
8cf473bc2207e51f02bd182d825158a57d72b098
train
SerialScheduler._compute_merkle_root
Computes the merkle root of the state changes in the context corresponding with _last_valid_batch_c_id as applied to _previous_state_hash. Args: required_state_root (str): The merkle root that these txns should equal. Returns: state_hash (str): T...
validator/sawtooth_validator/execution/scheduler_serial.py
def _compute_merkle_root(self, required_state_root): """Computes the merkle root of the state changes in the context corresponding with _last_valid_batch_c_id as applied to _previous_state_hash. Args: required_state_root (str): The merkle root that these txns ...
def _compute_merkle_root(self, required_state_root): """Computes the merkle root of the state changes in the context corresponding with _last_valid_batch_c_id as applied to _previous_state_hash. Args: required_state_root (str): The merkle root that these txns ...
[ "Computes", "the", "merkle", "root", "of", "the", "state", "changes", "in", "the", "context", "corresponding", "with", "_last_valid_batch_c_id", "as", "applied", "to", "_previous_state_hash", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_serial.py#L324-L352
[ "def", "_compute_merkle_root", "(", "self", ",", "required_state_root", ")", ":", "state_hash", "=", "None", "if", "self", ".", "_previous_valid_batch_c_id", "is", "not", "None", ":", "publishing_or_genesis", "=", "self", ".", "_always_persist", "or", "required_stat...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.deserialize_block
Deserialize a byte string into a BlockWrapper Args: value (bytes): the byte string to deserialze Returns: BlockWrapper: a block wrapper instance
validator/sawtooth_validator/journal/block_store.py
def deserialize_block(value): """ Deserialize a byte string into a BlockWrapper Args: value (bytes): the byte string to deserialze Returns: BlockWrapper: a block wrapper instance """ # Block id strings are stored under batch/txn ids for reference...
def deserialize_block(value): """ Deserialize a byte string into a BlockWrapper Args: value (bytes): the byte string to deserialze Returns: BlockWrapper: a block wrapper instance """ # Block id strings are stored under batch/txn ids for reference...
[ "Deserialize", "a", "byte", "string", "into", "a", "BlockWrapper" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L142-L157
[ "def", "deserialize_block", "(", "value", ")", ":", "# Block id strings are stored under batch/txn ids for reference.", "# Only Blocks, not ids or Nones, should be returned by _get_block.", "block", "=", "Block", "(", ")", "block", ".", "ParseFromString", "(", "value", ")", "re...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.chain_head
Return the head block of the current chain.
validator/sawtooth_validator/journal/block_store.py
def chain_head(self): """ Return the head block of the current chain. """ (vec_ptr, vec_len, vec_cap) = ffi.prepare_vec_result() try: _libexec( 'commit_store_get_chain_head', self.pointer, ctypes.byref(vec_ptr), ...
def chain_head(self): """ Return the head block of the current chain. """ (vec_ptr, vec_len, vec_cap) = ffi.prepare_vec_result() try: _libexec( 'commit_store_get_chain_head', self.pointer, ctypes.byref(vec_ptr), ...
[ "Return", "the", "head", "block", "of", "the", "current", "chain", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L160-L177
[ "def", "chain_head", "(", "self", ")", ":", "(", "vec_ptr", ",", "vec_len", ",", "vec_cap", ")", "=", "ffi", ".", "prepare_vec_result", "(", ")", "try", ":", "_libexec", "(", "'commit_store_get_chain_head'", ",", "self", ".", "pointer", ",", "ctypes", ".",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.get_block_iter
Returns an iterator that traverses blocks in block number order. Args: start_block (:obj:`BlockWrapper`): the block from which traversal begins start_block_num (str): a starting block number, in hex, from where traversal begins; only used if no starting_b...
validator/sawtooth_validator/journal/block_store.py
def get_block_iter(self, start_block=None, start_block_num=None, reverse=True): """Returns an iterator that traverses blocks in block number order. Args: start_block (:obj:`BlockWrapper`): the block from which traversal begins start_block_n...
def get_block_iter(self, start_block=None, start_block_num=None, reverse=True): """Returns an iterator that traverses blocks in block number order. Args: start_block (:obj:`BlockWrapper`): the block from which traversal begins start_block_n...
[ "Returns", "an", "iterator", "that", "traverses", "blocks", "in", "block", "number", "order", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L200-L234
[ "def", "get_block_iter", "(", "self", ",", "start_block", "=", "None", ",", "start_block_num", "=", "None", ",", "reverse", "=", "True", ")", ":", "start", "=", "None", "if", "start_block_num", ":", "if", "len", "(", "start_block_num", ")", "<", "2", ":"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.get_blocks
Returns all blocks with the given set of block_ids. If a block id in the provided iterable does not exist in the block store, it is ignored. Args: block_ids (:iterable:str): an iterable of block ids Returns list of block wrappers found for the given block ids
validator/sawtooth_validator/journal/block_store.py
def get_blocks(self, block_ids): """Returns all blocks with the given set of block_ids. If a block id in the provided iterable does not exist in the block store, it is ignored. Args: block_ids (:iterable:str): an iterable of block ids Returns list of blo...
def get_blocks(self, block_ids): """Returns all blocks with the given set of block_ids. If a block id in the provided iterable does not exist in the block store, it is ignored. Args: block_ids (:iterable:str): an iterable of block ids Returns list of blo...
[ "Returns", "all", "blocks", "with", "the", "given", "set", "of", "block_ids", ".", "If", "a", "block", "id", "in", "the", "provided", "iterable", "does", "not", "exist", "in", "the", "block", "store", "it", "is", "ignored", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L236-L250
[ "def", "get_blocks", "(", "self", ",", "block_ids", ")", ":", "return", "list", "(", "filter", "(", "lambda", "b", ":", "b", "is", "not", "None", ",", "map", "(", "self", ".", "_get_block_by_id_or_none", ",", "block_ids", ")", ")", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.get_batch_by_transaction
Check to see if the requested transaction_id is in the current chain. If so, find the batch that has the transaction referenced by the transaction_id and return the batch. This is done by finding the block and searching for the batch. :param transaction_id (string): The id of the transa...
validator/sawtooth_validator/journal/block_store.py
def get_batch_by_transaction(self, transaction_id): """ Check to see if the requested transaction_id is in the current chain. If so, find the batch that has the transaction referenced by the transaction_id and return the batch. This is done by finding the block and searching for ...
def get_batch_by_transaction(self, transaction_id): """ Check to see if the requested transaction_id is in the current chain. If so, find the batch that has the transaction referenced by the transaction_id and return the batch. This is done by finding the block and searching for ...
[ "Check", "to", "see", "if", "the", "requested", "transaction_id", "is", "in", "the", "current", "chain", ".", "If", "so", "find", "the", "batch", "that", "has", "the", "transaction", "referenced", "by", "the", "transaction_id", "and", "return", "the", "batch...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L327-L345
[ "def", "get_batch_by_transaction", "(", "self", ",", "transaction_id", ")", ":", "payload", "=", "self", ".", "_get_data_by_id", "(", "transaction_id", ",", "'commit_store_get_batch_by_transaction'", ")", "batch", "=", "Batch", "(", ")", "batch", ".", "ParseFromStri...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.get_batch
Check to see if the requested batch_id is in the current chain. If so, find the batch with the batch_id and return it. This is done by finding the block and searching for the batch. :param batch_id (string): The id of the batch requested. :return: The batch with the batch_id.
validator/sawtooth_validator/journal/block_store.py
def get_batch(self, batch_id): """ Check to see if the requested batch_id is in the current chain. If so, find the batch with the batch_id and return it. This is done by finding the block and searching for the batch. :param batch_id (string): The id of the batch requested. ...
def get_batch(self, batch_id): """ Check to see if the requested batch_id is in the current chain. If so, find the batch with the batch_id and return it. This is done by finding the block and searching for the batch. :param batch_id (string): The id of the batch requested. ...
[ "Check", "to", "see", "if", "the", "requested", "batch_id", "is", "in", "the", "current", "chain", ".", "If", "so", "find", "the", "batch", "with", "the", "batch_id", "and", "return", "it", ".", "This", "is", "done", "by", "finding", "the", "block", "a...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L347-L363
[ "def", "get_batch", "(", "self", ",", "batch_id", ")", ":", "payload", "=", "self", ".", "_get_data_by_id", "(", "batch_id", ",", "'commit_store_get_batch'", ")", "batch", "=", "Batch", "(", ")", "batch", ".", "ParseFromString", "(", "payload", ")", "return"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockStore.get_transaction
Returns a Transaction object from the block store by its id. Params: transaction_id (str): The header_signature of the desired txn Returns: Transaction: The specified transaction Raises: ValueError: The transaction is not in the block store
validator/sawtooth_validator/journal/block_store.py
def get_transaction(self, transaction_id): """Returns a Transaction object from the block store by its id. Params: transaction_id (str): The header_signature of the desired txn Returns: Transaction: The specified transaction Raises: ValueError: The ...
def get_transaction(self, transaction_id): """Returns a Transaction object from the block store by its id. Params: transaction_id (str): The header_signature of the desired txn Returns: Transaction: The specified transaction Raises: ValueError: The ...
[ "Returns", "a", "Transaction", "object", "from", "the", "block", "store", "by", "its", "id", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_store.py#L365-L383
[ "def", "get_transaction", "(", "self", ",", "transaction_id", ")", ":", "payload", "=", "self", ".", "_get_data_by_id", "(", "transaction_id", ",", "'commit_store_get_transaction'", ")", "txn", "=", "Transaction", "(", ")", "txn", ".", "ParseFromString", "(", "p...
8cf473bc2207e51f02bd182d825158a57d72b098
train
format_terminal_row
Uses headers and a row of example data to generate a format string for printing a single row of data. Args: headers (tuple of strings): The headers for each column of data example_row (tuple): A representative tuple of strings or ints Returns string: A format string with a size for...
cli/sawtooth_cli/format_utils.py
def format_terminal_row(headers, example_row): """Uses headers and a row of example data to generate a format string for printing a single row of data. Args: headers (tuple of strings): The headers for each column of data example_row (tuple): A representative tuple of strings or ints R...
def format_terminal_row(headers, example_row): """Uses headers and a row of example data to generate a format string for printing a single row of data. Args: headers (tuple of strings): The headers for each column of data example_row (tuple): A representative tuple of strings or ints R...
[ "Uses", "headers", "and", "a", "row", "of", "example", "data", "to", "generate", "a", "format", "string", "for", "printing", "a", "single", "row", "of", "data", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/format_utils.py#L26-L59
[ "def", "format_terminal_row", "(", "headers", ",", "example_row", ")", ":", "def", "format_column", "(", "col", ")", ":", "if", "isinstance", "(", "col", ",", "str", ")", ":", "return", "'{{:{w}.{w}}}'", "return", "'{{:<{w}}}'", "widths", "=", "[", "max", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_terminal_table
Uses a set of headers, raw data, and a row parsing function, to print data to the terminal in a table of rows and columns. Args: headers (tuple of strings): The headers for each column of data data_list (list of dicts): Raw response data from the validator parse_row_fn (function): Parse...
cli/sawtooth_cli/format_utils.py
def print_terminal_table(headers, data_list, parse_row_fn): """Uses a set of headers, raw data, and a row parsing function, to print data to the terminal in a table of rows and columns. Args: headers (tuple of strings): The headers for each column of data data_list (list of dicts): Raw resp...
def print_terminal_table(headers, data_list, parse_row_fn): """Uses a set of headers, raw data, and a row parsing function, to print data to the terminal in a table of rows and columns. Args: headers (tuple of strings): The headers for each column of data data_list (list of dicts): Raw resp...
[ "Uses", "a", "set", "of", "headers", "raw", "data", "and", "a", "row", "parsing", "function", "to", "print", "data", "to", "the", "terminal", "in", "a", "table", "of", "rows", "and", "columns", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/format_utils.py#L62-L88
[ "def", "print_terminal_table", "(", "headers", ",", "data_list", ",", "parse_row_fn", ")", ":", "data_iter", "=", "iter", "(", "data_list", ")", "try", ":", "example", "=", "next", "(", "data_iter", ")", "example_row", "=", "parse_row_fn", "(", "example", ")...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_csv
Takes headers, data, and a row parsing function, and prints data to the console in a csv format.
cli/sawtooth_cli/format_utils.py
def print_csv(headers, data_list, parse_row_fn): """Takes headers, data, and a row parsing function, and prints data to the console in a csv format. """ try: writer = csv.writer(sys.stdout) writer.writerow(headers) for data in data_list: writer.writerow(parse_row_fn(d...
def print_csv(headers, data_list, parse_row_fn): """Takes headers, data, and a row parsing function, and prints data to the console in a csv format. """ try: writer = csv.writer(sys.stdout) writer.writerow(headers) for data in data_list: writer.writerow(parse_row_fn(d...
[ "Takes", "headers", "data", "and", "a", "row", "parsing", "function", "and", "prints", "data", "to", "the", "console", "in", "a", "csv", "format", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/format_utils.py#L91-L101
[ "def", "print_csv", "(", "headers", ",", "data_list", ",", "parse_row_fn", ")", ":", "try", ":", "writer", "=", "csv", ".", "writer", "(", "sys", ".", "stdout", ")", "writer", ".", "writerow", "(", "headers", ")", "for", "data", "in", "data_list", ":",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConcurrentMultiMap.append
Append item to the list at key. Creates the list at key if it doesn't exist.
validator/sawtooth_validator/concurrent/atomic.py
def append(self, key, item): """Append item to the list at key. Creates the list at key if it doesn't exist. """ with self._lock: if key in self._dict: self._dict[key].append(item) else: self._dict[key] = [item]
def append(self, key, item): """Append item to the list at key. Creates the list at key if it doesn't exist. """ with self._lock: if key in self._dict: self._dict[key].append(item) else: self._dict[key] = [item]
[ "Append", "item", "to", "the", "list", "at", "key", ".", "Creates", "the", "list", "at", "key", "if", "it", "doesn", "t", "exist", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/concurrent/atomic.py#L85-L93
[ "def", "append", "(", "self", ",", "key", ",", "item", ")", ":", "with", "self", ".", "_lock", ":", "if", "key", "in", "self", ".", "_dict", ":", "self", ".", "_dict", "[", "key", "]", ".", "append", "(", "item", ")", "else", ":", "self", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConcurrentMultiMap.set
Set key to a copy of items
validator/sawtooth_validator/concurrent/atomic.py
def set(self, key, items): """Set key to a copy of items""" if not isinstance(items, list): raise ValueError("items must be a list") with self._lock: self._dict[key] = items.copy()
def set(self, key, items): """Set key to a copy of items""" if not isinstance(items, list): raise ValueError("items must be a list") with self._lock: self._dict[key] = items.copy()
[ "Set", "key", "to", "a", "copy", "of", "items" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/concurrent/atomic.py#L95-L100
[ "def", "set", "(", "self", ",", "key", ",", "items", ")", ":", "if", "not", "isinstance", "(", "items", ",", "list", ")", ":", "raise", "ValueError", "(", "\"items must be a list\"", ")", "with", "self", ".", "_lock", ":", "self", ".", "_dict", "[", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConcurrentMultiMap.swap
Set key to a copy of items and return the list that was previously stored if the key was set. If not key was set, returns an empty list.
validator/sawtooth_validator/concurrent/atomic.py
def swap(self, key, items): """Set key to a copy of items and return the list that was previously stored if the key was set. If not key was set, returns an empty list. """ if not isinstance(items, list): raise ValueError("items must be a list") return_value = [] ...
def swap(self, key, items): """Set key to a copy of items and return the list that was previously stored if the key was set. If not key was set, returns an empty list. """ if not isinstance(items, list): raise ValueError("items must be a list") return_value = [] ...
[ "Set", "key", "to", "a", "copy", "of", "items", "and", "return", "the", "list", "that", "was", "previously", "stored", "if", "the", "key", "was", "set", ".", "If", "not", "key", "was", "set", "returns", "an", "empty", "list", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/concurrent/atomic.py#L102-L115
[ "def", "swap", "(", "self", ",", "key", ",", "items", ")", ":", "if", "not", "isinstance", "(", "items", ",", "list", ")", ":", "raise", "ValueError", "(", "\"items must be a list\"", ")", "return_value", "=", "[", "]", "with", "self", ".", "_lock", ":...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConcurrentMultiMap.pop
If the key is set, remove and return the list stored at key. Otherwise return default.
validator/sawtooth_validator/concurrent/atomic.py
def pop(self, key, default): """If the key is set, remove and return the list stored at key. Otherwise return default.""" with self._lock: return self._dict.pop(key, default)
def pop(self, key, default): """If the key is set, remove and return the list stored at key. Otherwise return default.""" with self._lock: return self._dict.pop(key, default)
[ "If", "the", "key", "is", "set", "remove", "and", "return", "the", "list", "stored", "at", "key", ".", "Otherwise", "return", "default", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/concurrent/atomic.py#L117-L121
[ "def", "pop", "(", "self", ",", "key", ",", "default", ")", ":", "with", "self", ".", "_lock", ":", "return", "self", ".", "_dict", ".", "pop", "(", "key", ",", "default", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConcurrentMultiMap.get
If the key is set, return a copy of the list stored at key. Otherwise return default.
validator/sawtooth_validator/concurrent/atomic.py
def get(self, key, default): """If the key is set, return a copy of the list stored at key. Otherwise return default.""" with self._lock: try: return self._dict[key].copy() except KeyError: return default
def get(self, key, default): """If the key is set, return a copy of the list stored at key. Otherwise return default.""" with self._lock: try: return self._dict[key].copy() except KeyError: return default
[ "If", "the", "key", "is", "set", "return", "a", "copy", "of", "the", "list", "stored", "at", "key", ".", "Otherwise", "return", "default", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/concurrent/atomic.py#L123-L130
[ "def", "get", "(", "self", ",", "key", ",", "default", ")", ":", "with", "self", ".", "_lock", ":", "try", ":", "return", "self", ".", "_dict", "[", "key", "]", ".", "copy", "(", ")", "except", "KeyError", ":", "return", "default" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.chain_update
Removes batches from the pending cache if found in the block store, and notifies any observers.
validator/sawtooth_validator/state/batch_tracker.py
def chain_update(self, block, receipts): """Removes batches from the pending cache if found in the block store, and notifies any observers. """ with self._lock: for batch_id in self._pending.copy(): if self._batch_committed(batch_id): self....
def chain_update(self, block, receipts): """Removes batches from the pending cache if found in the block store, and notifies any observers. """ with self._lock: for batch_id in self._pending.copy(): if self._batch_committed(batch_id): self....
[ "Removes", "batches", "from", "the", "pending", "cache", "if", "found", "in", "the", "block", "store", "and", "notifies", "any", "observers", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L60-L69
[ "def", "chain_update", "(", "self", ",", "block", ",", "receipts", ")", ":", "with", "self", ".", "_lock", ":", "for", "batch_id", "in", "self", ".", "_pending", ".", "copy", "(", ")", ":", "if", "self", ".", "_batch_committed", "(", "batch_id", ")", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.notify_txn_invalid
Adds a batch id to the invalid cache along with the id of the transaction that was rejected and any error message or extended data. Removes that batch id from the pending set. The cache is only temporary, and the batch info will be purged after one hour. Args: txn_id (str): ...
validator/sawtooth_validator/state/batch_tracker.py
def notify_txn_invalid(self, txn_id, message=None, extended_data=None): """Adds a batch id to the invalid cache along with the id of the transaction that was rejected and any error message or extended data. Removes that batch id from the pending set. The cache is only temporary, and the ...
def notify_txn_invalid(self, txn_id, message=None, extended_data=None): """Adds a batch id to the invalid cache along with the id of the transaction that was rejected and any error message or extended data. Removes that batch id from the pending set. The cache is only temporary, and the ...
[ "Adds", "a", "batch", "id", "to", "the", "invalid", "cache", "along", "with", "the", "id", "of", "the", "transaction", "that", "was", "rejected", "and", "any", "error", "message", "or", "extended", "data", ".", "Removes", "that", "batch", "id", "from", "...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L71-L97
[ "def", "notify_txn_invalid", "(", "self", ",", "txn_id", ",", "message", "=", "None", ",", "extended_data", "=", "None", ")", ":", "invalid_txn_info", "=", "{", "'id'", ":", "txn_id", "}", "if", "message", "is", "not", "None", ":", "invalid_txn_info", "[",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.notify_batch_pending
Adds a Batch id to the pending cache, with its transaction ids. Args: batch (str): The id of the pending batch
validator/sawtooth_validator/state/batch_tracker.py
def notify_batch_pending(self, batch): """Adds a Batch id to the pending cache, with its transaction ids. Args: batch (str): The id of the pending batch """ txn_ids = {t.header_signature for t in batch.transactions} with self._lock: self._pending.add(batc...
def notify_batch_pending(self, batch): """Adds a Batch id to the pending cache, with its transaction ids. Args: batch (str): The id of the pending batch """ txn_ids = {t.header_signature for t in batch.transactions} with self._lock: self._pending.add(batc...
[ "Adds", "a", "Batch", "id", "to", "the", "pending", "cache", "with", "its", "transaction", "ids", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L99-L110
[ "def", "notify_batch_pending", "(", "self", ",", "batch", ")", ":", "txn_ids", "=", "{", "t", ".", "header_signature", "for", "t", "in", "batch", ".", "transactions", "}", "with", "self", ".", "_lock", ":", "self", ".", "_pending", ".", "add", "(", "ba...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.get_status
Returns the status enum for a batch. Args: batch_id (str): The id of the batch to get the status for Returns: int: The status enum
validator/sawtooth_validator/state/batch_tracker.py
def get_status(self, batch_id): """Returns the status enum for a batch. Args: batch_id (str): The id of the batch to get the status for Returns: int: The status enum """ with self._lock: if self._batch_committed(batch_id): ret...
def get_status(self, batch_id): """Returns the status enum for a batch. Args: batch_id (str): The id of the batch to get the status for Returns: int: The status enum """ with self._lock: if self._batch_committed(batch_id): ret...
[ "Returns", "the", "status", "enum", "for", "a", "batch", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L112-L128
[ "def", "get_status", "(", "self", ",", "batch_id", ")", ":", "with", "self", ".", "_lock", ":", "if", "self", ".", "_batch_committed", "(", "batch_id", ")", ":", "return", "ClientBatchStatus", ".", "COMMITTED", "if", "batch_id", "in", "self", ".", "_invali...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.get_statuses
Returns a statuses dict for the requested batches. Args: batch_ids (list of str): The ids of the batches to get statuses for Returns: dict: A dict with keys of batch ids, and values of status enums
validator/sawtooth_validator/state/batch_tracker.py
def get_statuses(self, batch_ids): """Returns a statuses dict for the requested batches. Args: batch_ids (list of str): The ids of the batches to get statuses for Returns: dict: A dict with keys of batch ids, and values of status enums """ with self._loc...
def get_statuses(self, batch_ids): """Returns a statuses dict for the requested batches. Args: batch_ids (list of str): The ids of the batches to get statuses for Returns: dict: A dict with keys of batch ids, and values of status enums """ with self._loc...
[ "Returns", "a", "statuses", "dict", "for", "the", "requested", "batches", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L130-L140
[ "def", "get_statuses", "(", "self", ",", "batch_ids", ")", ":", "with", "self", ".", "_lock", ":", "return", "{", "b", ":", "self", ".", "get_status", "(", "b", ")", "for", "b", "in", "batch_ids", "}" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.get_invalid_txn_info
Fetches the id of the Transaction that failed within a particular Batch, as well as any error message or other data about the failure. Args: batch_id (str): The id of the Batch containing an invalid txn Returns: list of dict: A list of dicts with three possible keys: ...
validator/sawtooth_validator/state/batch_tracker.py
def get_invalid_txn_info(self, batch_id): """Fetches the id of the Transaction that failed within a particular Batch, as well as any error message or other data about the failure. Args: batch_id (str): The id of the Batch containing an invalid txn Returns: list ...
def get_invalid_txn_info(self, batch_id): """Fetches the id of the Transaction that failed within a particular Batch, as well as any error message or other data about the failure. Args: batch_id (str): The id of the Batch containing an invalid txn Returns: list ...
[ "Fetches", "the", "id", "of", "the", "Transaction", "that", "failed", "within", "a", "particular", "Batch", "as", "well", "as", "any", "error", "message", "or", "other", "data", "about", "the", "failure", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L142-L156
[ "def", "get_invalid_txn_info", "(", "self", ",", "batch_id", ")", ":", "with", "self", ".", "_lock", ":", "return", "[", "info", ".", "copy", "(", ")", "for", "info", "in", "self", ".", "_invalid", ".", "get", "(", "batch_id", ",", "[", "]", ")", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker.watch_statuses
Allows a component to register to be notified when a set of batches is no longer PENDING. Expects to be able to call the "notify_batches_finished" method on the registered component, sending the statuses of the batches. Args: observer (object): Must implement "notify_batches...
validator/sawtooth_validator/state/batch_tracker.py
def watch_statuses(self, observer, batch_ids): """Allows a component to register to be notified when a set of batches is no longer PENDING. Expects to be able to call the "notify_batches_finished" method on the registered component, sending the statuses of the batches. Args: ...
def watch_statuses(self, observer, batch_ids): """Allows a component to register to be notified when a set of batches is no longer PENDING. Expects to be able to call the "notify_batches_finished" method on the registered component, sending the statuses of the batches. Args: ...
[ "Allows", "a", "component", "to", "register", "to", "be", "notified", "when", "a", "set", "of", "batches", "is", "no", "longer", "PENDING", ".", "Expects", "to", "be", "able", "to", "call", "the", "notify_batches_finished", "method", "on", "the", "registered...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L158-L173
[ "def", "watch_statuses", "(", "self", ",", "observer", ",", "batch_ids", ")", ":", "with", "self", ".", "_lock", ":", "statuses", "=", "self", ".", "get_statuses", "(", "batch_ids", ")", "if", "self", ".", "_has_no_pendings", "(", "statuses", ")", ":", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker._update_observers
Updates each observer tracking a particular batch with its new status. If all statuses are no longer pending, notifies the observer and removes it from the list.
validator/sawtooth_validator/state/batch_tracker.py
def _update_observers(self, batch_id, status): """Updates each observer tracking a particular batch with its new status. If all statuses are no longer pending, notifies the observer and removes it from the list. """ for observer, statuses in self._observers.copy().items(): ...
def _update_observers(self, batch_id, status): """Updates each observer tracking a particular batch with its new status. If all statuses are no longer pending, notifies the observer and removes it from the list. """ for observer, statuses in self._observers.copy().items(): ...
[ "Updates", "each", "observer", "tracking", "a", "particular", "batch", "with", "its", "new", "status", ".", "If", "all", "statuses", "are", "no", "longer", "pending", "notifies", "the", "observer", "and", "removes", "it", "from", "the", "list", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L175-L185
[ "def", "_update_observers", "(", "self", ",", "batch_id", ",", "status", ")", ":", "for", "observer", ",", "statuses", "in", "self", ".", "_observers", ".", "copy", "(", ")", ".", "items", "(", ")", ":", "if", "batch_id", "in", "statuses", ":", "status...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchTracker._has_no_pendings
Returns True if a statuses dict has no PENDING statuses.
validator/sawtooth_validator/state/batch_tracker.py
def _has_no_pendings(self, statuses): """Returns True if a statuses dict has no PENDING statuses. """ return all(s != ClientBatchStatus.PENDING for s in statuses.values())
def _has_no_pendings(self, statuses): """Returns True if a statuses dict has no PENDING statuses. """ return all(s != ClientBatchStatus.PENDING for s in statuses.values())
[ "Returns", "True", "if", "a", "statuses", "dict", "has", "no", "PENDING", "statuses", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/batch_tracker.py#L187-L190
[ "def", "_has_no_pendings", "(", "self", ",", "statuses", ")", ":", "return", "all", "(", "s", "!=", "ClientBatchStatus", ".", "PENDING", "for", "s", "in", "statuses", ".", "values", "(", ")", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.get
Returns the value in this context, or None, for each address in addresses. Useful for gets on the context manager. Args: addresses (list of str): The addresses to return values for, if within this context. Returns: results (list of bytes): The values in ...
validator/sawtooth_validator/execution/execution_context.py
def get(self, addresses): """Returns the value in this context, or None, for each address in addresses. Useful for gets on the context manager. Args: addresses (list of str): The addresses to return values for, if within this context. Returns: re...
def get(self, addresses): """Returns the value in this context, or None, for each address in addresses. Useful for gets on the context manager. Args: addresses (list of str): The addresses to return values for, if within this context. Returns: re...
[ "Returns", "the", "value", "in", "this", "context", "or", "None", "for", "each", "address", "in", "addresses", ".", "Useful", "for", "gets", "on", "the", "context", "manager", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L126-L143
[ "def", "get", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "[", "]", "for", "add", "in", "addresses", ":", "self", ".", "validate_read", "(", "add", ")", "results", ".", "append", "(", "self", ".", "_g...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.get_if_set
Returns the value set in this context, or None, for each address in addresses. Args: addresses (list of str): The addresses to return values for, if set within this context. Returns: (list): bytes set at the address or None
validator/sawtooth_validator/execution/execution_context.py
def get_if_set(self, addresses): """Returns the value set in this context, or None, for each address in addresses. Args: addresses (list of str): The addresses to return values for, if set within this context. Returns: (list): bytes set at the ad...
def get_if_set(self, addresses): """Returns the value set in this context, or None, for each address in addresses. Args: addresses (list of str): The addresses to return values for, if set within this context. Returns: (list): bytes set at the ad...
[ "Returns", "the", "value", "set", "in", "this", "context", "or", "None", "for", "each", "address", "in", "addresses", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L145-L161
[ "def", "get_if_set", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "[", "]", "for", "add", "in", "addresses", ":", "results", ".", "append", "(", "self", ".", "_get_if_set", "(", "add", ")", ")", "return"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.get_if_deleted
Returns a list of addresses that have been deleted, or None if it hasn't been deleted. Args: addresses (list of str): The addresses to check if deleted. Returns: (list of str): The addresses, if deleted, or None.
validator/sawtooth_validator/execution/execution_context.py
def get_if_deleted(self, addresses): """Returns a list of addresses that have been deleted, or None if it hasn't been deleted. Args: addresses (list of str): The addresses to check if deleted. Returns: (list of str): The addresses, if deleted, or None. "...
def get_if_deleted(self, addresses): """Returns a list of addresses that have been deleted, or None if it hasn't been deleted. Args: addresses (list of str): The addresses to check if deleted. Returns: (list of str): The addresses, if deleted, or None. "...
[ "Returns", "a", "list", "of", "addresses", "that", "have", "been", "deleted", "or", "None", "if", "it", "hasn", "t", "been", "deleted", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L163-L178
[ "def", "get_if_deleted", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "[", "]", "for", "add", "in", "addresses", ":", "results", ".", "append", "(", "self", ".", "_get_if_deleted", "(", "add", ")", ")", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.get_if_not_set
Returns the value at an address if it was an input to the txn but never set. It returns None if that address was never set in the merkle database, or if the address is not within the context. Args: addresses (list of str): The full 70 character addresses. Returns: ...
validator/sawtooth_validator/execution/execution_context.py
def get_if_not_set(self, addresses): """Returns the value at an address if it was an input to the txn but never set. It returns None if that address was never set in the merkle database, or if the address is not within the context. Args: addresses (list of str): The full 70 ...
def get_if_not_set(self, addresses): """Returns the value at an address if it was an input to the txn but never set. It returns None if that address was never set in the merkle database, or if the address is not within the context. Args: addresses (list of str): The full 70 ...
[ "Returns", "the", "value", "at", "an", "address", "if", "it", "was", "an", "input", "to", "the", "txn", "but", "never", "set", ".", "It", "returns", "None", "if", "that", "address", "was", "never", "set", "in", "the", "merkle", "database", "or", "if", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L180-L196
[ "def", "get_if_not_set", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "[", "]", "for", "add", "in", "addresses", ":", "results", ".", "append", "(", "self", ".", "_get_if_not_set", "(", "add", ")", ")", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.get_all_if_set
Return all the addresses and opaque values set in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been set in the context.
validator/sawtooth_validator/execution/execution_context.py
def get_all_if_set(self): """Return all the addresses and opaque values set in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been set in the context. """ with self._lock: resu...
def get_all_if_set(self): """Return all the addresses and opaque values set in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been set in the context. """ with self._lock: resu...
[ "Return", "all", "the", "addresses", "and", "opaque", "values", "set", "in", "the", "context", ".", "Useful", "in", "the", "squash", "method", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L198-L212
[ "def", "get_all_if_set", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "{", "}", "for", "add", ",", "fut", "in", "self", ".", "_state", ".", "items", "(", ")", ":", "if", "self", ".", "_contains_and_set", "(", "add", ")"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.get_all_if_deleted
Return all the addresses deleted in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been deleted in the context.
validator/sawtooth_validator/execution/execution_context.py
def get_all_if_deleted(self): """Return all the addresses deleted in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been deleted in the context. """ with self._lock: results = ...
def get_all_if_deleted(self): """Return all the addresses deleted in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been deleted in the context. """ with self._lock: results = ...
[ "Return", "all", "the", "addresses", "deleted", "in", "the", "context", ".", "Useful", "in", "the", "squash", "method", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L214-L228
[ "def", "get_all_if_deleted", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "{", "}", "for", "add", ",", "fut", "in", "self", ".", "_state", ".", "items", "(", ")", ":", "if", "self", ".", "_contains_and_deleted", "(", "add...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.create_prefetch
Create futures needed before starting the process of reading the address's value from the merkle tree. Args: addresses (list of str): addresses in the txn's inputs that aren't in any base context (or any in the chain).
validator/sawtooth_validator/execution/execution_context.py
def create_prefetch(self, addresses): """Create futures needed before starting the process of reading the address's value from the merkle tree. Args: addresses (list of str): addresses in the txn's inputs that aren't in any base context (or any in the chain). ...
def create_prefetch(self, addresses): """Create futures needed before starting the process of reading the address's value from the merkle tree. Args: addresses (list of str): addresses in the txn's inputs that aren't in any base context (or any in the chain). ...
[ "Create", "futures", "needed", "before", "starting", "the", "process", "of", "reading", "the", "address", "s", "value", "from", "the", "merkle", "tree", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L230-L242
[ "def", "create_prefetch", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "for", "add", "in", "addresses", ":", "self", ".", "_state", "[", "add", "]", "=", "_ContextFuture", "(", "address", "=", "add", ",", "wait_for_tree", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.create_initial
Create futures from inputs with the current value for that address at the start of that context. Args: address_values (list of tuple): The tuple is string, bytes of the address and value.
validator/sawtooth_validator/execution/execution_context.py
def create_initial(self, address_values): """Create futures from inputs with the current value for that address at the start of that context. Args: address_values (list of tuple): The tuple is string, bytes of the address and value. """ with self._lo...
def create_initial(self, address_values): """Create futures from inputs with the current value for that address at the start of that context. Args: address_values (list of tuple): The tuple is string, bytes of the address and value. """ with self._lo...
[ "Create", "futures", "from", "inputs", "with", "the", "current", "value", "for", "that", "address", "at", "the", "start", "of", "that", "context", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L244-L255
[ "def", "create_initial", "(", "self", ",", "address_values", ")", ":", "with", "self", ".", "_lock", ":", "for", "add", ",", "val", "in", "address_values", ":", "self", ".", "_state", "[", "add", "]", "=", "_ContextFuture", "(", "address", "=", "add", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.set_from_tree
Set the result for each future at the given addresses with the value stored in the merkle database. Args: address_value_dict (dict of str: bytes): The unique full addresses that the bytes values should be set with.
validator/sawtooth_validator/execution/execution_context.py
def set_from_tree(self, address_value_dict): """Set the result for each future at the given addresses with the value stored in the merkle database. Args: address_value_dict (dict of str: bytes): The unique full addresses that the bytes values should be set with. ...
def set_from_tree(self, address_value_dict): """Set the result for each future at the given addresses with the value stored in the merkle database. Args: address_value_dict (dict of str: bytes): The unique full addresses that the bytes values should be set with. ...
[ "Set", "the", "result", "for", "each", "future", "at", "the", "given", "addresses", "with", "the", "value", "stored", "in", "the", "merkle", "database", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L257-L269
[ "def", "set_from_tree", "(", "self", ",", "address_value_dict", ")", ":", "for", "address", ",", "value", "in", "address_value_dict", ".", "items", "(", ")", ":", "if", "address", "in", "self", ".", "_state", ":", "self", ".", "_state", "[", "address", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.delete_direct
Called in the context manager's delete method to either mark an entry for deletion , or create a new future and immediately set it for deletion in the future. Args: address_list (list of str): The unique full addresses. Raises: AuthorizationException
validator/sawtooth_validator/execution/execution_context.py
def delete_direct(self, addresses): """Called in the context manager's delete method to either mark an entry for deletion , or create a new future and immediately set it for deletion in the future. Args: address_list (list of str): The unique full addresses. Raises:...
def delete_direct(self, addresses): """Called in the context manager's delete method to either mark an entry for deletion , or create a new future and immediately set it for deletion in the future. Args: address_list (list of str): The unique full addresses. Raises:...
[ "Called", "in", "the", "context", "manager", "s", "delete", "method", "to", "either", "mark", "an", "entry", "for", "deletion", "or", "create", "a", "new", "future", "and", "immediately", "set", "it", "for", "deletion", "in", "the", "future", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L271-L291
[ "def", "delete_direct", "(", "self", ",", "addresses", ")", ":", "with", "self", ".", "_lock", ":", "for", "address", "in", "addresses", ":", "self", ".", "_validate_write", "(", "address", ")", "if", "address", "in", "self", ".", "_state", ":", "self", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.set_direct
Called in the context manager's set method to either overwrite the value for an address, or create a new future and immediately set a value in the future. Args: address_value_dict (dict of str:bytes): The unique full addresses with bytes to set at that address. ...
validator/sawtooth_validator/execution/execution_context.py
def set_direct(self, address_value_dict): """Called in the context manager's set method to either overwrite the value for an address, or create a new future and immediately set a value in the future. Args: address_value_dict (dict of str:bytes): The unique full addresses ...
def set_direct(self, address_value_dict): """Called in the context manager's set method to either overwrite the value for an address, or create a new future and immediately set a value in the future. Args: address_value_dict (dict of str:bytes): The unique full addresses ...
[ "Called", "in", "the", "context", "manager", "s", "set", "method", "to", "either", "overwrite", "the", "value", "for", "an", "address", "or", "create", "a", "new", "future", "and", "immediately", "set", "a", "value", "in", "the", "future", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L293-L314
[ "def", "set_direct", "(", "self", ",", "address_value_dict", ")", ":", "with", "self", ".", "_lock", ":", "for", "address", ",", "value", "in", "address_value_dict", ".", "items", "(", ")", ":", "self", ".", "_validate_write", "(", "address", ")", "if", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext._validate_write
Raises an exception if the address is not allowed to be set in this context, based on txn outputs. Notes: Checks that the address is either listed fully as one of the outputs, or some portion of the address is listed as a namespace in the outputs of the txn. ...
validator/sawtooth_validator/execution/execution_context.py
def _validate_write(self, address): """Raises an exception if the address is not allowed to be set in this context, based on txn outputs. Notes: Checks that the address is either listed fully as one of the outputs, or some portion of the address is listed as a namespace ...
def _validate_write(self, address): """Raises an exception if the address is not allowed to be set in this context, based on txn outputs. Notes: Checks that the address is either listed fully as one of the outputs, or some portion of the address is listed as a namespace ...
[ "Raises", "an", "exception", "if", "the", "address", "is", "not", "allowed", "to", "be", "set", "in", "this", "context", "based", "on", "txn", "outputs", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L316-L336
[ "def", "_validate_write", "(", "self", ",", "address", ")", ":", "if", "not", "any", "(", "address", ".", "startswith", "(", "ns", ")", "for", "ns", "in", "self", ".", "_write_list", ")", ":", "raise", "AuthorizationException", "(", "address", "=", "addr...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ExecutionContext.validate_read
Raises an exception if the address is not allowed to be read in this context, based on txn inputs. Args: address (str): An address to be validated. Returns: None Raises: AuthorizationException
validator/sawtooth_validator/execution/execution_context.py
def validate_read(self, address): """Raises an exception if the address is not allowed to be read in this context, based on txn inputs. Args: address (str): An address to be validated. Returns: None Raises: AuthorizationException """...
def validate_read(self, address): """Raises an exception if the address is not allowed to be read in this context, based on txn inputs. Args: address (str): An address to be validated. Returns: None Raises: AuthorizationException """...
[ "Raises", "an", "exception", "if", "the", "address", "is", "not", "allowed", "to", "be", "read", "in", "this", "context", "based", "on", "txn", "inputs", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L338-L353
[ "def", "validate_read", "(", "self", ",", "address", ")", ":", "if", "not", "any", "(", "address", ".", "startswith", "(", "ns", ")", "for", "ns", "in", "self", ".", "_read_list", ")", ":", "raise", "AuthorizationException", "(", "address", "=", "address...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ContextFuture.result
Return the value at an address, optionally waiting until it is set from the context_manager, or set based on the pre-fetch mechanism. Returns: (bytes): The opaque value for an address.
validator/sawtooth_validator/execution/execution_context.py
def result(self): """Return the value at an address, optionally waiting until it is set from the context_manager, or set based on the pre-fetch mechanism. Returns: (bytes): The opaque value for an address. """ if self._read_only: return self._result ...
def result(self): """Return the value at an address, optionally waiting until it is set from the context_manager, or set based on the pre-fetch mechanism. Returns: (bytes): The opaque value for an address. """ if self._read_only: return self._result ...
[ "Return", "the", "value", "at", "an", "address", "optionally", "waiting", "until", "it", "is", "set", "from", "the", "context_manager", "or", "set", "based", "on", "the", "pre", "-", "fetch", "mechanism", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L441-L455
[ "def", "result", "(", "self", ")", ":", "if", "self", ".", "_read_only", ":", "return", "self", ".", "_result", "with", "self", ".", "_condition", ":", "if", "self", ".", "_wait_for_tree", "and", "not", "self", ".", "_result_set_in_context", ":", "self", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ContextFuture.set_result
Set the addresses's value unless the future has been declared read only. Args: result (bytes): The value at an address. from_tree (bool): Whether the value is being set by a read from the merkle tree. Returns: None
validator/sawtooth_validator/execution/execution_context.py
def set_result(self, result, from_tree=False): """Set the addresses's value unless the future has been declared read only. Args: result (bytes): The value at an address. from_tree (bool): Whether the value is being set by a read from the merkle tree. ...
def set_result(self, result, from_tree=False): """Set the addresses's value unless the future has been declared read only. Args: result (bytes): The value at an address. from_tree (bool): Whether the value is being set by a read from the merkle tree. ...
[ "Set", "the", "addresses", "s", "value", "unless", "the", "future", "has", "been", "declared", "read", "only", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L461-L500
[ "def", "set_result", "(", "self", ",", "result", ",", "from_tree", "=", "False", ")", ":", "if", "self", ".", "_read_only", ":", "if", "not", "from_tree", ":", "LOGGER", ".", "warning", "(", "\"Tried to set address %s on a\"", "\" read-only context.\"", ",", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
verify_state
Verify the state root hash of all blocks is in state and if not, reconstruct the missing state. Assumes that there are no "holes" in state, ie starting from genesis, state is present for all blocks up to some point and then not at all. If persist is False, this recomputes state in memory for all blocks ...
validator/sawtooth_validator/server/state_verifier.py
def verify_state(global_state_db, blockstore, bind_component, scheduler_type): """ Verify the state root hash of all blocks is in state and if not, reconstruct the missing state. Assumes that there are no "holes" in state, ie starting from genesis, state is present for all blocks up to some point an...
def verify_state(global_state_db, blockstore, bind_component, scheduler_type): """ Verify the state root hash of all blocks is in state and if not, reconstruct the missing state. Assumes that there are no "holes" in state, ie starting from genesis, state is present for all blocks up to some point an...
[ "Verify", "the", "state", "root", "hash", "of", "all", "blocks", "is", "in", "state", "and", "if", "not", "reconstruct", "the", "missing", "state", ".", "Assumes", "that", "there", "are", "no", "holes", "in", "state", "ie", "starting", "from", "genesis", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/state_verifier.py#L73-L180
[ "def", "verify_state", "(", "global_state_db", ",", "blockstore", ",", "bind_component", ",", "scheduler_type", ")", ":", "state_view_factory", "=", "StateViewFactory", "(", "global_state_db", ")", "# Check if we should do state verification", "start_block", ",", "prev_stat...
8cf473bc2207e51f02bd182d825158a57d72b098
train
search_for_present_state_root
Search through the blockstore and return a tuple containing: - the first block with a missing state root - the state root of that blocks predecessor
validator/sawtooth_validator/server/state_verifier.py
def search_for_present_state_root(blockstore, state_view_factory): """ Search through the blockstore and return a tuple containing: - the first block with a missing state root - the state root of that blocks predecessor """ # If there is no chain to process, then we are done. block =...
def search_for_present_state_root(blockstore, state_view_factory): """ Search through the blockstore and return a tuple containing: - the first block with a missing state root - the state root of that blocks predecessor """ # If there is no chain to process, then we are done. block =...
[ "Search", "through", "the", "blockstore", "and", "return", "a", "tuple", "containing", ":", "-", "the", "first", "block", "with", "a", "missing", "state", "root", "-", "the", "state", "root", "of", "that", "blocks", "predecessor" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/state_verifier.py#L183-L207
[ "def", "search_for_present_state_root", "(", "blockstore", ",", "state_view_factory", ")", ":", "# If there is no chain to process, then we are done.", "block", "=", "blockstore", ".", "chain_head", "if", "block", "is", "None", ":", "return", "None", ",", "None", "# Che...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConnectHandler.is_valid_endpoint_host
An endpoint host name is valid if it is a URL and if the host is not the name of a network interface.
validator/sawtooth_validator/networking/handlers.py
def is_valid_endpoint_host(interfaces, endpoint): """ An endpoint host name is valid if it is a URL and if the host is not the name of a network interface. """ result = urlparse(endpoint) hostname = result.hostname if hostname is None: return False ...
def is_valid_endpoint_host(interfaces, endpoint): """ An endpoint host name is valid if it is a URL and if the host is not the name of a network interface. """ result = urlparse(endpoint) hostname = result.hostname if hostname is None: return False ...
[ "An", "endpoint", "host", "name", "is", "valid", "if", "it", "is", "a", "URL", "and", "if", "the", "host", "is", "not", "the", "name", "of", "a", "network", "interface", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/handlers.py#L65-L79
[ "def", "is_valid_endpoint_host", "(", "interfaces", ",", "endpoint", ")", ":", "result", "=", "urlparse", "(", "endpoint", ")", "hostname", "=", "result", ".", "hostname", "if", "hostname", "is", "None", ":", "return", "False", "for", "interface", "in", "int...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConnectHandler.handle
A connection must use one of the supported authorization types to prove their identity. If a requester deviates from the procedure in any way, the requester will be rejected and the connection will be closed. The same is true if the requester sends multiple ConnectionRequests or multiple...
validator/sawtooth_validator/networking/handlers.py
def handle(self, connection_id, message_content): """ A connection must use one of the supported authorization types to prove their identity. If a requester deviates from the procedure in any way, the requester will be rejected and the connection will be closed. The same is true ...
def handle(self, connection_id, message_content): """ A connection must use one of the supported authorization types to prove their identity. If a requester deviates from the procedure in any way, the requester will be rejected and the connection will be closed. The same is true ...
[ "A", "connection", "must", "use", "one", "of", "the", "supported", "authorization", "types", "to", "prove", "their", "identity", ".", "If", "a", "requester", "deviates", "from", "the", "procedure", "in", "any", "way", "the", "requester", "will", "be", "rejec...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/handlers.py#L81-L184
[ "def", "handle", "(", "self", ",", "connection_id", ",", "message_content", ")", ":", "message", "=", "ConnectionRequest", "(", ")", "message", ".", "ParseFromString", "(", "message_content", ")", "LOGGER", ".", "debug", "(", "\"got connect message from %s. sending ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
AuthorizationTrustRequestHandler.handle
The simplest authorization type will be Trust. If Trust authorization is enabled, the validator will trust the connection and approve any roles requested that are available on that endpoint. If the requester wishes to gain access to every role it has permission to access, it can request ...
validator/sawtooth_validator/networking/handlers.py
def handle(self, connection_id, message_content): """ The simplest authorization type will be Trust. If Trust authorization is enabled, the validator will trust the connection and approve any roles requested that are available on that endpoint. If the requester wishes to gain acc...
def handle(self, connection_id, message_content): """ The simplest authorization type will be Trust. If Trust authorization is enabled, the validator will trust the connection and approve any roles requested that are available on that endpoint. If the requester wishes to gain acc...
[ "The", "simplest", "authorization", "type", "will", "be", "Trust", ".", "If", "Trust", "authorization", "is", "enabled", "the", "validator", "will", "trust", "the", "connection", "and", "approve", "any", "roles", "requested", "that", "are", "available", "on", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/handlers.py#L261-L340
[ "def", "handle", "(", "self", ",", "connection_id", ",", "message_content", ")", ":", "if", "self", ".", "_network", ".", "get_connection_status", "(", "connection_id", ")", "!=", "ConnectionStatus", ".", "CONNECTION_REQUEST", ":", "LOGGER", ".", "debug", "(", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
AuthorizationChallengeRequestHandler.handle
If the connection wants to take on a role that requires a challenge to be signed, it will request the challenge by sending an AuthorizationChallengeRequest to the validator it wishes to connect to. The validator will send back a random payload that must be signed. If the connection has n...
validator/sawtooth_validator/networking/handlers.py
def handle(self, connection_id, message_content): """ If the connection wants to take on a role that requires a challenge to be signed, it will request the challenge by sending an AuthorizationChallengeRequest to the validator it wishes to connect to. The validator will send back...
def handle(self, connection_id, message_content): """ If the connection wants to take on a role that requires a challenge to be signed, it will request the challenge by sending an AuthorizationChallengeRequest to the validator it wishes to connect to. The validator will send back...
[ "If", "the", "connection", "wants", "to", "take", "on", "a", "role", "that", "requires", "a", "challenge", "to", "be", "signed", "it", "will", "request", "the", "challenge", "by", "sending", "an", "AuthorizationChallengeRequest", "to", "the", "validator", "it"...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/handlers.py#L352-L389
[ "def", "handle", "(", "self", ",", "connection_id", ",", "message_content", ")", ":", "if", "self", ".", "_network", ".", "get_connection_status", "(", "connection_id", ")", "!=", "ConnectionStatus", ".", "CONNECTION_REQUEST", ":", "LOGGER", ".", "debug", "(", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
AuthorizationChallengeSubmitHandler.handle
When the validator receives an AuthorizationChallengeSubmit message, it will verify the public key against the signature. If the public key is verified, the requested roles will be checked against the stored roles to see if the public key is included in the policy. If the node’s response...
validator/sawtooth_validator/networking/handlers.py
def handle(self, connection_id, message_content): """ When the validator receives an AuthorizationChallengeSubmit message, it will verify the public key against the signature. If the public key is verified, the requested roles will be checked against the stored roles to see if th...
def handle(self, connection_id, message_content): """ When the validator receives an AuthorizationChallengeSubmit message, it will verify the public key against the signature. If the public key is verified, the requested roles will be checked against the stored roles to see if th...
[ "When", "the", "validator", "receives", "an", "AuthorizationChallengeSubmit", "message", "it", "will", "verify", "the", "public", "key", "against", "the", "signature", ".", "If", "the", "public", "key", "is", "verified", "the", "requested", "roles", "will", "be"...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/handlers.py#L408-L506
[ "def", "handle", "(", "self", ",", "connection_id", ",", "message_content", ")", ":", "if", "self", ".", "_network", ".", "get_connection_status", "(", "connection_id", ")", "!=", "ConnectionStatus", ".", "AUTH_CHALLENGE_REQUEST", ":", "LOGGER", ".", "debug", "(...
8cf473bc2207e51f02bd182d825158a57d72b098
train
AuthorizationViolationHandler.handle
If an AuthorizationViolation is recieved, the connection has decided that this validator is no longer permitted to be connected. Remove the connection preemptively.
validator/sawtooth_validator/networking/handlers.py
def handle(self, connection_id, message_content): """ If an AuthorizationViolation is recieved, the connection has decided that this validator is no longer permitted to be connected. Remove the connection preemptively. """ LOGGER.warning("Received AuthorizationViolation f...
def handle(self, connection_id, message_content): """ If an AuthorizationViolation is recieved, the connection has decided that this validator is no longer permitted to be connected. Remove the connection preemptively. """ LOGGER.warning("Received AuthorizationViolation f...
[ "If", "an", "AuthorizationViolation", "is", "recieved", "the", "connection", "has", "decided", "that", "this", "validator", "is", "no", "longer", "permitted", "to", "be", "connected", ".", "Remove", "the", "connection", "preemptively", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/networking/handlers.py#L514-L526
[ "def", "handle", "(", "self", ",", "connection_id", ",", "message_content", ")", ":", "LOGGER", ".", "warning", "(", "\"Received AuthorizationViolation from %s\"", ",", "connection_id", ")", "# Close the connection", "endpoint", "=", "self", ".", "_network", ".", "c...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_transaction
Runs the transaction list or show command, printing to the console Args: args: The parsed arguments sent to the command at runtime
cli/sawtooth_cli/transaction.py
def do_transaction(args): """Runs the transaction list or show command, printing to the console Args: args: The parsed arguments sent to the command at runtime """ rest_client = RestClient(args.url, args.user) if args.subcommand == 'list': transactions = rest_client.list_tr...
def do_transaction(args): """Runs the transaction list or show command, printing to the console Args: args: The parsed arguments sent to the command at runtime """ rest_client = RestClient(args.url, args.user) if args.subcommand == 'list': transactions = rest_client.list_tr...
[ "Runs", "the", "transaction", "list", "or", "show", "command", "printing", "to", "the", "console" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/transaction.py#L63-L125
[ "def", "do_transaction", "(", "args", ")", ":", "rest_client", "=", "RestClient", "(", "args", ".", "url", ",", "args", ".", "user", ")", "if", "args", ".", "subcommand", "==", "'list'", ":", "transactions", "=", "rest_client", ".", "list_transactions", "(...
8cf473bc2207e51f02bd182d825158a57d72b098
train
load_cli_config
Modifies ARGS in-place to have the attributes defined in the CLI config file if it doesn't already have them. Certain default values are given if they are not in ARGS or the config file.
cli/sawtooth_cli/cli_config.py
def load_cli_config(args): """Modifies ARGS in-place to have the attributes defined in the CLI config file if it doesn't already have them. Certain default values are given if they are not in ARGS or the config file. """ default_cli_config = _load_default_cli_config() toml_config = _load_toml_cl...
def load_cli_config(args): """Modifies ARGS in-place to have the attributes defined in the CLI config file if it doesn't already have them. Certain default values are given if they are not in ARGS or the config file. """ default_cli_config = _load_default_cli_config() toml_config = _load_toml_cl...
[ "Modifies", "ARGS", "in", "-", "place", "to", "have", "the", "attributes", "defined", "in", "the", "CLI", "config", "file", "if", "it", "doesn", "t", "already", "have", "them", ".", "Certain", "default", "values", "are", "given", "if", "they", "are", "no...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/cli_config.py#L31-L44
[ "def", "load_cli_config", "(", "args", ")", ":", "default_cli_config", "=", "_load_default_cli_config", "(", ")", "toml_config", "=", "_load_toml_cli_config", "(", ")", "for", "config", "in", "(", "toml_config", ",", "default_cli_config", ")", ":", "for", "key", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
TransactionReceiptStore.get
Returns the TransactionReceipt Args: txn_id (str): the id of the transaction for which the receipt should be retrieved. Returns: TransactionReceipt: The receipt for the given transaction id. Raises: KeyError: if the transaction id is unknown...
validator/sawtooth_validator/journal/receipt_store.py
def get(self, txn_id): """Returns the TransactionReceipt Args: txn_id (str): the id of the transaction for which the receipt should be retrieved. Returns: TransactionReceipt: The receipt for the given transaction id. Raises: KeyError...
def get(self, txn_id): """Returns the TransactionReceipt Args: txn_id (str): the id of the transaction for which the receipt should be retrieved. Returns: TransactionReceipt: The receipt for the given transaction id. Raises: KeyError...
[ "Returns", "the", "TransactionReceipt" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/receipt_store.py#L55-L74
[ "def", "get", "(", "self", ",", "txn_id", ")", ":", "if", "txn_id", "not", "in", "self", ".", "_receipt_db", ":", "raise", "KeyError", "(", "'Unknown transaction id {}'", ".", "format", "(", "txn_id", ")", ")", "txn_receipt_bytes", "=", "self", ".", "_rece...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RestClient.send_batches
Sends a list of batches to the validator. Args: batch_list (:obj:`BatchList`): the list of batches Returns: dict: the json result data, as a dict
cli/sawtooth_cli/rest_client.py
def send_batches(self, batch_list): """Sends a list of batches to the validator. Args: batch_list (:obj:`BatchList`): the list of batches Returns: dict: the json result data, as a dict """ if isinstance(batch_list, BaseMessage): batch_list = ...
def send_batches(self, batch_list): """Sends a list of batches to the validator. Args: batch_list (:obj:`BatchList`): the list of batches Returns: dict: the json result data, as a dict """ if isinstance(batch_list, BaseMessage): batch_list = ...
[ "Sends", "a", "list", "of", "batches", "to", "the", "validator", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/rest_client.py#L86-L98
[ "def", "send_batches", "(", "self", ",", "batch_list", ")", ":", "if", "isinstance", "(", "batch_list", ",", "BaseMessage", ")", ":", "batch_list", "=", "batch_list", ".", "SerializeToString", "(", ")", "return", "self", ".", "_post", "(", "'/batches'", ",",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
RestClient._submit_request
Submits the given request, and handles the errors appropriately. Args: url (str): the request to send. params (dict): params to be passed along to get/post data (bytes): the data to include in the request. headers (dict): the headers to include in the request. ...
cli/sawtooth_cli/rest_client.py
def _submit_request(self, url, params=None, data=None, headers=None, method="GET"): """Submits the given request, and handles the errors appropriately. Args: url (str): the request to send. params (dict): params to be passed along to get/post ...
def _submit_request(self, url, params=None, data=None, headers=None, method="GET"): """Submits the given request, and handles the errors appropriately. Args: url (str): the request to send. params (dict): params to be passed along to get/post ...
[ "Submits", "the", "given", "request", "and", "handles", "the", "errors", "appropriately", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/rest_client.py#L166-L209
[ "def", "_submit_request", "(", "self", ",", "url", ",", "params", "=", "None", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "method", "=", "\"GET\"", ")", ":", "if", "headers", "is", "None", ":", "headers", "=", "{", "}", "if", "self...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_list_blocks_parser
Creates the arg parsers needed for the compare command.
cli/sawtooth_cli/network_command/list_blocks.py
def add_list_blocks_parser(subparsers, parent_parser): """Creates the arg parsers needed for the compare command. """ parser = subparsers.add_parser( 'list-blocks', help='List blocks from different nodes.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog='', ...
def add_list_blocks_parser(subparsers, parent_parser): """Creates the arg parsers needed for the compare command. """ parser = subparsers.add_parser( 'list-blocks', help='List blocks from different nodes.', formatter_class=argparse.RawDescriptionHelpFormatter, epilog='', ...
[ "Creates", "the", "arg", "parsers", "needed", "for", "the", "compare", "command", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/list_blocks.py#L23-L38
[ "def", "add_list_blocks_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'list-blocks'", ",", "help", "=", "'List blocks from different nodes.'", ",", "formatter_class", "=", "argparse", ".", "RawDescrip...
8cf473bc2207e51f02bd182d825158a57d72b098
train
IdentityObserver.chain_update
Handles both "sawtooth/block-commit" Events and "identity/update" Events. For "sawtooth/block-commit", the last_block_num is updated or a fork is detected. For "identity/update", the corresponding cache entry will be updated.
validator/sawtooth_validator/gossip/identity_observer.py
def chain_update(self, block, receipts): """ Handles both "sawtooth/block-commit" Events and "identity/update" Events. For "sawtooth/block-commit", the last_block_num is updated or a fork is detected. For "identity/update", the corresponding cache entry will be updated. "...
def chain_update(self, block, receipts): """ Handles both "sawtooth/block-commit" Events and "identity/update" Events. For "sawtooth/block-commit", the last_block_num is updated or a fork is detected. For "identity/update", the corresponding cache entry will be updated. "...
[ "Handles", "both", "sawtooth", "/", "block", "-", "commit", "Events", "and", "identity", "/", "update", "Events", ".", "For", "sawtooth", "/", "block", "-", "commit", "the", "last_block_num", "is", "updated", "or", "a", "fork", "is", "detected", ".", "For"...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/identity_observer.py#L41-L61
[ "def", "chain_update", "(", "self", ",", "block", ",", "receipts", ")", ":", "block_events", "=", "BlockEventExtractor", "(", "block", ")", ".", "extract", "(", "[", "EventSubscription", "(", "event_type", "=", "\"sawtooth/block-commit\"", ")", "]", ")", "rece...
8cf473bc2207e51f02bd182d825158a57d72b098
train
load_toml_rest_api_config
Returns a RestApiConfig created by loading a TOML file from the filesystem.
rest_api/sawtooth_rest_api/config.py
def load_toml_rest_api_config(filename): """Returns a RestApiConfig created by loading a TOML file from the filesystem. """ if not os.path.exists(filename): LOGGER.info( "Skipping rest api loading from non-existent config file: %s", filename) return RestApiConfig(...
def load_toml_rest_api_config(filename): """Returns a RestApiConfig created by loading a TOML file from the filesystem. """ if not os.path.exists(filename): LOGGER.info( "Skipping rest api loading from non-existent config file: %s", filename) return RestApiConfig(...
[ "Returns", "a", "RestApiConfig", "created", "by", "loading", "a", "TOML", "file", "from", "the", "filesystem", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/config.py#L35-L74
[ "def", "load_toml_rest_api_config", "(", "filename", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "LOGGER", ".", "info", "(", "\"Skipping rest api loading from non-existent config file: %s\"", ",", "filename", ")", "return", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
merge_rest_api_config
Given a list of PathConfig objects, merges them into a single PathConfig, giving priority in the order of the configs (first has highest priority).
rest_api/sawtooth_rest_api/config.py
def merge_rest_api_config(configs): """ Given a list of PathConfig objects, merges them into a single PathConfig, giving priority in the order of the configs (first has highest priority). """ bind = None connect = None timeout = None opentsdb_url = None opentsdb_db = None opentsd...
def merge_rest_api_config(configs): """ Given a list of PathConfig objects, merges them into a single PathConfig, giving priority in the order of the configs (first has highest priority). """ bind = None connect = None timeout = None opentsdb_url = None opentsdb_db = None opentsd...
[ "Given", "a", "list", "of", "PathConfig", "objects", "merges", "them", "into", "a", "single", "PathConfig", "giving", "priority", "in", "the", "order", "of", "the", "configs", "(", "first", "has", "highest", "priority", ")", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/config.py#L77-L117
[ "def", "merge_rest_api_config", "(", "configs", ")", ":", "bind", "=", "None", "connect", "=", "None", "timeout", "=", "None", "opentsdb_url", "=", "None", "opentsdb_db", "=", "None", "opentsdb_username", "=", "None", "opentsdb_password", "=", "None", "client_ma...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_block_parser
Adds arguments parsers for the block list and block show commands Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object
cli/sawtooth_cli/block.py
def add_block_parser(subparsers, parent_parser): """Adds arguments parsers for the block list and block show commands Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object """ parser = subparsers.add_parser( '...
def add_block_parser(subparsers, parent_parser): """Adds arguments parsers for the block list and block show commands Args: subparsers: Add parsers to this subparser object parent_parser: The parent argparse.ArgumentParser object """ parser = subparsers.add_parser( '...
[ "Adds", "arguments", "parsers", "for", "the", "block", "list", "and", "block", "show", "commands" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/block.py#L25-L77
[ "def", "add_block_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'block'", ",", "description", "=", "'Provides subcommands to display information about the '", "'blocks in the current blockchain.'", ",", "he...
8cf473bc2207e51f02bd182d825158a57d72b098