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
do_block
Runs the block list or block show command, printing output to the console Args: args: The parsed arguments sent to the command at runtime
cli/sawtooth_cli/block.py
def do_block(args): """Runs the block list or block 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': block_generator = rest_client...
def do_block(args): """Runs the block list or block 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': block_generator = rest_client...
[ "Runs", "the", "block", "list", "or", "block", "show", "command", "printing", "output", "to", "the", "console" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/block.py#L80-L149
[ "def", "do_block", "(", "args", ")", ":", "rest_client", "=", "RestClient", "(", "args", ".", "url", ",", "args", ".", "user", ")", "if", "args", ".", "subcommand", "==", "'list'", ":", "block_generator", "=", "rest_client", ".", "list_blocks", "(", ")",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_MessageRouter.incoming
Returns the next incoming message.
rest_api/sawtooth_rest_api/messaging.py
async def incoming(self): """Returns the next incoming message. """ msg = await self._queue.get() self._queue.task_done() return msg
async def incoming(self): """Returns the next incoming message. """ msg = await self._queue.get() self._queue.task_done() return msg
[ "Returns", "the", "next", "incoming", "message", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L72-L77
[ "async", "def", "incoming", "(", "self", ")", ":", "msg", "=", "await", "self", ".", "_queue", ".", "get", "(", ")", "self", ".", "_queue", ".", "task_done", "(", ")", "return", "msg" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
_MessageRouter.await_reply
Wait for a reply to a given correlation id. If a timeout is provided, it will raise a asyncio.TimeoutError.
rest_api/sawtooth_rest_api/messaging.py
async def await_reply(self, correlation_id, timeout=None): """Wait for a reply to a given correlation id. If a timeout is provided, it will raise a asyncio.TimeoutError. """ try: result = await asyncio.wait_for( self._futures[correlation_id], timeout=timeout)...
async def await_reply(self, correlation_id, timeout=None): """Wait for a reply to a given correlation id. If a timeout is provided, it will raise a asyncio.TimeoutError. """ try: result = await asyncio.wait_for( self._futures[correlation_id], timeout=timeout)...
[ "Wait", "for", "a", "reply", "to", "a", "given", "correlation", "id", ".", "If", "a", "timeout", "is", "provided", "it", "will", "raise", "a", "asyncio", ".", "TimeoutError", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L90-L100
[ "async", "def", "await_reply", "(", "self", ",", "correlation_id", ",", "timeout", "=", "None", ")", ":", "try", ":", "result", "=", "await", "asyncio", ".", "wait_for", "(", "self", ".", "_futures", "[", "correlation_id", "]", ",", "timeout", "=", "time...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_MessageRouter.fail_all
Fail all the expected replies with a given error.
rest_api/sawtooth_rest_api/messaging.py
def fail_all(self, err): """Fail all the expected replies with a given error. """ for c_id in self._futures: self._fail_reply(c_id, err)
def fail_all(self, err): """Fail all the expected replies with a given error. """ for c_id in self._futures: self._fail_reply(c_id, err)
[ "Fail", "all", "the", "expected", "replies", "with", "a", "given", "error", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L122-L126
[ "def", "fail_all", "(", "self", ",", "err", ")", ":", "for", "c_id", "in", "self", ".", "_futures", ":", "self", ".", "_fail_reply", "(", "c_id", ",", "err", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
_MessageRouter.route_msg
Given a message, route it either to the incoming queue, or to the future associated with its correlation_id.
rest_api/sawtooth_rest_api/messaging.py
async def route_msg(self, msg): """Given a message, route it either to the incoming queue, or to the future associated with its correlation_id. """ if msg.correlation_id in self._futures: self._set_reply(msg.correlation_id, msg) else: await self._push_inco...
async def route_msg(self, msg): """Given a message, route it either to the incoming queue, or to the future associated with its correlation_id. """ if msg.correlation_id in self._futures: self._set_reply(msg.correlation_id, msg) else: await self._push_inco...
[ "Given", "a", "message", "route", "it", "either", "to", "the", "incoming", "queue", "or", "to", "the", "future", "associated", "with", "its", "correlation_id", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L128-L135
[ "async", "def", "route_msg", "(", "self", ",", "msg", ")", ":", "if", "msg", ".", "correlation_id", "in", "self", ".", "_futures", ":", "self", ".", "_set_reply", "(", "msg", ".", "correlation_id", ",", "msg", ")", "else", ":", "await", "self", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_Receiver.start
Starts receiving messages on the underlying socket and passes them to the message router.
rest_api/sawtooth_rest_api/messaging.py
async def start(self): """Starts receiving messages on the underlying socket and passes them to the message router. """ self._is_running = True while self._is_running: try: zmq_msg = await self._socket.recv_multipart() message = Messa...
async def start(self): """Starts receiving messages on the underlying socket and passes them to the message router. """ self._is_running = True while self._is_running: try: zmq_msg = await self._socket.recv_multipart() message = Messa...
[ "Starts", "receiving", "messages", "on", "the", "underlying", "socket", "and", "passes", "them", "to", "the", "message", "router", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L148-L168
[ "async", "def", "start", "(", "self", ")", ":", "self", ".", "_is_running", "=", "True", "while", "self", ".", "_is_running", ":", "try", ":", "zmq_msg", "=", "await", "self", ".", "_socket", ".", "recv_multipart", "(", ")", "message", "=", "Message", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Connection.open
Opens the connection. An open connection will monitor for disconnects from the remote end. Messages are either received as replies to outgoing messages, or received from an incoming queue.
rest_api/sawtooth_rest_api/messaging.py
def open(self): """Opens the connection. An open connection will monitor for disconnects from the remote end. Messages are either received as replies to outgoing messages, or received from an incoming queue. """ LOGGER.info('Connecting to %s', self._url) asyncio....
def open(self): """Opens the connection. An open connection will monitor for disconnects from the remote end. Messages are either received as replies to outgoing messages, or received from an incoming queue. """ LOGGER.info('Connecting to %s', self._url) asyncio....
[ "Opens", "the", "connection", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L268-L276
[ "def", "open", "(", "self", ")", ":", "LOGGER", ".", "info", "(", "'Connecting to %s'", ",", "self", ".", "_url", ")", "asyncio", ".", "ensure_future", "(", "self", ".", "_do_start", "(", ")", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
Connection.on_connection_state_change
Register a callback for a specific connection state change. Register a callback to be triggered when the connection changes to the specified state, signified by a ConnectionEvent. The callback must be a coroutine. Args: event_type (ConnectionEvent): the connection event to...
rest_api/sawtooth_rest_api/messaging.py
def on_connection_state_change(self, event_type, callback): """Register a callback for a specific connection state change. Register a callback to be triggered when the connection changes to the specified state, signified by a ConnectionEvent. The callback must be a coroutine. ...
def on_connection_state_change(self, event_type, callback): """Register a callback for a specific connection state change. Register a callback to be triggered when the connection changes to the specified state, signified by a ConnectionEvent. The callback must be a coroutine. ...
[ "Register", "a", "callback", "for", "a", "specific", "connection", "state", "change", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L278-L292
[ "def", "on_connection_state_change", "(", "self", ",", "event_type", ",", "callback", ")", ":", "listeners", "=", "self", ".", "_connection_state_listeners", ".", "get", "(", "event_type", ",", "[", "]", ")", "listeners", ".", "append", "(", "callback", ")", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Connection.send
Sends a message and returns a future for the response.
rest_api/sawtooth_rest_api/messaging.py
async def send(self, message_type, message_content, timeout=None): """Sends a message and returns a future for the response. """ return await self._sender.send( message_type, message_content, timeout=timeout)
async def send(self, message_type, message_content, timeout=None): """Sends a message and returns a future for the response. """ return await self._sender.send( message_type, message_content, timeout=timeout)
[ "Sends", "a", "message", "and", "returns", "a", "future", "for", "the", "response", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L315-L319
[ "async", "def", "send", "(", "self", ",", "message_type", ",", "message_content", ",", "timeout", "=", "None", ")", ":", "return", "await", "self", ".", "_sender", ".", "send", "(", "message_type", ",", "message_content", ",", "timeout", "=", "timeout", ")...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Connection.close
Closes the connection. All outstanding futures for replies will be sent a DisconnectError.
rest_api/sawtooth_rest_api/messaging.py
def close(self): """Closes the connection. All outstanding futures for replies will be sent a DisconnectError. """ if self._recv_task: self._recv_task.cancel() self._disable_monitoring() if self._monitor_task and not self._monitor_task.done(): s...
def close(self): """Closes the connection. All outstanding futures for replies will be sent a DisconnectError. """ if self._recv_task: self._recv_task.cancel() self._disable_monitoring() if self._monitor_task and not self._monitor_task.done(): s...
[ "Closes", "the", "connection", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/messaging.py#L326-L342
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_recv_task", ":", "self", ".", "_recv_task", ".", "cancel", "(", ")", "self", ".", "_disable_monitoring", "(", ")", "if", "self", ".", "_monitor_task", "and", "not", "self", ".", "_monitor_task",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
LMDBNoLockDatabase.delete
Removes a key:value from the database Args: key (str): The key to remove.
validator/sawtooth_validator/database/lmdb_nolock_database.py
def delete(self, key): """Removes a key:value from the database Args: key (str): The key to remove. """ with self._lmdb.begin(write=True, buffers=True) as txn: txn.delete(key.encode())
def delete(self, key): """Removes a key:value from the database Args: key (str): The key to remove. """ with self._lmdb.begin(write=True, buffers=True) as txn: txn.delete(key.encode())
[ "Removes", "a", "key", ":", "value", "from", "the", "database" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/database/lmdb_nolock_database.py#L107-L114
[ "def", "delete", "(", "self", ",", "key", ")", ":", "with", "self", ".", "_lmdb", ".", "begin", "(", "write", "=", "True", ",", "buffers", "=", "True", ")", "as", "txn", ":", "txn", ".", "delete", "(", "key", ".", "encode", "(", ")", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
LMDBNoLockDatabase.keys
Returns a list of keys in the database
validator/sawtooth_validator/database/lmdb_nolock_database.py
def keys(self, index=None): """Returns a list of keys in the database """ with self._lmdb.begin() as txn: return [key.decode() for key, _ in txn.cursor()]
def keys(self, index=None): """Returns a list of keys in the database """ with self._lmdb.begin() as txn: return [key.decode() for key, _ in txn.cursor()]
[ "Returns", "a", "list", "of", "keys", "in", "the", "database" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/database/lmdb_nolock_database.py#L126-L130
[ "def", "keys", "(", "self", ",", "index", "=", "None", ")", ":", "with", "self", ".", "_lmdb", ".", "begin", "(", ")", "as", "txn", ":", "return", "[", "key", ".", "decode", "(", ")", "for", "key", ",", "_", "in", "txn", ".", "cursor", "(", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockBuilder.build_block
Assembles the candidate block into it's finalized form for broadcast.
validator/sawtooth_validator/journal/block_builder.py
def build_block(self): """ Assembles the candidate block into it's finalized form for broadcast. """ header_bytes = self.block_header.SerializeToString() block = Block(header=header_bytes, header_signature=self._header_signature) block.batches.extend...
def build_block(self): """ Assembles the candidate block into it's finalized form for broadcast. """ header_bytes = self.block_header.SerializeToString() block = Block(header=header_bytes, header_signature=self._header_signature) block.batches.extend...
[ "Assembles", "the", "candidate", "block", "into", "it", "s", "finalized", "form", "for", "broadcast", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_builder.py#L38-L46
[ "def", "build_block", "(", "self", ")", ":", "header_bytes", "=", "self", ".", "block_header", ".", "SerializeToString", "(", ")", "block", "=", "Block", "(", "header", "=", "header_bytes", ",", "header_signature", "=", "self", ".", "_header_signature", ")", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Scheduler.set_transaction_execution_result
Set the status of an executed transaction. Called by the executor after a transaction has been processed. The scheduler must know when transactions have finished being applied so that it can determine which transactions will become eligible for processing. Args: tx...
validator/sawtooth_validator/execution/scheduler.py
def set_transaction_execution_result( self, txn_signature, is_valid, context_id, state_changes, events, data, error_message, error_data): """Set the status of an executed transaction. Called by the executor after a transaction has been processed. The scheduler must know...
def set_transaction_execution_result( self, txn_signature, is_valid, context_id, state_changes, events, data, error_message, error_data): """Set the status of an executed transaction. Called by the executor after a transaction has been processed. The scheduler must know...
[ "Set", "the", "status", "of", "an", "executed", "transaction", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler.py#L73-L98
[ "def", "set_transaction_execution_result", "(", "self", ",", "txn_signature", ",", "is_valid", ",", "context_id", ",", "state_changes", ",", "events", ",", "data", ",", "error_message", ",", "error_data", ")", ":", "raise", "NotImplementedError", "(", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockCache.add_chain
Add block in a chain in the correct order. Also add all of the blocks to the cache before doing a purge.
validator/sawtooth_validator/journal/block_cache.py
def add_chain(self, chain): """ Add block in a chain in the correct order. Also add all of the blocks to the cache before doing a purge. """ with self._lock: chain.sort(key=lambda x: x.block_num) for block in chain: block_id = block.header_...
def add_chain(self, chain): """ Add block in a chain in the correct order. Also add all of the blocks to the cache before doing a purge. """ with self._lock: chain.sort(key=lambda x: x.block_num) for block in chain: block_id = block.header_...
[ "Add", "block", "in", "a", "chain", "in", "the", "correct", "order", ".", "Also", "add", "all", "of", "the", "blocks", "to", "the", "cache", "before", "doing", "a", "purge", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_cache.py#L116-L132
[ "def", "add_chain", "(", "self", ",", "chain", ")", ":", "with", "self", ".", "_lock", ":", "chain", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ".", "block_num", ")", "for", "block", "in", "chain", ":", "block_id", "=", "block", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockCache._purge_expired
Remove all expired entries from the cache that do not have a reference count.
validator/sawtooth_validator/journal/block_cache.py
def _purge_expired(self): """ Remove all expired entries from the cache that do not have a reference count. """ time_horizon = time.time() - self._keep_time new_cache = {} dec_count_for = [] for (k, v) in self._cache.items(): if v.count > 0: ...
def _purge_expired(self): """ Remove all expired entries from the cache that do not have a reference count. """ time_horizon = time.time() - self._keep_time new_cache = {} dec_count_for = [] for (k, v) in self._cache.items(): if v.count > 0: ...
[ "Remove", "all", "expired", "entries", "from", "the", "cache", "that", "do", "not", "have", "a", "reference", "count", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_cache.py#L147-L179
[ "def", "_purge_expired", "(", "self", ")", ":", "time_horizon", "=", "time", ".", "time", "(", ")", "-", "self", ".", "_keep_time", "new_cache", "=", "{", "}", "dec_count_for", "=", "[", "]", "for", "(", "k", ",", "v", ")", "in", "self", ".", "_cac...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ErrorTrap.check
Checks if a status enum matches the trigger originally set, and if so, raises the appropriate error. Args: status (int, enum): A protobuf enum response status to check. Raises: AssertionError: If trigger or error were not set. _ApiError: If the statuses don'...
rest_api/sawtooth_rest_api/error_handlers.py
def check(cls, status): """Checks if a status enum matches the trigger originally set, and if so, raises the appropriate error. Args: status (int, enum): A protobuf enum response status to check. Raises: AssertionError: If trigger or error were not set. ...
def check(cls, status): """Checks if a status enum matches the trigger originally set, and if so, raises the appropriate error. Args: status (int, enum): A protobuf enum response status to check. Raises: AssertionError: If trigger or error were not set. ...
[ "Checks", "if", "a", "status", "enum", "matches", "the", "trigger", "originally", "set", "and", "if", "so", "raises", "the", "appropriate", "error", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/rest_api/sawtooth_rest_api/error_handlers.py#L40-L58
[ "def", "check", "(", "cls", ",", "status", ")", ":", "assert", "cls", ".", "trigger", "is", "not", "None", ",", "'Invalid ErrorTrap, trigger not set'", "assert", "cls", ".", "error", "is", "not", "None", ",", "'Invalid ErrorTrap, error not set'", "if", "status",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BroadcastBlockSender._remove_batches
Returns a copy of the block without the non-injected batches, which other validators are likely to already have. This reduces the size of the broadcasted block.
validator/sawtooth_validator/journal/block_sender.py
def _remove_batches(self, block, keep_batches): """Returns a copy of the block without the non-injected batches, which other validators are likely to already have. This reduces the size of the broadcasted block. """ clone = Block() clone.header = block.header clon...
def _remove_batches(self, block, keep_batches): """Returns a copy of the block without the non-injected batches, which other validators are likely to already have. This reduces the size of the broadcasted block. """ clone = Block() clone.header = block.header clon...
[ "Returns", "a", "copy", "of", "the", "block", "without", "the", "non", "-", "injected", "batches", "which", "other", "validators", "are", "likely", "to", "already", "have", ".", "This", "reduces", "the", "size", "of", "the", "broadcasted", "block", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/block_sender.py#L48-L60
[ "def", "_remove_batches", "(", "self", ",", "block", ",", "keep_batches", ")", ":", "clone", "=", "Block", "(", ")", "clone", ".", "header", "=", "block", ".", "header", "clone", ".", "header_signature", "=", "block", ".", "header_signature", "clone", ".",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockPublisher.initialize_block
Do initialization necessary for the consensus to claim a block, this may include initiating voting activates, starting proof of work hash generation, or create a PoET wait timer. Args: block_header (BlockHeader): the BlockHeader to initialize. Returns: True
validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py
def initialize_block(self, block_header): """Do initialization necessary for the consensus to claim a block, this may include initiating voting activates, starting proof of work hash generation, or create a PoET wait timer. Args: block_header (BlockHeader): the BlockHeader t...
def initialize_block(self, block_header): """Do initialization necessary for the consensus to claim a block, this may include initiating voting activates, starting proof of work hash generation, or create a PoET wait timer. Args: block_header (BlockHeader): the BlockHeader t...
[ "Do", "initialization", "necessary", "for", "the", "consensus", "to", "claim", "a", "block", "this", "may", "include", "initiating", "voting", "activates", "starting", "proof", "of", "work", "hash", "generation", "or", "create", "a", "PoET", "wait", "timer", "...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py#L70-L101
[ "def", "initialize_block", "(", "self", ",", "block_header", ")", ":", "# Using the current chain head, we need to create a state view so we", "# can get our config values.", "state_view", "=", "BlockWrapper", ".", "state_view_for_block", "(", "self", ".", "_block_cache", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BlockPublisher.check_publish_block
Check if a candidate block is ready to be claimed. block_header (BlockHeader): the block_header to be checked if it should be claimed Returns: Boolean: True if the candidate block_header should be claimed.
validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py
def check_publish_block(self, block_header): """Check if a candidate block is ready to be claimed. block_header (BlockHeader): the block_header to be checked if it should be claimed Returns: Boolean: True if the candidate block_header should be claimed. """ ...
def check_publish_block(self, block_header): """Check if a candidate block is ready to be claimed. block_header (BlockHeader): the block_header to be checked if it should be claimed Returns: Boolean: True if the candidate block_header should be claimed. """ ...
[ "Check", "if", "a", "candidate", "block", "is", "ready", "to", "be", "claimed", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py#L103-L133
[ "def", "check_publish_block", "(", "self", ",", "block_header", ")", ":", "if", "any", "(", "publisher_key", "!=", "block_header", ".", "signer_public_key", "for", "publisher_key", "in", "self", ".", "_valid_block_publishers", ")", ":", "return", "False", "if", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ForkResolver.compare_forks
The longest chain is selected. If they are equal, then the hash value of the previous block id and publisher signature is computed. The lowest result value is the winning block. Args: cur_fork_head: The current head of the block chain. new_fork_head: The head of the fork ...
validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py
def compare_forks(self, cur_fork_head, new_fork_head): """The longest chain is selected. If they are equal, then the hash value of the previous block id and publisher signature is computed. The lowest result value is the winning block. Args: cur_fork_head: The current head of...
def compare_forks(self, cur_fork_head, new_fork_head): """The longest chain is selected. If they are equal, then the hash value of the previous block id and publisher signature is computed. The lowest result value is the winning block. Args: cur_fork_head: The current head of...
[ "The", "longest", "chain", "is", "selected", ".", "If", "they", "are", "equal", "then", "the", "hash", "value", "of", "the", "previous", "block", "id", "and", "publisher", "signature", "is", "computed", ".", "The", "lowest", "result", "value", "is", "the",...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/dev_mode/dev_mode_consensus.py#L201-L254
[ "def", "compare_forks", "(", "self", ",", "cur_fork_head", ",", "new_fork_head", ")", ":", "# If the new fork head is not DevMode consensus, bail out. This should", "# never happen, but we need to protect against it.", "if", "new_fork_head", ".", "consensus", "!=", "b\"Devmode\"",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PermissionVerifier.is_batch_signer_authorized
Check the batch signing key against the allowed transactor permissions. The roles being checked are the following, from first to last: "transactor.batch_signer" "transactor" "default" The first role that is set will be the one used to ...
validator/sawtooth_validator/gossip/permission_verifier.py
def is_batch_signer_authorized(self, batch, state_root=None, from_state=False): """ Check the batch signing key against the allowed transactor permissions. The roles being checked are the following, from first to last: "transactor.batch_...
def is_batch_signer_authorized(self, batch, state_root=None, from_state=False): """ Check the batch signing key against the allowed transactor permissions. The roles being checked are the following, from first to last: "transactor.batch_...
[ "Check", "the", "batch", "signing", "key", "against", "the", "allowed", "transactor", "permissions", ".", "The", "roles", "being", "checked", "are", "the", "following", "from", "first", "to", "last", ":", "transactor", ".", "batch_signer", "transactor", "default...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/permission_verifier.py#L44-L104
[ "def", "is_batch_signer_authorized", "(", "self", ",", "batch", ",", "state_root", "=", "None", ",", "from_state", "=", "False", ")", ":", "if", "state_root", "is", "None", ":", "state_root", "=", "self", ".", "_current_root_func", "(", ")", "if", "state_roo...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PermissionVerifier.is_transaction_signer_authorized
Check the transaction signing key against the allowed transactor permissions. The roles being checked are the following, from first to last: "transactor.transaction_signer.<TP_Name>" "transactor.transaction_signer" "transactor" "def...
validator/sawtooth_validator/gossip/permission_verifier.py
def is_transaction_signer_authorized(self, transactions, state_root, from_state): """ Check the transaction signing key against the allowed transactor permissions. The roles being checked are the following, from first to last: "tra...
def is_transaction_signer_authorized(self, transactions, state_root, from_state): """ Check the transaction signing key against the allowed transactor permissions. The roles being checked are the following, from first to last: "tra...
[ "Check", "the", "transaction", "signing", "key", "against", "the", "allowed", "transactor", "permissions", ".", "The", "roles", "being", "checked", "are", "the", "following", "from", "first", "to", "last", ":", "transactor", ".", "transaction_signer", ".", "<TP_...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/permission_verifier.py#L106-L176
[ "def", "is_transaction_signer_authorized", "(", "self", ",", "transactions", ",", "state_root", ",", "from_state", ")", ":", "role", "=", "None", "if", "role", "is", "None", ":", "role", "=", "self", ".", "_cache", ".", "get_role", "(", "\"transactor.transacti...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PermissionVerifier.check_off_chain_batch_roles
Check the batch signing key against the allowed off-chain transactor permissions. The roles being checked are the following, from first to last: "transactor.batch_signer" "transactor" The first role that is set will be the one used to enforce if the ...
validator/sawtooth_validator/gossip/permission_verifier.py
def check_off_chain_batch_roles(self, batch): """ Check the batch signing key against the allowed off-chain transactor permissions. The roles being checked are the following, from first to last: "transactor.batch_signer" "transactor" The first...
def check_off_chain_batch_roles(self, batch): """ Check the batch signing key against the allowed off-chain transactor permissions. The roles being checked are the following, from first to last: "transactor.batch_signer" "transactor" The first...
[ "Check", "the", "batch", "signing", "key", "against", "the", "allowed", "off", "-", "chain", "transactor", "permissions", ".", "The", "roles", "being", "checked", "are", "the", "following", "from", "first", "to", "last", ":", "transactor", ".", "batch_signer",...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/permission_verifier.py#L178-L215
[ "def", "check_off_chain_batch_roles", "(", "self", ",", "batch", ")", ":", "if", "self", ".", "_permissions", "is", "None", ":", "return", "True", "header", "=", "BatchHeader", "(", ")", "header", ".", "ParseFromString", "(", "batch", ".", "header", ")", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PermissionVerifier.check_off_chain_transaction_roles
Check the transaction signing key against the allowed off-chain transactor permissions. The roles being checked are the following, from first to last: "transactor.transaction_signer.<TP_Name>" "transactor.transaction_signer" "transactor" ...
validator/sawtooth_validator/gossip/permission_verifier.py
def check_off_chain_transaction_roles(self, transactions): """ Check the transaction signing key against the allowed off-chain transactor permissions. The roles being checked are the following, from first to last: "transactor.transaction_signer.<TP_Name>" ...
def check_off_chain_transaction_roles(self, transactions): """ Check the transaction signing key against the allowed off-chain transactor permissions. The roles being checked are the following, from first to last: "transactor.transaction_signer.<TP_Name>" ...
[ "Check", "the", "transaction", "signing", "key", "against", "the", "allowed", "off", "-", "chain", "transactor", "permissions", ".", "The", "roles", "being", "checked", "are", "the", "following", "from", "first", "to", "last", ":", "transactor", ".", "transact...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/permission_verifier.py#L217-L262
[ "def", "check_off_chain_transaction_roles", "(", "self", ",", "transactions", ")", ":", "policy", "=", "None", "if", "\"transactor.transaction_signer\"", "in", "self", ".", "_permissions", ":", "policy", "=", "self", ".", "_permissions", "[", "\"transactor.transaction...
8cf473bc2207e51f02bd182d825158a57d72b098
train
PermissionVerifier.check_network_role
Check the public key of a node on the network to see if they are permitted to participate. The roles being checked are the following, from first to last: "network" "default" The first role that is set will be the one used to enforce if the ...
validator/sawtooth_validator/gossip/permission_verifier.py
def check_network_role(self, public_key): """ Check the public key of a node on the network to see if they are permitted to participate. The roles being checked are the following, from first to last: "network" "default" The first role that is ...
def check_network_role(self, public_key): """ Check the public key of a node on the network to see if they are permitted to participate. The roles being checked are the following, from first to last: "network" "default" The first role that is ...
[ "Check", "the", "public", "key", "of", "a", "node", "on", "the", "network", "to", "see", "if", "they", "are", "permitted", "to", "participate", ".", "The", "roles", "being", "checked", "are", "the", "following", "from", "first", "to", "last", ":", "netwo...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/permission_verifier.py#L264-L295
[ "def", "check_network_role", "(", "self", ",", "public_key", ")", ":", "state_root", "=", "self", ".", "_current_root_func", "(", ")", "if", "state_root", "==", "INIT_ROOT_KEY", ":", "LOGGER", ".", "debug", "(", "\"Chain head is not set yet. Permit all.\"", ")", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
IdentityCache.get_role
Used to retrieve an identity role. Args: item (string): the name of the role to be fetched state_root(string): The state root of the previous block. from_state (bool): Whether the identity value should be read directly from state, instead of using the cached v...
validator/sawtooth_validator/gossip/permission_verifier.py
def get_role(self, item, state_root, from_state=False): """ Used to retrieve an identity role. Args: item (string): the name of the role to be fetched state_root(string): The state root of the previous block. from_state (bool): Whether the identity value shoul...
def get_role(self, item, state_root, from_state=False): """ Used to retrieve an identity role. Args: item (string): the name of the role to be fetched state_root(string): The state root of the previous block. from_state (bool): Whether the identity value shoul...
[ "Used", "to", "retrieve", "an", "identity", "role", ".", "Args", ":", "item", "(", "string", ")", ":", "the", "name", "of", "the", "role", "to", "be", "fetched", "state_root", "(", "string", ")", ":", "The", "state", "root", "of", "the", "previous", ...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/gossip/permission_verifier.py#L465-L489
[ "def", "get_role", "(", "self", ",", "item", ",", "state_root", ",", "from_state", "=", "False", ")", ":", "if", "from_state", ":", "# if from state use identity_view and do not add to cache", "if", "self", ".", "_identity_view", "is", "None", ":", "self", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_format_batch_statuses
Takes a statuses dict and formats it for transmission with Protobuf and ZMQ. Args: statuses (dict of int): Dict with batch ids as the key, status as value batch_ids (list of str): The batch ids in their original order tracker (BatchTracker): A batch tracker with access to invalid info
validator/sawtooth_validator/state/client_handlers.py
def _format_batch_statuses(statuses, batch_ids, tracker): """Takes a statuses dict and formats it for transmission with Protobuf and ZMQ. Args: statuses (dict of int): Dict with batch ids as the key, status as value batch_ids (list of str): The batch ids in their original order trac...
def _format_batch_statuses(statuses, batch_ids, tracker): """Takes a statuses dict and formats it for transmission with Protobuf and ZMQ. Args: statuses (dict of int): Dict with batch ids as the key, status as value batch_ids (list of str): The batch ids in their original order trac...
[ "Takes", "a", "statuses", "dict", "and", "formats", "it", "for", "transmission", "with", "Protobuf", "and", "ZMQ", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L550-L579
[ "def", "_format_batch_statuses", "(", "statuses", ",", "batch_ids", ",", "tracker", ")", ":", "proto_statuses", "=", "[", "]", "for", "batch_id", "in", "batch_ids", ":", "if", "statuses", "[", "batch_id", "]", "==", "client_batch_submit_pb2", ".", "ClientBatchSt...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler.handle
Handles parsing incoming requests, and wrapping the final response. Args: connection_id (str): ZMQ identity sent over ZMQ socket message_content (bytes): Byte encoded request protobuf to be parsed Returns: HandlerResult: result to be sent in response back to client
validator/sawtooth_validator/state/client_handlers.py
def handle(self, connection_id, message_content): """Handles parsing incoming requests, and wrapping the final response. Args: connection_id (str): ZMQ identity sent over ZMQ socket message_content (bytes): Byte encoded request protobuf to be parsed Returns: ...
def handle(self, connection_id, message_content): """Handles parsing incoming requests, and wrapping the final response. Args: connection_id (str): ZMQ identity sent over ZMQ socket message_content (bytes): Byte encoded request protobuf to be parsed Returns: ...
[ "Handles", "parsing", "incoming", "requests", "and", "wrapping", "the", "final", "response", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L105-L127
[ "def", "handle", "(", "self", ",", "connection_id", ",", "message_content", ")", ":", "try", ":", "request", "=", "self", ".", "_request_proto", "(", ")", "request", ".", "ParseFromString", "(", "message_content", ")", "except", "DecodeError", ":", "LOGGER", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._wrap_result
Wraps child's response in a HandlerResult to be sent back to client. Args: response (enum or dict): Either an integer status enum, or a dict of attributes to be added to the protobuf response.
validator/sawtooth_validator/state/client_handlers.py
def _wrap_result(self, response): """Wraps child's response in a HandlerResult to be sent back to client. Args: response (enum or dict): Either an integer status enum, or a dict of attributes to be added to the protobuf response. """ if isinstance(response, i...
def _wrap_result(self, response): """Wraps child's response in a HandlerResult to be sent back to client. Args: response (enum or dict): Either an integer status enum, or a dict of attributes to be added to the protobuf response. """ if isinstance(response, i...
[ "Wraps", "child", "s", "response", "in", "a", "HandlerResult", "to", "be", "sent", "back", "to", "client", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L142-L155
[ "def", "_wrap_result", "(", "self", ",", "response", ")", ":", "if", "isinstance", "(", "response", ",", "int", ")", ":", "response", "=", "self", ".", "_wrap_response", "(", "response", ")", "return", "HandlerResult", "(", "status", "=", "HandlerStatus", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._wrap_response
Convenience method to wrap a status with any key word args. Args: status (enum): enum response status, defaults to OK Returns: dict: inlcudes a 'status' attribute and any key word arguments
validator/sawtooth_validator/state/client_handlers.py
def _wrap_response(self, status=None, **kwargs): """Convenience method to wrap a status with any key word args. Args: status (enum): enum response status, defaults to OK Returns: dict: inlcudes a 'status' attribute and any key word arguments """ kwargs['...
def _wrap_response(self, status=None, **kwargs): """Convenience method to wrap a status with any key word args. Args: status (enum): enum response status, defaults to OK Returns: dict: inlcudes a 'status' attribute and any key word arguments """ kwargs['...
[ "Convenience", "method", "to", "wrap", "a", "status", "with", "any", "key", "word", "args", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L157-L167
[ "def", "_wrap_response", "(", "self", ",", "status", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'status'", "]", "=", "status", "if", "status", "is", "not", "None", "else", "self", ".", "_status", ".", "OK", "return", "kwargs" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._get_head_block
Fetches the request specified head block, or the chain head. Note: This method will fail if `_block_store` has not been set Args: request (object): The parsed protobuf request object Returns: Block: the block object at the head of the requested chain ...
validator/sawtooth_validator/state/client_handlers.py
def _get_head_block(self, request): """Fetches the request specified head block, or the chain head. Note: This method will fail if `_block_store` has not been set Args: request (object): The parsed protobuf request object Returns: Block: the block o...
def _get_head_block(self, request): """Fetches the request specified head block, or the chain head. Note: This method will fail if `_block_store` has not been set Args: request (object): The parsed protobuf request object Returns: Block: the block o...
[ "Fetches", "the", "request", "specified", "head", "block", "or", "the", "chain", "head", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L169-L195
[ "def", "_get_head_block", "(", "self", ",", "request", ")", ":", "if", "request", ".", "head_id", ":", "if", "self", ".", "_id_regex", ".", "fullmatch", "(", "request", ".", "head_id", ")", "is", "None", ":", "LOGGER", ".", "debug", "(", "'Invalid head i...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._set_root
Sets the root of the merkle tree, returning any head id used. Note: This method will fail if `_tree` has not been set Args: request (object): The parsed protobuf request object Returns: str: the state root of the head block used to specify the root ...
validator/sawtooth_validator/state/client_handlers.py
def _set_root(self, request): """Sets the root of the merkle tree, returning any head id used. Note: This method will fail if `_tree` has not been set Args: request (object): The parsed protobuf request object Returns: str: the state root of the hea...
def _set_root(self, request): """Sets the root of the merkle tree, returning any head id used. Note: This method will fail if `_tree` has not been set Args: request (object): The parsed protobuf request object Returns: str: the state root of the hea...
[ "Sets", "the", "root", "of", "the", "merkle", "tree", "returning", "any", "head", "id", "used", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L204-L231
[ "def", "_set_root", "(", "self", ",", "request", ")", ":", "if", "request", ".", "state_root", ":", "root", "=", "request", ".", "state_root", "else", ":", "head", "=", "self", ".", "_get_chain_head", "(", ")", "root", "=", "head", ".", "state_root_hash"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._list_store_resources
Builds a list of blocks or resources derived from blocks, handling multiple possible filter requests: - filtered by a set of ids - filtered by head block - filtered by both id and head block - not filtered (all current resources) Note: This me...
validator/sawtooth_validator/state/client_handlers.py
def _list_store_resources(self, request, head_id, filter_ids, resource_fetcher, block_xform): """Builds a list of blocks or resources derived from blocks, handling multiple possible filter requests: - filtered by a set of ids - filtered by head block...
def _list_store_resources(self, request, head_id, filter_ids, resource_fetcher, block_xform): """Builds a list of blocks or resources derived from blocks, handling multiple possible filter requests: - filtered by a set of ids - filtered by head block...
[ "Builds", "a", "list", "of", "blocks", "or", "resources", "derived", "from", "blocks", "handling", "multiple", "possible", "filter", "requests", ":", "-", "filtered", "by", "a", "set", "of", "ids", "-", "filtered", "by", "head", "block", "-", "filtered", "...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L233-L294
[ "def", "_list_store_resources", "(", "self", ",", "request", ",", "head_id", ",", "filter_ids", ",", "resource_fetcher", ",", "block_xform", ")", ":", "resources", "=", "[", "]", "# Simply fetch by id if filtered by id but not by head block", "if", "filter_ids", "and", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._validate_ids
Validates a list of ids, raising a ResponseFailed error if invalid. Args: resource_id (list of str): The ids to validate Raises: ResponseFailed: The id was invalid, and a status of INVALID_ID will be sent with the response.
validator/sawtooth_validator/state/client_handlers.py
def _validate_ids(self, resource_ids): """Validates a list of ids, raising a ResponseFailed error if invalid. Args: resource_id (list of str): The ids to validate Raises: ResponseFailed: The id was invalid, and a status of INVALID_ID will be sent with th...
def _validate_ids(self, resource_ids): """Validates a list of ids, raising a ResponseFailed error if invalid. Args: resource_id (list of str): The ids to validate Raises: ResponseFailed: The id was invalid, and a status of INVALID_ID will be sent with th...
[ "Validates", "a", "list", "of", "ids", "raising", "a", "ResponseFailed", "error", "if", "invalid", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L296-L309
[ "def", "_validate_ids", "(", "self", ",", "resource_ids", ")", ":", "for", "resource_id", "in", "resource_ids", ":", "if", "self", ".", "_id_regex", ".", "fullmatch", "(", "resource_id", ")", "is", "None", ":", "LOGGER", ".", "debug", "(", "'Invalid resource...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._validate_state_root
Validates a state root, raising a ResponseFailed error if invalid. Args: state_root (str): The state_root to validate Raises: ResponseFailed: The state_root was invalid, and a status of INVALID_ROOT will be sent with the response.
validator/sawtooth_validator/state/client_handlers.py
def _validate_state_root(self, state_root): """Validates a state root, raising a ResponseFailed error if invalid. Args: state_root (str): The state_root to validate Raises: ResponseFailed: The state_root was invalid, and a status of INVALID_ROOT will be ...
def _validate_state_root(self, state_root): """Validates a state root, raising a ResponseFailed error if invalid. Args: state_root (str): The state_root to validate Raises: ResponseFailed: The state_root was invalid, and a status of INVALID_ROOT will be ...
[ "Validates", "a", "state", "root", "raising", "a", "ResponseFailed", "error", "if", "invalid", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L311-L323
[ "def", "_validate_state_root", "(", "self", ",", "state_root", ")", ":", "if", "self", ".", "_state_root_regex", ".", "fullmatch", "(", "state_root", ")", "is", "None", ":", "LOGGER", ".", "debug", "(", "'Invalid state root: %s'", ",", "state_root", ")", "rais...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_ClientRequestHandler._validate_namespace
Validates a namespace, raising a ResponseFailed error if invalid. Args: state_root (str): The state_root to validate Raises: ResponseFailed: The state_root was invalid, and a status of INVALID_ROOT will be sent with the response.
validator/sawtooth_validator/state/client_handlers.py
def _validate_namespace(self, namespace): """Validates a namespace, raising a ResponseFailed error if invalid. Args: state_root (str): The state_root to validate Raises: ResponseFailed: The state_root was invalid, and a status of INVALID_ROOT will be sen...
def _validate_namespace(self, namespace): """Validates a namespace, raising a ResponseFailed error if invalid. Args: state_root (str): The state_root to validate Raises: ResponseFailed: The state_root was invalid, and a status of INVALID_ROOT will be sen...
[ "Validates", "a", "namespace", "raising", "a", "ResponseFailed", "error", "if", "invalid", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L325-L337
[ "def", "_validate_namespace", "(", "self", ",", "namespace", ")", ":", "if", "self", ".", "_namespace_regex", ".", "fullmatch", "(", "namespace", ")", "is", "None", ":", "LOGGER", ".", "debug", "(", "'Invalid namespace: %s'", ",", "namespace", ")", "raise", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_Pager.paginate_resources
Truncates a list of resources based on ClientPagingControls Args: request (object): The parsed protobuf request object resources (list of objects): The resources to be paginated Returns: list: The paginated list of resources object: The ClientPagingRespo...
validator/sawtooth_validator/state/client_handlers.py
def paginate_resources(cls, request, resources, on_fail_status): """Truncates a list of resources based on ClientPagingControls Args: request (object): The parsed protobuf request object resources (list of objects): The resources to be paginated Returns: lis...
def paginate_resources(cls, request, resources, on_fail_status): """Truncates a list of resources based on ClientPagingControls Args: request (object): The parsed protobuf request object resources (list of objects): The resources to be paginated Returns: lis...
[ "Truncates", "a", "list", "of", "resources", "based", "on", "ClientPagingControls" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L349-L388
[ "def", "paginate_resources", "(", "cls", ",", "request", ",", "resources", ",", "on_fail_status", ")", ":", "if", "not", "resources", ":", "return", "(", "resources", ",", "client_list_control_pb2", ".", "ClientPagingResponse", "(", ")", ")", "paging", "=", "r...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_Pager.index_by_id
Helper method to fetch the index of a resource by its id or address Args: resources (list of objects): The resources to be paginated target_id (string): The address or header_signature of the resource Returns: integer: The index of the target resource Raise...
validator/sawtooth_validator/state/client_handlers.py
def index_by_id(cls, target_id, resources): """Helper method to fetch the index of a resource by its id or address Args: resources (list of objects): The resources to be paginated target_id (string): The address or header_signature of the resource Returns: i...
def index_by_id(cls, target_id, resources): """Helper method to fetch the index of a resource by its id or address Args: resources (list of objects): The resources to be paginated target_id (string): The address or header_signature of the resource Returns: i...
[ "Helper", "method", "to", "fetch", "the", "index", "of", "a", "resource", "by", "its", "id", "or", "address" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L391-L408
[ "def", "index_by_id", "(", "cls", ",", "target_id", ",", "resources", ")", ":", "for", "index", "in", "range", "(", "len", "(", "resources", ")", ")", ":", "if", "cls", ".", "id_by_index", "(", "index", ",", "resources", ")", "==", "target_id", ":", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_Pager.id_by_index
Helper method to fetch the id or address of a resource by its index Args: resources (list of objects): The resources to be paginated index (integer): The index of the target resource Returns: str: The address or header_signature of the resource, retu...
validator/sawtooth_validator/state/client_handlers.py
def id_by_index(index, resources): """Helper method to fetch the id or address of a resource by its index Args: resources (list of objects): The resources to be paginated index (integer): The index of the target resource Returns: str: The address or header_s...
def id_by_index(index, resources): """Helper method to fetch the id or address of a resource by its index Args: resources (list of objects): The resources to be paginated index (integer): The index of the target resource Returns: str: The address or header_s...
[ "Helper", "method", "to", "fetch", "the", "id", "or", "address", "of", "a", "resource", "by", "its", "index" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L411-L428
[ "def", "id_by_index", "(", "index", ",", "resources", ")", ":", "if", "index", "<", "0", "or", "index", ">=", "len", "(", "resources", ")", ":", "return", "''", "try", ":", "return", "resources", "[", "index", "]", ".", "header_signature", "except", "A...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_Sorter.sort_resources
Sorts a list of resources based on a list of sort controls Args: request (object): The parsed protobuf request object resources (list of objects): The resources to be sorted fail_enum (int, enum): The enum status to raise with invalid keys header_proto(class): Cl...
validator/sawtooth_validator/state/client_handlers.py
def sort_resources(cls, request, resources, fail_enum, header_proto=None): """Sorts a list of resources based on a list of sort controls Args: request (object): The parsed protobuf request object resources (list of objects): The resources to be sorted fail_enum (int,...
def sort_resources(cls, request, resources, fail_enum, header_proto=None): """Sorts a list of resources based on a list of sort controls Args: request (object): The parsed protobuf request object resources (list of objects): The resources to be sorted fail_enum (int,...
[ "Sorts", "a", "list", "of", "resources", "based", "on", "a", "list", "of", "sort", "controls" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L437-L465
[ "def", "sort_resources", "(", "cls", ",", "request", ",", "resources", ",", "fail_enum", ",", "header_proto", "=", "None", ")", ":", "if", "not", "request", ".", "sorting", ":", "return", "resources", "value_handlers", "=", "cls", ".", "_get_handler_set", "(...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_Sorter._get_handler_set
Goes through the list of ClientSortControls and returns a list of unique _ValueHandlers. Maintains order, but drops ClientSortControls that have already appeared to help prevent spamming.
validator/sawtooth_validator/state/client_handlers.py
def _get_handler_set(cls, request, fail_enum, header_proto=None): """Goes through the list of ClientSortControls and returns a list of unique _ValueHandlers. Maintains order, but drops ClientSortControls that have already appeared to help prevent spamming. """ added = set() ...
def _get_handler_set(cls, request, fail_enum, header_proto=None): """Goes through the list of ClientSortControls and returns a list of unique _ValueHandlers. Maintains order, but drops ClientSortControls that have already appeared to help prevent spamming. """ added = set() ...
[ "Goes", "through", "the", "list", "of", "ClientSortControls", "and", "returns", "a", "list", "of", "unique", "_ValueHandlers", ".", "Maintains", "order", "but", "drops", "ClientSortControls", "that", "have", "already", "appeared", "to", "help", "prevent", "spammin...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L468-L483
[ "def", "_get_handler_set", "(", "cls", ",", "request", ",", "fail_enum", ",", "header_proto", "=", "None", ")", ":", "added", "=", "set", "(", ")", "handlers", "=", "[", "]", "for", "controls", "in", "request", ".", "sorting", ":", "control_bytes", "=", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_BatchWaiter.notify_batches_finished
Called by the BatchTracker the _BatchWaiter is observing. Should not be called by handlers. Args: statuses (dict of int): A dict with keys of batch ids, and values of status enums
validator/sawtooth_validator/state/client_handlers.py
def notify_batches_finished(self, statuses): """Called by the BatchTracker the _BatchWaiter is observing. Should not be called by handlers. Args: statuses (dict of int): A dict with keys of batch ids, and values of status enums """ with self._wait_con...
def notify_batches_finished(self, statuses): """Called by the BatchTracker the _BatchWaiter is observing. Should not be called by handlers. Args: statuses (dict of int): A dict with keys of batch ids, and values of status enums """ with self._wait_con...
[ "Called", "by", "the", "BatchTracker", "the", "_BatchWaiter", "is", "observing", ".", "Should", "not", "be", "called", "by", "handlers", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L597-L607
[ "def", "notify_batches_finished", "(", "self", ",", "statuses", ")", ":", "with", "self", ".", "_wait_condition", ":", "self", ".", "_statuses", "=", "statuses", "self", ".", "_wait_condition", ".", "notify", "(", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
_BatchWaiter.wait_for_batches
Locks until a list of batch ids is committed to the block chain or a timeout is exceeded. Returns the statuses of those batches. Args: batch_ids (list of str): The ids of the batches to wait for timeout(int): Maximum time in seconds to wait for Returns: list...
validator/sawtooth_validator/state/client_handlers.py
def wait_for_batches(self, batch_ids, timeout=None): """Locks until a list of batch ids is committed to the block chain or a timeout is exceeded. Returns the statuses of those batches. Args: batch_ids (list of str): The ids of the batches to wait for timeout(int): Maximu...
def wait_for_batches(self, batch_ids, timeout=None): """Locks until a list of batch ids is committed to the block chain or a timeout is exceeded. Returns the statuses of those batches. Args: batch_ids (list of str): The ids of the batches to wait for timeout(int): Maximu...
[ "Locks", "until", "a", "list", "of", "batch", "ids", "is", "committed", "to", "the", "block", "chain", "or", "a", "timeout", "is", "exceeded", ".", "Returns", "the", "statuses", "of", "those", "batches", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/state/client_handlers.py#L610-L636
[ "def", "wait_for_batches", "(", "self", ",", "batch_ids", ",", "timeout", "=", "None", ")", ":", "self", ".", "_batch_tracker", ".", "watch_statuses", "(", "self", ",", "batch_ids", ")", "timeout", "=", "timeout", "or", "DEFAULT_TIMEOUT", "start_time", "=", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
check_directory
Verify that the directory exists and is readable and writable. Args: path (str): a directory which should exist and be writable human_readable_name (str): a human readable string for the directory which is used in logging statements Returns: bool: False if an error exists, ...
validator/sawtooth_validator/server/cli.py
def check_directory(path, human_readable_name): """Verify that the directory exists and is readable and writable. Args: path (str): a directory which should exist and be writable human_readable_name (str): a human readable string for the directory which is used in logging statements...
def check_directory(path, human_readable_name): """Verify that the directory exists and is readable and writable. Args: path (str): a directory which should exist and be writable human_readable_name (str): a human readable string for the directory which is used in logging statements...
[ "Verify", "that", "the", "directory", "exists", "and", "is", "readable", "and", "writable", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/server/cli.py#L46-L80
[ "def", "check_directory", "(", "path", ",", "human_readable_name", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "LOGGER", ".", "error", "(", "\"%s directory does not exist: %s\"", ",", "human_readable_name", ",", "path", ")",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_identity_parser
Creates the arg parsers needed for the identity command and its subcommands.
cli/sawtooth_cli/identity.py
def add_identity_parser(subparsers, parent_parser): """Creates the arg parsers needed for the identity command and its subcommands. """ # identity parser = subparsers.add_parser( 'identity', help='Works with optional roles, policies, and permissions', description='Provides su...
def add_identity_parser(subparsers, parent_parser): """Creates the arg parsers needed for the identity command and its subcommands. """ # identity parser = subparsers.add_parser( 'identity', help='Works with optional roles, policies, and permissions', description='Provides su...
[ "Creates", "the", "arg", "parsers", "needed", "for", "the", "identity", "command", "and", "its", "subcommands", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/identity.py#L61-L226
[ "def", "add_identity_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "# identity", "parser", "=", "subparsers", ".", "add_parser", "(", "'identity'", ",", "help", "=", "'Works with optional roles, policies, and permissions'", ",", "description", "=", "'Provi...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_identity
Executes the config commands subcommands.
cli/sawtooth_cli/identity.py
def do_identity(args): """Executes the config commands subcommands. """ if args.subcommand == 'policy' and args.policy_cmd == 'create': _do_identity_policy_create(args) elif args.subcommand == 'policy' and args.policy_cmd == 'list': _do_identity_policy_list(args) elif args.subcommand...
def do_identity(args): """Executes the config commands subcommands. """ if args.subcommand == 'policy' and args.policy_cmd == 'create': _do_identity_policy_create(args) elif args.subcommand == 'policy' and args.policy_cmd == 'list': _do_identity_policy_list(args) elif args.subcommand...
[ "Executes", "the", "config", "commands", "subcommands", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/identity.py#L229-L243
[ "def", "do_identity", "(", "args", ")", ":", "if", "args", ".", "subcommand", "==", "'policy'", "and", "args", ".", "policy_cmd", "==", "'create'", ":", "_do_identity_policy_create", "(", "args", ")", "elif", "args", ".", "subcommand", "==", "'policy'", "and...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_do_identity_policy_create
Executes the 'policy create' subcommand. Given a key file, and a series of entries, it generates a batch of sawtooth_identity transactions in a BatchList instance. The BatchList is either stored to a file or submitted to a validator, depending on the supplied CLI arguments.
cli/sawtooth_cli/identity.py
def _do_identity_policy_create(args): """Executes the 'policy create' subcommand. Given a key file, and a series of entries, it generates a batch of sawtooth_identity transactions in a BatchList instance. The BatchList is either stored to a file or submitted to a validator, depending on the supplied CL...
def _do_identity_policy_create(args): """Executes the 'policy create' subcommand. Given a key file, and a series of entries, it generates a batch of sawtooth_identity transactions in a BatchList instance. The BatchList is either stored to a file or submitted to a validator, depending on the supplied CL...
[ "Executes", "the", "policy", "create", "subcommand", ".", "Given", "a", "key", "file", "and", "a", "series", "of", "entries", "it", "generates", "a", "batch", "of", "sawtooth_identity", "transactions", "in", "a", "BatchList", "instance", ".", "The", "BatchList...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/identity.py#L246-L294
[ "def", "_do_identity_policy_create", "(", "args", ")", ":", "signer", "=", "_read_signer", "(", "args", ".", "key", ")", "txns", "=", "[", "_create_policy_txn", "(", "signer", ",", "args", ".", "name", ",", "args", ".", "rule", ")", "]", "batch", "=", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_do_identity_role_list
Lists the current on-chain configuration values.
cli/sawtooth_cli/identity.py
def _do_identity_role_list(args): """Lists the current on-chain configuration values. """ rest_client = RestClient(args.url) state = rest_client.list_state(subtree=IDENTITY_NAMESPACE + _ROLE_PREFIX) head = state['head'] state_values = state['data'] printable_roles = [] for state_value i...
def _do_identity_role_list(args): """Lists the current on-chain configuration values. """ rest_client = RestClient(args.url) state = rest_client.list_state(subtree=IDENTITY_NAMESPACE + _ROLE_PREFIX) head = state['head'] state_values = state['data'] printable_roles = [] for state_value i...
[ "Lists", "the", "current", "on", "-", "chain", "configuration", "values", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/identity.py#L414-L462
[ "def", "_do_identity_role_list", "(", "args", ")", ":", "rest_client", "=", "RestClient", "(", "args", ".", "url", ")", "state", "=", "rest_client", ".", "list_state", "(", "subtree", "=", "IDENTITY_NAMESPACE", "+", "_ROLE_PREFIX", ")", "head", "=", "state", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_read_signer
Reads the given file as a hex key. Args: key_filename: The filename where the key is stored. If None, defaults to the default key for the current user. Returns: Signer: the signer Raises: CliException: If unable to read the file.
cli/sawtooth_cli/identity.py
def _read_signer(key_filename): """Reads the given file as a hex key. Args: key_filename: The filename where the key is stored. If None, defaults to the default key for the current user. Returns: Signer: the signer Raises: CliException: If unable to read the file. ...
def _read_signer(key_filename): """Reads the given file as a hex key. Args: key_filename: The filename where the key is stored. If None, defaults to the default key for the current user. Returns: Signer: the signer Raises: CliException: If unable to read the file. ...
[ "Reads", "the", "given", "file", "as", "a", "hex", "key", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/identity.py#L535-L568
[ "def", "_read_signer", "(", "key_filename", ")", ":", "filename", "=", "key_filename", "if", "filename", "is", "None", ":", "filename", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", ",", "'.sawtooth'", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_create_batch
Creates a batch from a list of transactions and a public key, and signs the resulting batch with the given signing key. Args: signer (:obj:`Signer`): The cryptographic signer transactions (list of `Transaction`): The transactions to add to the batch. Returns: `Batch`: T...
cli/sawtooth_cli/identity.py
def _create_batch(signer, transactions): """Creates a batch from a list of transactions and a public key, and signs the resulting batch with the given signing key. Args: signer (:obj:`Signer`): The cryptographic signer transactions (list of `Transaction`): The transactions to add to the ...
def _create_batch(signer, transactions): """Creates a batch from a list of transactions and a public key, and signs the resulting batch with the given signing key. Args: signer (:obj:`Signer`): The cryptographic signer transactions (list of `Transaction`): The transactions to add to the ...
[ "Creates", "a", "batch", "from", "a", "list", "of", "transactions", "and", "a", "public", "key", "and", "signs", "the", "resulting", "batch", "with", "the", "given", "signing", "key", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/identity.py#L571-L591
[ "def", "_create_batch", "(", "signer", ",", "transactions", ")", ":", "txn_ids", "=", "[", "txn", ".", "header_signature", "for", "txn", "in", "transactions", "]", "batch_header", "=", "BatchHeader", "(", "signer_public_key", "=", "signer", ".", "get_public_key"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.create_context
Create a ExecutionContext to run a transaction against. Args: state_hash: (str): Merkle root to base state on. base_contexts (list of str): Context ids of contexts that will have their state applied to make this context. inputs (list of str): Addresses that c...
validator/sawtooth_validator/execution/context_manager.py
def create_context(self, state_hash, base_contexts, inputs, outputs): """Create a ExecutionContext to run a transaction against. Args: state_hash: (str): Merkle root to base state on. base_contexts (list of str): Context ids of contexts that will have their state...
def create_context(self, state_hash, base_contexts, inputs, outputs): """Create a ExecutionContext to run a transaction against. Args: state_hash: (str): Merkle root to base state on. base_contexts (list of str): Context ids of contexts that will have their state...
[ "Create", "a", "ExecutionContext", "to", "run", "a", "transaction", "against", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L89-L141
[ "def", "create_context", "(", "self", ",", "state_hash", ",", "base_contexts", ",", "inputs", ",", "outputs", ")", ":", "for", "address", "in", "inputs", ":", "if", "not", "self", ".", "namespace_is_valid", "(", "address", ")", ":", "raise", "CreateContextEx...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager._find_address_values_in_chain
Breadth first search through the chain of contexts searching for the bytes values at the addresses in addresses_to_find. Args: base_contexts (list of str): The context ids to start with. addresses_to_find (list of str): Addresses to find values in the chain of co...
validator/sawtooth_validator/execution/context_manager.py
def _find_address_values_in_chain(self, base_contexts, addresses_to_find): """Breadth first search through the chain of contexts searching for the bytes values at the addresses in addresses_to_find. Args: base_contexts (list of str): The context ids to start with. addres...
def _find_address_values_in_chain(self, base_contexts, addresses_to_find): """Breadth first search through the chain of contexts searching for the bytes values at the addresses in addresses_to_find. Args: base_contexts (list of str): The context ids to start with. addres...
[ "Breadth", "first", "search", "through", "the", "chain", "of", "contexts", "searching", "for", "the", "bytes", "values", "at", "the", "addresses", "in", "addresses_to_find", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L143-L214
[ "def", "_find_address_values_in_chain", "(", "self", ",", "base_contexts", ",", "addresses_to_find", ")", ":", "contexts_in_chain", "=", "deque", "(", ")", "contexts_in_chain", ".", "extend", "(", "base_contexts", ")", "reads", "=", "list", "(", "addresses_to_find",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.delete_contexts
Delete contexts from the ContextManager. Args: context_id_list (list): a list of context ids Returns: None
validator/sawtooth_validator/execution/context_manager.py
def delete_contexts(self, context_id_list): """Delete contexts from the ContextManager. Args: context_id_list (list): a list of context ids Returns: None """ for c_id in context_id_list: if c_id in self._contexts: del self._c...
def delete_contexts(self, context_id_list): """Delete contexts from the ContextManager. Args: context_id_list (list): a list of context ids Returns: None """ for c_id in context_id_list: if c_id in self._contexts: del self._c...
[ "Delete", "contexts", "from", "the", "ContextManager", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L216-L228
[ "def", "delete_contexts", "(", "self", ",", "context_id_list", ")", ":", "for", "c_id", "in", "context_id_list", ":", "if", "c_id", "in", "self", ".", "_contexts", ":", "del", "self", ".", "_contexts", "[", "c_id", "]" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.delete
Delete the values associated with list of addresses, for a specific context referenced by context_id. Args: context_id (str): the return value of create_context, referencing a particular context. address_list (list): a list of address strs Returns: ...
validator/sawtooth_validator/execution/context_manager.py
def delete(self, context_id, address_list): """Delete the values associated with list of addresses, for a specific context referenced by context_id. Args: context_id (str): the return value of create_context, referencing a particular context. address_list...
def delete(self, context_id, address_list): """Delete the values associated with list of addresses, for a specific context referenced by context_id. Args: context_id (str): the return value of create_context, referencing a particular context. address_list...
[ "Delete", "the", "values", "associated", "with", "list", "of", "addresses", "for", "a", "specific", "context", "referenced", "by", "context_id", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L230-L262
[ "def", "delete", "(", "self", ",", "context_id", ",", "address_list", ")", ":", "if", "context_id", "not", "in", "self", ".", "_contexts", ":", "return", "False", "context", "=", "self", ".", "_contexts", "[", "context_id", "]", "for", "add", "in", "addr...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.get
Get the values associated with list of addresses, for a specific context referenced by context_id. Args: context_id (str): the return value of create_context, referencing a particular context. address_list (list): a list of address strs Returns: ...
validator/sawtooth_validator/execution/context_manager.py
def get(self, context_id, address_list): """Get the values associated with list of addresses, for a specific context referenced by context_id. Args: context_id (str): the return value of create_context, referencing a particular context. address_list (list...
def get(self, context_id, address_list): """Get the values associated with list of addresses, for a specific context referenced by context_id. Args: context_id (str): the return value of create_context, referencing a particular context. address_list (list...
[ "Get", "the", "values", "associated", "with", "list", "of", "addresses", "for", "a", "specific", "context", "referenced", "by", "context_id", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L264-L329
[ "def", "get", "(", "self", ",", "context_id", ",", "address_list", ")", ":", "if", "context_id", "not", "in", "self", ".", "_contexts", ":", "return", "[", "]", "for", "add", "in", "address_list", ":", "if", "not", "self", ".", "address_is_valid", "(", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.set
Within a context, sets addresses to a value. Args: context_id (str): the context id returned by create_context address_value_list (list): list of {address: value} dicts Returns: (bool): True if the operation is successful, False if the context_id doe...
validator/sawtooth_validator/execution/context_manager.py
def set(self, context_id, address_value_list): """Within a context, sets addresses to a value. Args: context_id (str): the context id returned by create_context address_value_list (list): list of {address: value} dicts Returns: (bool): True if the operation ...
def set(self, context_id, address_value_list): """Within a context, sets addresses to a value. Args: context_id (str): the context id returned by create_context address_value_list (list): list of {address: value} dicts Returns: (bool): True if the operation ...
[ "Within", "a", "context", "sets", "addresses", "to", "a", "value", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L331-L363
[ "def", "set", "(", "self", ",", "context_id", ",", "address_value_list", ")", ":", "if", "context_id", "not", "in", "self", ".", "_contexts", ":", "LOGGER", ".", "warning", "(", "\"Context_id not in contexts, %s\"", ",", "context_id", ")", "return", "False", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.add_execution_data
Within a context, append data to the execution result. Args: context_id (str): the context id returned by create_context data (bytes): data to append Returns: (bool): True if the operation is successful, False if the context_id doesn't reference a kn...
validator/sawtooth_validator/execution/context_manager.py
def add_execution_data(self, context_id, data): """Within a context, append data to the execution result. Args: context_id (str): the context id returned by create_context data (bytes): data to append Returns: (bool): True if the operation is successful, Fal...
def add_execution_data(self, context_id, data): """Within a context, append data to the execution result. Args: context_id (str): the context id returned by create_context data (bytes): data to append Returns: (bool): True if the operation is successful, Fal...
[ "Within", "a", "context", "append", "data", "to", "the", "execution", "result", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L423-L440
[ "def", "add_execution_data", "(", "self", ",", "context_id", ",", "data", ")", ":", "if", "context_id", "not", "in", "self", ".", "_contexts", ":", "LOGGER", ".", "warning", "(", "\"Context_id not in contexts, %s\"", ",", "context_id", ")", "return", "False", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ContextManager.add_execution_event
Within a context, append data to the execution result. Args: context_id (str): the context id returned by create_context data_type (str): type of data to append data (bytes): data to append Returns: (bool): True if the operation is successful, False if ...
validator/sawtooth_validator/execution/context_manager.py
def add_execution_event(self, context_id, event): """Within a context, append data to the execution result. Args: context_id (str): the context id returned by create_context data_type (str): type of data to append data (bytes): data to append Returns: ...
def add_execution_event(self, context_id, event): """Within a context, append data to the execution result. Args: context_id (str): the context id returned by create_context data_type (str): type of data to append data (bytes): data to append Returns: ...
[ "Within", "a", "context", "append", "data", "to", "the", "execution", "result", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/context_manager.py#L442-L460
[ "def", "add_execution_event", "(", "self", ",", "context_id", ",", "event", ")", ":", "if", "context_id", "not", "in", "self", ".", "_contexts", ":", "LOGGER", ".", "warning", "(", "\"Context_id not in contexts, %s\"", ",", "context_id", ")", "return", "False", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
IndexedDatabase.update
Applies the given puts and deletes atomically. Args: puts (:iterable:`tuple`): an iterable of key/value pairs to insert deletes (:iterable:str:) an iterable of keys to delete
validator/sawtooth_validator/database/indexed_database.py
def update(self, puts, deletes): """Applies the given puts and deletes atomically. Args: puts (:iterable:`tuple`): an iterable of key/value pairs to insert deletes (:iterable:str:) an iterable of keys to delete """ with self._lmdb.begin(write=True, buffers=True) ...
def update(self, puts, deletes): """Applies the given puts and deletes atomically. Args: puts (:iterable:`tuple`): an iterable of key/value pairs to insert deletes (:iterable:str:) an iterable of keys to delete """ with self._lmdb.begin(write=True, buffers=True) ...
[ "Applies", "the", "given", "puts", "and", "deletes", "atomically", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/database/indexed_database.py#L182-L220
[ "def", "update", "(", "self", ",", "puts", ",", "deletes", ")", ":", "with", "self", ".", "_lmdb", ".", "begin", "(", "write", "=", "True", ",", "buffers", "=", "True", ")", "as", "txn", ":", "cursor", "=", "txn", ".", "cursor", "(", "self", ".",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
IndexedDatabase.keys
Returns a list of keys in the database
validator/sawtooth_validator/database/indexed_database.py
def keys(self, index=None): """Returns a list of keys in the database """ if index is not None and index not in self._indexes: raise ValueError('Index {} does not exist'.format(index)) db = self._indexes[index][0] if index else self._main_db with self._lmdb.begin(db=...
def keys(self, index=None): """Returns a list of keys in the database """ if index is not None and index not in self._indexes: raise ValueError('Index {} does not exist'.format(index)) db = self._indexes[index][0] if index else self._main_db with self._lmdb.begin(db=...
[ "Returns", "a", "list", "of", "keys", "in", "the", "database" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/database/indexed_database.py#L232-L243
[ "def", "keys", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "not", "None", "and", "index", "not", "in", "self", ".", "_indexes", ":", "raise", "ValueError", "(", "'Index {} does not exist'", ".", "format", "(", "index", ")", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
BatchPublisher.send
Package up transactions into a batch and send them to the network via the provided batch_sender. :param transactions: list of transactions to package and broadcast. :return: None
validator/sawtooth_validator/journal/consensus/batch_publisher.py
def send(self, transactions): """ Package up transactions into a batch and send them to the network via the provided batch_sender. :param transactions: list of transactions to package and broadcast. :return: None """ txn_signatures = [txn.header_signature for txn in trans...
def send(self, transactions): """ Package up transactions into a batch and send them to the network via the provided batch_sender. :param transactions: list of transactions to package and broadcast. :return: None """ txn_signatures = [txn.header_signature for txn in trans...
[ "Package", "up", "transactions", "into", "a", "batch", "and", "send", "them", "to", "the", "network", "via", "the", "provided", "batch_sender", ".", ":", "param", "transactions", ":", "list", "of", "transactions", "to", "package", "and", "broadcast", ".", ":...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/batch_publisher.py#L38-L56
[ "def", "send", "(", "self", ",", "transactions", ")", ":", "txn_signatures", "=", "[", "txn", ".", "header_signature", "for", "txn", "in", "transactions", "]", "header", "=", "BatchHeader", "(", "signer_public_key", "=", "self", ".", "_identity_signer", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
base_multinode_parser
Creates a parser with arguments specific to sending HTTP requests to multiple REST APIs. Returns: {ArgumentParser}: Base parser with default HTTP args
cli/sawtooth_cli/network_command/parent_parsers.py
def base_multinode_parser(): """Creates a parser with arguments specific to sending HTTP requests to multiple REST APIs. Returns: {ArgumentParser}: Base parser with default HTTP args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( 'urls', type...
def base_multinode_parser(): """Creates a parser with arguments specific to sending HTTP requests to multiple REST APIs. Returns: {ArgumentParser}: Base parser with default HTTP args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( 'urls', type...
[ "Creates", "a", "parser", "with", "arguments", "specific", "to", "sending", "HTTP", "requests", "to", "multiple", "REST", "APIs", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/parent_parsers.py#L42-L66
[ "def", "base_multinode_parser", "(", ")", ":", "base_parser", "=", "ArgumentParser", "(", "add_help", "=", "False", ")", "base_parser", ".", "add_argument", "(", "'urls'", ",", "type", "=", "str", ",", "nargs", "=", "'+'", ",", "help", "=", "\"The URLs of th...
8cf473bc2207e51f02bd182d825158a57d72b098
train
base_http_parser
Creates a parser with arguments specific to sending an HTTP request to the REST API. Returns: {ArgumentParser}: Base parser with default HTTP args
cli/sawtooth_cli/parent_parsers.py
def base_http_parser(): """Creates a parser with arguments specific to sending an HTTP request to the REST API. Returns: {ArgumentParser}: Base parser with default HTTP args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( '--url', type=str, ...
def base_http_parser(): """Creates a parser with arguments specific to sending an HTTP request to the REST API. Returns: {ArgumentParser}: Base parser with default HTTP args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( '--url', type=str, ...
[ "Creates", "a", "parser", "with", "arguments", "specific", "to", "sending", "an", "HTTP", "request", "to", "the", "REST", "API", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/parent_parsers.py#L19-L39
[ "def", "base_http_parser", "(", ")", ":", "base_parser", "=", "ArgumentParser", "(", "add_help", "=", "False", ")", "base_parser", ".", "add_argument", "(", "'--url'", ",", "type", "=", "str", ",", "help", "=", "\"identify the URL of the validator's REST API \"", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
base_list_parser
Creates a parser with arguments specific to formatting lists of resources. Returns: {ArgumentParser}: Base parser with defaul list args
cli/sawtooth_cli/parent_parsers.py
def base_list_parser(): """Creates a parser with arguments specific to formatting lists of resources. Returns: {ArgumentParser}: Base parser with defaul list args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( '-F', '--format', action='store'...
def base_list_parser(): """Creates a parser with arguments specific to formatting lists of resources. Returns: {ArgumentParser}: Base parser with defaul list args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( '-F', '--format', action='store'...
[ "Creates", "a", "parser", "with", "arguments", "specific", "to", "formatting", "lists", "of", "resources", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/parent_parsers.py#L42-L58
[ "def", "base_list_parser", "(", ")", ":", "base_parser", "=", "ArgumentParser", "(", "add_help", "=", "False", ")", "base_parser", ".", "add_argument", "(", "'-F'", ",", "'--format'", ",", "action", "=", "'store'", ",", "default", "=", "'default'", ",", "cho...
8cf473bc2207e51f02bd182d825158a57d72b098
train
base_show_parser
Creates a parser with arguments specific to formatting a single resource. Returns: {ArgumentParser}: Base parser with default show args
cli/sawtooth_cli/parent_parsers.py
def base_show_parser(): """Creates a parser with arguments specific to formatting a single resource. Returns: {ArgumentParser}: Base parser with default show args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( '-k', '--key', type=str, ...
def base_show_parser(): """Creates a parser with arguments specific to formatting a single resource. Returns: {ArgumentParser}: Base parser with default show args """ base_parser = ArgumentParser(add_help=False) base_parser.add_argument( '-k', '--key', type=str, ...
[ "Creates", "a", "parser", "with", "arguments", "specific", "to", "formatting", "a", "single", "resource", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/parent_parsers.py#L61-L81
[ "def", "base_show_parser", "(", ")", ":", "base_parser", "=", "ArgumentParser", "(", "add_help", "=", "False", ")", "base_parser", ".", "add_argument", "(", "'-k'", ",", "'--key'", ",", "type", "=", "str", ",", "help", "=", "'show a single property from the bloc...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusProxy.get_block_statuses
Returns a list of tuples of (block id, BlockStatus) pairs.
validator/sawtooth_validator/consensus/proxy.py
def get_block_statuses(self, block_ids): """Returns a list of tuples of (block id, BlockStatus) pairs. """ try: return [ (block_id.hex(), self._chain_controller.block_validation_result( block_id.hex())) for block_i...
def get_block_statuses(self, block_ids): """Returns a list of tuples of (block id, BlockStatus) pairs. """ try: return [ (block_id.hex(), self._chain_controller.block_validation_result( block_id.hex())) for block_i...
[ "Returns", "a", "list", "of", "tuples", "of", "(", "block", "id", "BlockStatus", ")", "pairs", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/consensus/proxy.py#L207-L218
[ "def", "get_block_statuses", "(", "self", ",", "block_ids", ")", ":", "try", ":", "return", "[", "(", "block_id", ".", "hex", "(", ")", ",", "self", ".", "_chain_controller", ".", "block_validation_result", "(", "block_id", ".", "hex", "(", ")", ")", ")"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusProxy.settings_get
Returns a list of key/value pairs (str, str).
validator/sawtooth_validator/consensus/proxy.py
def settings_get(self, block_id, settings): '''Returns a list of key/value pairs (str, str).''' block = self._get_blocks([block_id.hex()])[0] block_header = BlockHeader() block_header.ParseFromString(block.header) try: settings_view = self._settings_view_factory.cr...
def settings_get(self, block_id, settings): '''Returns a list of key/value pairs (str, str).''' block = self._get_blocks([block_id.hex()])[0] block_header = BlockHeader() block_header.ParseFromString(block.header) try: settings_view = self._settings_view_factory.cr...
[ "Returns", "a", "list", "of", "key", "/", "value", "pairs", "(", "str", "str", ")", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/consensus/proxy.py#L266-L297
[ "def", "settings_get", "(", "self", ",", "block_id", ",", "settings", ")", ":", "block", "=", "self", ".", "_get_blocks", "(", "[", "block_id", ".", "hex", "(", ")", "]", ")", "[", "0", "]", "block_header", "=", "BlockHeader", "(", ")", "block_header",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusProxy.state_get
Returns a list of address/data pairs (str, bytes)
validator/sawtooth_validator/consensus/proxy.py
def state_get(self, block_id, addresses): '''Returns a list of address/data pairs (str, bytes)''' block = self._get_blocks([block_id.hex()])[0] block_header = BlockHeader() block_header.ParseFromString(block.header) try: state_view = self._state_view_factory.create_v...
def state_get(self, block_id, addresses): '''Returns a list of address/data pairs (str, bytes)''' block = self._get_blocks([block_id.hex()])[0] block_header = BlockHeader() block_header.ParseFromString(block.header) try: state_view = self._state_view_factory.create_v...
[ "Returns", "a", "list", "of", "address", "/", "data", "pairs", "(", "str", "bytes", ")" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/consensus/proxy.py#L299-L338
[ "def", "state_get", "(", "self", ",", "block_id", ",", "addresses", ")", ":", "block", "=", "self", ".", "_get_blocks", "(", "[", "block_id", ".", "hex", "(", ")", "]", ")", "[", "0", "]", "block_header", "=", "BlockHeader", "(", ")", "block_header", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_settings_parser
Creates the args parser needed for the settings command and its subcommands.
cli/sawtooth_cli/settings.py
def add_settings_parser(subparsers, parent_parser): """Creates the args parser needed for the settings command and its subcommands. """ # The following parser is for the settings subsection of commands. These # commands display information about the currently applied on-chain # settings. s...
def add_settings_parser(subparsers, parent_parser): """Creates the args parser needed for the settings command and its subcommands. """ # The following parser is for the settings subsection of commands. These # commands display information about the currently applied on-chain # settings. s...
[ "Creates", "the", "args", "parser", "needed", "for", "the", "settings", "command", "and", "its", "subcommands", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/settings.py#L38-L81
[ "def", "add_settings_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "# The following parser is for the settings subsection of commands. These", "# commands display information about the currently applied on-chain", "# settings.", "settings_parser", "=", "subparsers", ".", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_do_settings_list
Lists the current on-chain configuration values.
cli/sawtooth_cli/settings.py
def _do_settings_list(args): """Lists the current on-chain configuration values. """ rest_client = RestClient(args.url) state = rest_client.list_state(subtree=SETTINGS_NAMESPACE) prefix = args.filter head = state['head'] state_values = state['data'] printable_settings = [] proposal...
def _do_settings_list(args): """Lists the current on-chain configuration values. """ rest_client = RestClient(args.url) state = rest_client.list_state(subtree=SETTINGS_NAMESPACE) prefix = args.filter head = state['head'] state_values = state['data'] printable_settings = [] proposal...
[ "Lists", "the", "current", "on", "-", "chain", "configuration", "values", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/settings.py#L91-L147
[ "def", "_do_settings_list", "(", "args", ")", ":", "rest_client", "=", "RestClient", "(", "args", ".", "url", ")", "state", "=", "rest_client", ".", "list_state", "(", "subtree", "=", "SETTINGS_NAMESPACE", ")", "prefix", "=", "args", ".", "filter", "head", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_key_to_address
Creates the state address for a given setting key.
cli/sawtooth_cli/settings.py
def _key_to_address(key): """Creates the state address for a given setting key. """ key_parts = key.split('.', maxsplit=_MAX_KEY_PARTS - 1) key_parts.extend([''] * (_MAX_KEY_PARTS - len(key_parts))) return SETTINGS_NAMESPACE + ''.join(_short_hash(x) for x in key_parts)
def _key_to_address(key): """Creates the state address for a given setting key. """ key_parts = key.split('.', maxsplit=_MAX_KEY_PARTS - 1) key_parts.extend([''] * (_MAX_KEY_PARTS - len(key_parts))) return SETTINGS_NAMESPACE + ''.join(_short_hash(x) for x in key_parts)
[ "Creates", "the", "state", "address", "for", "a", "given", "setting", "key", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/settings.py#L150-L156
[ "def", "_key_to_address", "(", "key", ")", ":", "key_parts", "=", "key", ".", "split", "(", "'.'", ",", "maxsplit", "=", "_MAX_KEY_PARTS", "-", "1", ")", "key_parts", ".", "extend", "(", "[", "''", "]", "*", "(", "_MAX_KEY_PARTS", "-", "len", "(", "k...
8cf473bc2207e51f02bd182d825158a57d72b098
train
DefaultBatchInjectorFactory._create_injector
Returns a new batch injector
validator/sawtooth_validator/journal/batch_injector.py
def _create_injector(self, injector): """Returns a new batch injector""" if injector == "block_info": block_info_injector = importlib.import_module( "sawtooth_validator.journal.block_info_injector") return block_info_injector.BlockInfoInjector( se...
def _create_injector(self, injector): """Returns a new batch injector""" if injector == "block_info": block_info_injector = importlib.import_module( "sawtooth_validator.journal.block_info_injector") return block_info_injector.BlockInfoInjector( se...
[ "Returns", "a", "new", "batch", "injector" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/batch_injector.py#L84-L93
[ "def", "_create_injector", "(", "self", ",", "injector", ")", ":", "if", "injector", "==", "\"block_info\"", ":", "block_info_injector", "=", "importlib", ".", "import_module", "(", "\"sawtooth_validator.journal.block_info_injector\"", ")", "return", "block_info_injector"...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ChainController.on_block_received
This is exposed for unit tests, and should not be called directly.
validator/sawtooth_validator/journal/chain.py
def on_block_received(self, block_id): """This is exposed for unit tests, and should not be called directly. """ _libexec('chain_controller_on_block_received', self.pointer, ctypes.c_char_p(block_id.encode('utf-8')))
def on_block_received(self, block_id): """This is exposed for unit tests, and should not be called directly. """ _libexec('chain_controller_on_block_received', self.pointer, ctypes.c_char_p(block_id.encode('utf-8')))
[ "This", "is", "exposed", "for", "unit", "tests", "and", "should", "not", "be", "called", "directly", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/chain.py#L163-L167
[ "def", "on_block_received", "(", "self", ",", "block_id", ")", ":", "_libexec", "(", "'chain_controller_on_block_received'", ",", "self", ".", "pointer", ",", "ctypes", ".", "c_char_p", "(", "block_id", ".", "encode", "(", "'utf-8'", ")", ")", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_compare_chains_parser
Creates the arg parsers needed for the compare command.
cli/sawtooth_cli/network_command/compare.py
def add_compare_chains_parser(subparsers, parent_parser): """Creates the arg parsers needed for the compare command. """ parser = subparsers.add_parser( 'compare-chains', help='Compare chains from different nodes.', description=( 'Compute and display information about how...
def add_compare_chains_parser(subparsers, parent_parser): """Creates the arg parsers needed for the compare command. """ parser = subparsers.add_parser( 'compare-chains', help='Compare chains from different nodes.', description=( 'Compute and display information about how...
[ "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/compare.py#L27-L82
[ "def", "add_compare_chains_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'compare-chains'", ",", "help", "=", "'Compare chains from different nodes.'", ",", "description", "=", "(", "'Compute and displa...
8cf473bc2207e51f02bd182d825158a57d72b098
train
do_compare_chains
Calculates and outputs comparison between all nodes on the network.
cli/sawtooth_cli/network_command/compare.py
def do_compare_chains(args): """Calculates and outputs comparison between all nodes on the network.""" urls = split_comma_append_args(args.urls) users = split_comma_append_args(args.users) clients = make_rest_apis(urls, users) broken = [] chains, errors = get_chain_generators(clients, args.lim...
def do_compare_chains(args): """Calculates and outputs comparison between all nodes on the network.""" urls = split_comma_append_args(args.urls) users = split_comma_append_args(args.users) clients = make_rest_apis(urls, users) broken = [] chains, errors = get_chain_generators(clients, args.lim...
[ "Calculates", "and", "outputs", "comparison", "between", "all", "nodes", "on", "the", "network", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L85-L139
[ "def", "do_compare_chains", "(", "args", ")", ":", "urls", "=", "split_comma_append_args", "(", "args", ".", "urls", ")", "users", "=", "split_comma_append_args", "(", "args", ".", "users", ")", "clients", "=", "make_rest_apis", "(", "urls", ",", "users", ")...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_summary
Print out summary and per-node comparison data.
cli/sawtooth_cli/network_command/compare.py
def print_summary(graph, tails, node_id_map): """Print out summary and per-node comparison data.""" # Get comparison data heads = get_heads(tails) heights = get_heights(tails) max_height = max(heights) common_height, block_ids_at_common_height = get_common_height(tails) lags = get_lags(heigh...
def print_summary(graph, tails, node_id_map): """Print out summary and per-node comparison data.""" # Get comparison data heads = get_heads(tails) heights = get_heights(tails) max_height = max(heights) common_height, block_ids_at_common_height = get_common_height(tails) lags = get_lags(heigh...
[ "Print", "out", "summary", "and", "per", "-", "node", "comparison", "data", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L187-L237
[ "def", "print_summary", "(", "graph", ",", "tails", ",", "node_id_map", ")", ":", "# Get comparison data", "heads", "=", "get_heads", "(", "tails", ")", "heights", "=", "get_heights", "(", "tails", ")", "max_height", "=", "max", "(", "heights", ")", "common_...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_table
Print out a table of nodes and the blocks they have at each block height starting with the common ancestor.
cli/sawtooth_cli/network_command/compare.py
def print_table(graph, tails, node_id_map): """Print out a table of nodes and the blocks they have at each block height starting with the common ancestor.""" node_count = len(tails) # Get the width of the table columns num_col_width = max( floor(log(max(get_heights(tails)), 10)) + 1, ...
def print_table(graph, tails, node_id_map): """Print out a table of nodes and the blocks they have at each block height starting with the common ancestor.""" node_count = len(tails) # Get the width of the table columns num_col_width = max( floor(log(max(get_heights(tails)), 10)) + 1, ...
[ "Print", "out", "a", "table", "of", "nodes", "and", "the", "blocks", "they", "have", "at", "each", "block", "height", "starting", "with", "the", "common", "ancestor", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L247-L288
[ "def", "print_table", "(", "graph", ",", "tails", ",", "node_id_map", ")", ":", "node_count", "=", "len", "(", "tails", ")", "# Get the width of the table columns", "num_col_width", "=", "max", "(", "floor", "(", "log", "(", "max", "(", "get_heights", "(", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_tree
Print out a tree of blocks starting from the common ancestor.
cli/sawtooth_cli/network_command/compare.py
def print_tree(graph, tails, node_id_map): """Print out a tree of blocks starting from the common ancestor.""" # Example: # | # | 5 # * a {0, 1, 2, 3, 4} # | # | 6 # |\ # * | b {0, 1, 2, 3} # | * n {4} # | | # | | 7 # * | c {0, 1, 2, 3} # | * o {4} # | | ...
def print_tree(graph, tails, node_id_map): """Print out a tree of blocks starting from the common ancestor.""" # Example: # | # | 5 # * a {0, 1, 2, 3, 4} # | # | 6 # |\ # * | b {0, 1, 2, 3} # | * n {4} # | | # | | 7 # * | c {0, 1, 2, 3} # | * o {4} # | | ...
[ "Print", "out", "a", "tree", "of", "blocks", "starting", "from", "the", "common", "ancestor", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L291-L375
[ "def", "print_tree", "(", "graph", ",", "tails", ",", "node_id_map", ")", ":", "# Example:", "# |", "# | 5", "# * a {0, 1, 2, 3, 4}", "# |", "# | 6", "# |\\", "# * | b {0, 1, 2, 3}", "# | * n {4}", "# | |", "# | | 7", "# * | c {0, 1, 2, 3}", "# | * o {4}", "# | |",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
build_ordered_cliques
Order the new cliques based on the order of their ancestors in the previous iteration.
cli/sawtooth_cli/network_command/compare.py
def build_ordered_cliques(cliques, next_cliques): """Order the new cliques based on the order of their ancestors in the previous iteration.""" def sort_key(clique): return -len(clique[1]) if not cliques: return list(sorted( list(next_cliques.values())[0].items(), ...
def build_ordered_cliques(cliques, next_cliques): """Order the new cliques based on the order of their ancestors in the previous iteration.""" def sort_key(clique): return -len(clique[1]) if not cliques: return list(sorted( list(next_cliques.values())[0].items(), ...
[ "Order", "the", "new", "cliques", "based", "on", "the", "order", "of", "their", "ancestors", "in", "the", "previous", "iteration", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L378-L402
[ "def", "build_ordered_cliques", "(", "cliques", ",", "next_cliques", ")", ":", "def", "sort_key", "(", "clique", ")", ":", "return", "-", "len", "(", "clique", "[", "1", "]", ")", "if", "not", "cliques", ":", "return", "list", "(", "sorted", "(", "list...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_fold
Print a row that removes the given column and shifts all the following columns.
cli/sawtooth_cli/network_command/compare.py
def print_fold(column_to_fold, total_columns, skips): """Print a row that removes the given column and shifts all the following columns.""" format_str = '{:<2}' * (total_columns - 1) cols = [] for i in range(column_to_fold): # print(i) if i in skips: cols.append(" ") ...
def print_fold(column_to_fold, total_columns, skips): """Print a row that removes the given column and shifts all the following columns.""" format_str = '{:<2}' * (total_columns - 1) cols = [] for i in range(column_to_fold): # print(i) if i in skips: cols.append(" ") ...
[ "Print", "a", "row", "that", "removes", "the", "given", "column", "and", "shifts", "all", "the", "following", "columns", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L422-L439
[ "def", "print_fold", "(", "column_to_fold", ",", "total_columns", ",", "skips", ")", ":", "format_str", "=", "'{:<2}'", "*", "(", "total_columns", "-", "1", ")", "cols", "=", "[", "]", "for", "i", "in", "range", "(", "column_to_fold", ")", ":", "# print(...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_block_num_row
Print out a row of padding and a row with the block number. Includes the branches prior to this block number.
cli/sawtooth_cli/network_command/compare.py
def print_block_num_row(block_num, cliques, next_cliques): """Print out a row of padding and a row with the block number. Includes the branches prior to this block number.""" n_cliques = len(cliques) if n_cliques == 0: print('| {}'.format(block_num)) return def mapper(clique): ...
def print_block_num_row(block_num, cliques, next_cliques): """Print out a row of padding and a row with the block number. Includes the branches prior to this block number.""" n_cliques = len(cliques) if n_cliques == 0: print('| {}'.format(block_num)) return def mapper(clique): ...
[ "Print", "out", "a", "row", "of", "padding", "and", "a", "row", "with", "the", "block", "number", ".", "Includes", "the", "branches", "prior", "to", "this", "block", "number", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L442-L459
[ "def", "print_block_num_row", "(", "block_num", ",", "cliques", ",", "next_cliques", ")", ":", "n_cliques", "=", "len", "(", "cliques", ")", "if", "n_cliques", "==", "0", ":", "print", "(", "'| {}'", ".", "format", "(", "block_num", ")", ")", "return", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_cliques
Print a '*' on each branch with its block id and the ids of the nodes that have the block.
cli/sawtooth_cli/network_command/compare.py
def print_cliques(cliques, next_cliques, node_id_map): """Print a '*' on each branch with its block id and the ids of the nodes that have the block.""" n_cliques = len(cliques) format_str = '{:<' + str(n_cliques * 2) + '} {} {}' branches = ['|'] * len(cliques) for i, clique in enumerate(cliques...
def print_cliques(cliques, next_cliques, node_id_map): """Print a '*' on each branch with its block id and the ids of the nodes that have the block.""" n_cliques = len(cliques) format_str = '{:<' + str(n_cliques * 2) + '} {} {}' branches = ['|'] * len(cliques) for i, clique in enumerate(cliques...
[ "Print", "a", "*", "on", "each", "branch", "with", "its", "block", "id", "and", "the", "ids", "of", "the", "nodes", "that", "have", "the", "block", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L462-L474
[ "def", "print_cliques", "(", "cliques", ",", "next_cliques", ",", "node_id_map", ")", ":", "n_cliques", "=", "len", "(", "cliques", ")", "format_str", "=", "'{:<'", "+", "str", "(", "n_cliques", "*", "2", ")", "+", "'} {} {}'", "branches", "=", "[", "'|...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_splits
Print shifts for new forks.
cli/sawtooth_cli/network_command/compare.py
def print_splits(cliques, next_cliques): """Print shifts for new forks.""" splits = 0 for i, clique in enumerate(cliques): parent, _ = clique # If this fork continues if parent in next_cliques: # If there is a new fork, print a split if len(next_cliques[paren...
def print_splits(cliques, next_cliques): """Print shifts for new forks.""" splits = 0 for i, clique in enumerate(cliques): parent, _ = clique # If this fork continues if parent in next_cliques: # If there is a new fork, print a split if len(next_cliques[paren...
[ "Print", "shifts", "for", "new", "forks", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L477-L488
[ "def", "print_splits", "(", "cliques", ",", "next_cliques", ")", ":", "splits", "=", "0", "for", "i", ",", "clique", "in", "enumerate", "(", "cliques", ")", ":", "parent", ",", "_", "=", "clique", "# If this fork continues", "if", "parent", "in", "next_cli...
8cf473bc2207e51f02bd182d825158a57d72b098
train
print_split
Print a row that splits the given column into two columns while shifting all the following columns.
cli/sawtooth_cli/network_command/compare.py
def print_split(column_to_split, total_columns): """Print a row that splits the given column into two columns while shifting all the following columns.""" out = "" for _ in range(column_to_split): out += "| " out += "|\\" for _ in range(column_to_split + 1, total_columns): out +=...
def print_split(column_to_split, total_columns): """Print a row that splits the given column into two columns while shifting all the following columns.""" out = "" for _ in range(column_to_split): out += "| " out += "|\\" for _ in range(column_to_split + 1, total_columns): out +=...
[ "Print", "a", "row", "that", "splits", "the", "given", "column", "into", "two", "columns", "while", "shifting", "all", "the", "following", "columns", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L491-L500
[ "def", "print_split", "(", "column_to_split", ",", "total_columns", ")", ":", "out", "=", "\"\"", "for", "_", "in", "range", "(", "column_to_split", ")", ":", "out", "+=", "\"| \"", "out", "+=", "\"|\\\\\"", "for", "_", "in", "range", "(", "column_to_split...
8cf473bc2207e51f02bd182d825158a57d72b098
train
get_tails
Args: An ordered collection of block generators. Returns A dictionary of lists of blocks for all chains where: 1. The first block in all the lists has the same block number 2. Each list has all blocks from the common block to the current block in increasing or...
cli/sawtooth_cli/network_command/compare.py
def get_tails(chains): """ Args: An ordered collection of block generators. Returns A dictionary of lists of blocks for all chains where: 1. The first block in all the lists has the same block number 2. Each list has all blocks from the common block to the current ...
def get_tails(chains): """ Args: An ordered collection of block generators. Returns A dictionary of lists of blocks for all chains where: 1. The first block in all the lists has the same block number 2. Each list has all blocks from the common block to the current ...
[ "Args", ":", "An", "ordered", "collection", "of", "block", "generators", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L528-L571
[ "def", "get_tails", "(", "chains", ")", ":", "def", "get_num_of_oldest", "(", "blocks", ")", ":", "return", "blocks", "[", "0", "]", ".", "num", "# Get the first block from every chain", "tails", "=", "{", "}", "bad_chains", "=", "[", "]", "for", "i", ",",...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_compare_across
Return whether all the collections return equal values when called with `key`.
cli/sawtooth_cli/network_command/compare.py
def _compare_across(collections, key): """Return whether all the collections return equal values when called with `key`.""" if len(collections) < 2: return True c0 = key(collections[0]) return all(c0 == key(c) for c in collections[1:])
def _compare_across(collections, key): """Return whether all the collections return equal values when called with `key`.""" if len(collections) < 2: return True c0 = key(collections[0]) return all(c0 == key(c) for c in collections[1:])
[ "Return", "whether", "all", "the", "collections", "return", "equal", "values", "when", "called", "with", "key", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L574-L580
[ "def", "_compare_across", "(", "collections", ",", "key", ")", ":", "if", "len", "(", "collections", ")", "<", "2", ":", "return", "True", "c0", "=", "key", "(", "collections", "[", "0", "]", ")", "return", "all", "(", "c0", "==", "key", "(", "c", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
build_fork_graph
Args: An ordered collection of block generators which have been consumed to the point where they are all at the same block height and the tails of the chains from that block height (in the same order). Returns: A ForkGraph A list of indexes of the chains that had communicati...
cli/sawtooth_cli/network_command/compare.py
def build_fork_graph(chains, tails): """ Args: An ordered collection of block generators which have been consumed to the point where they are all at the same block height and the tails of the chains from that block height (in the same order). Returns: A ForkGraph A l...
def build_fork_graph(chains, tails): """ Args: An ordered collection of block generators which have been consumed to the point where they are all at the same block height and the tails of the chains from that block height (in the same order). Returns: A ForkGraph A l...
[ "Args", ":", "An", "ordered", "collection", "of", "block", "generators", "which", "have", "been", "consumed", "to", "the", "point", "where", "they", "are", "all", "at", "the", "same", "block", "height", "and", "the", "tails", "of", "the", "chains", "from",...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/network_command/compare.py#L583-L627
[ "def", "build_fork_graph", "(", "chains", ",", "tails", ")", ":", "graph", "=", "ForkGraph", "(", ")", "bad_chains", "=", "[", "]", "# Add tails to the graph first", "for", "i", ",", "tail", "in", "tails", ".", "items", "(", ")", ":", "for", "block", "in...
8cf473bc2207e51f02bd182d825158a57d72b098
train
MetricsCollector._join
Join the identifier tuple with periods ".", combine the arbitrary tags with the base tags and the identifier tag, convert tags to "tag=value" format, and then join everything with ",".
validator/sawtooth_validator/metrics/metrics.py
def _join(self, identifier, instance=None, tags=None): """ Join the identifier tuple with periods ".", combine the arbitrary tags with the base tags and the identifier tag, convert tags to "tag=value" format, and then join everything with ",". """ tag_list = [] if...
def _join(self, identifier, instance=None, tags=None): """ Join the identifier tuple with periods ".", combine the arbitrary tags with the base tags and the identifier tag, convert tags to "tag=value" format, and then join everything with ",". """ tag_list = [] if...
[ "Join", "the", "identifier", "tuple", "with", "periods", ".", "combine", "the", "arbitrary", "tags", "with", "the", "base", "tags", "and", "the", "identifier", "tag", "convert", "tags", "to", "tag", "=", "value", "format", "and", "then", "join", "everything"...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/metrics/metrics.py#L152-L165
[ "def", "_join", "(", "self", ",", "identifier", ",", "instance", "=", "None", ",", "tags", "=", "None", ")", ":", "tag_list", "=", "[", "]", "if", "tags", "is", "not", "None", ":", "tag_list", ".", "extend", "(", "tags", ".", "items", "(", ")", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
add_config_parser
Creates the arg parsers needed for the config command and its subcommands.
cli/sawtooth_cli/sawset.py
def add_config_parser(subparsers, parent_parser): """Creates the arg parsers needed for the config command and its subcommands. """ parser = subparsers.add_parser( 'config', help='Changes genesis block settings and create, view, and ' 'vote on settings proposals', descrip...
def add_config_parser(subparsers, parent_parser): """Creates the arg parsers needed for the config command and its subcommands. """ parser = subparsers.add_parser( 'config', help='Changes genesis block settings and create, view, and ' 'vote on settings proposals', descrip...
[ "Creates", "the", "arg", "parsers", "needed", "for", "the", "config", "command", "and", "its", "subcommands", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L61-L75
[ "def", "add_config_parser", "(", "subparsers", ",", "parent_parser", ")", ":", "parser", "=", "subparsers", ".", "add_parser", "(", "'config'", ",", "help", "=", "'Changes genesis block settings and create, view, and '", "'vote on settings proposals'", ",", "description", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_do_config_proposal_create
Executes the 'proposal create' subcommand. Given a key file, and a series of key/value pairs, it generates batches of sawtooth_settings transactions in a BatchList instance. The BatchList is either stored to a file or submitted to a validator, depending on the supplied CLI arguments.
cli/sawtooth_cli/sawset.py
def _do_config_proposal_create(args): """Executes the 'proposal create' subcommand. Given a key file, and a series of key/value pairs, it generates batches of sawtooth_settings transactions in a BatchList instance. The BatchList is either stored to a file or submitted to a validator, depending on the ...
def _do_config_proposal_create(args): """Executes the 'proposal create' subcommand. Given a key file, and a series of key/value pairs, it generates batches of sawtooth_settings transactions in a BatchList instance. The BatchList is either stored to a file or submitted to a validator, depending on the ...
[ "Executes", "the", "proposal", "create", "subcommand", ".", "Given", "a", "key", "file", "and", "a", "series", "of", "key", "/", "value", "pairs", "it", "generates", "batches", "of", "sawtooth_settings", "transactions", "in", "a", "BatchList", "instance", ".",...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L78-L110
[ "def", "_do_config_proposal_create", "(", "args", ")", ":", "settings", "=", "[", "s", ".", "split", "(", "'='", ",", "1", ")", "for", "s", "in", "args", ".", "setting", "]", "signer", "=", "_read_signer", "(", "args", ".", "key", ")", "txns", "=", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_do_config_proposal_list
Executes the 'proposal list' subcommand. Given a url, optional filters on prefix and public key, this command lists the current pending proposals for settings changes.
cli/sawtooth_cli/sawset.py
def _do_config_proposal_list(args): """Executes the 'proposal list' subcommand. Given a url, optional filters on prefix and public key, this command lists the current pending proposals for settings changes. """ def _accept(candidate, public_key, prefix): # Check to see if the first public ...
def _do_config_proposal_list(args): """Executes the 'proposal list' subcommand. Given a url, optional filters on prefix and public key, this command lists the current pending proposals for settings changes. """ def _accept(candidate, public_key, prefix): # Check to see if the first public ...
[ "Executes", "the", "proposal", "list", "subcommand", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L113-L160
[ "def", "_do_config_proposal_list", "(", "args", ")", ":", "def", "_accept", "(", "candidate", ",", "public_key", ",", "prefix", ")", ":", "# Check to see if the first public key matches the given public key", "# (if it is not None). This public key belongs to the user that", "# ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_do_config_proposal_vote
Executes the 'proposal vote' subcommand. Given a key file, a proposal id and a vote value, it generates a batch of sawtooth_settings transactions in a BatchList instance. The BatchList is file or submitted to a validator.
cli/sawtooth_cli/sawset.py
def _do_config_proposal_vote(args): """Executes the 'proposal vote' subcommand. Given a key file, a proposal id and a vote value, it generates a batch of sawtooth_settings transactions in a BatchList instance. The BatchList is file or submitted to a validator. """ signer = _read_signer(args.ke...
def _do_config_proposal_vote(args): """Executes the 'proposal vote' subcommand. Given a key file, a proposal id and a vote value, it generates a batch of sawtooth_settings transactions in a BatchList instance. The BatchList is file or submitted to a validator. """ signer = _read_signer(args.ke...
[ "Executes", "the", "proposal", "vote", "subcommand", ".", "Given", "a", "key", "file", "a", "proposal", "id", "and", "a", "vote", "value", "it", "generates", "a", "batch", "of", "sawtooth_settings", "transactions", "in", "a", "BatchList", "instance", ".", "T...
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L163-L197
[ "def", "_do_config_proposal_vote", "(", "args", ")", ":", "signer", "=", "_read_signer", "(", "args", ".", "key", ")", "rest_client", "=", "RestClient", "(", "args", ".", "url", ")", "proposals", "=", "_get_proposals", "(", "rest_client", ")", "proposal", "=...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_create_propose_txn
Creates an individual sawtooth_settings transaction for the given key and value.
cli/sawtooth_cli/sawset.py
def _create_propose_txn(signer, setting_key_value): """Creates an individual sawtooth_settings transaction for the given key and value. """ setting_key, setting_value = setting_key_value nonce = hex(random.randint(0, 2**64)) proposal = SettingProposal( setting=setting_key, value=...
def _create_propose_txn(signer, setting_key_value): """Creates an individual sawtooth_settings transaction for the given key and value. """ setting_key, setting_value = setting_key_value nonce = hex(random.randint(0, 2**64)) proposal = SettingProposal( setting=setting_key, value=...
[ "Creates", "an", "individual", "sawtooth_settings", "transaction", "for", "the", "given", "key", "and", "value", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L324-L337
[ "def", "_create_propose_txn", "(", "signer", ",", "setting_key_value", ")", ":", "setting_key", ",", "setting_value", "=", "setting_key_value", "nonce", "=", "hex", "(", "random", ".", "randint", "(", "0", ",", "2", "**", "64", ")", ")", "proposal", "=", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_create_vote_txn
Creates an individual sawtooth_settings transaction for voting on a proposal for a particular setting key.
cli/sawtooth_cli/sawset.py
def _create_vote_txn(signer, proposal_id, setting_key, vote_value): """Creates an individual sawtooth_settings transaction for voting on a proposal for a particular setting key. """ if vote_value == 'accept': vote_id = SettingVote.ACCEPT else: vote_id = SettingVote.REJECT vote =...
def _create_vote_txn(signer, proposal_id, setting_key, vote_value): """Creates an individual sawtooth_settings transaction for voting on a proposal for a particular setting key. """ if vote_value == 'accept': vote_id = SettingVote.ACCEPT else: vote_id = SettingVote.REJECT vote =...
[ "Creates", "an", "individual", "sawtooth_settings", "transaction", "for", "voting", "on", "a", "proposal", "for", "a", "particular", "setting", "key", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L340-L353
[ "def", "_create_vote_txn", "(", "signer", ",", "proposal_id", ",", "setting_key", ",", "vote_value", ")", ":", "if", "vote_value", "==", "'accept'", ":", "vote_id", "=", "SettingVote", ".", "ACCEPT", "else", ":", "vote_id", "=", "SettingVote", ".", "REJECT", ...
8cf473bc2207e51f02bd182d825158a57d72b098
train
_make_txn
Creates and signs a sawtooth_settings transaction with with a payload.
cli/sawtooth_cli/sawset.py
def _make_txn(signer, setting_key, payload): """Creates and signs a sawtooth_settings transaction with with a payload. """ serialized_payload = payload.SerializeToString() header = TransactionHeader( signer_public_key=signer.get_public_key().as_hex(), family_name='sawtooth_settings', ...
def _make_txn(signer, setting_key, payload): """Creates and signs a sawtooth_settings transaction with with a payload. """ serialized_payload = payload.SerializeToString() header = TransactionHeader( signer_public_key=signer.get_public_key().as_hex(), family_name='sawtooth_settings', ...
[ "Creates", "and", "signs", "a", "sawtooth_settings", "transaction", "with", "with", "a", "payload", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/sawset.py#L356-L374
[ "def", "_make_txn", "(", "signer", ",", "setting_key", ",", "payload", ")", ":", "serialized_payload", "=", "payload", ".", "SerializeToString", "(", ")", "header", "=", "TransactionHeader", "(", "signer_public_key", "=", "signer", ".", "get_public_key", "(", ")...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusNotifier.notify_peer_message
A new message was received from a peer
validator/sawtooth_validator/consensus/notifier.py
def notify_peer_message(self, message, sender_id): """A new message was received from a peer""" payload = message.SerializeToString() self._notify( "consensus_notifier_notify_peer_message", payload, len(payload), sender_id, len(sender_i...
def notify_peer_message(self, message, sender_id): """A new message was received from a peer""" payload = message.SerializeToString() self._notify( "consensus_notifier_notify_peer_message", payload, len(payload), sender_id, len(sender_i...
[ "A", "new", "message", "was", "received", "from", "a", "peer" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/consensus/notifier.py#L141-L149
[ "def", "notify_peer_message", "(", "self", ",", "message", ",", "sender_id", ")", ":", "payload", "=", "message", ".", "SerializeToString", "(", ")", "self", ".", "_notify", "(", "\"consensus_notifier_notify_peer_message\"", ",", "payload", ",", "len", "(", "pay...
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusNotifier.notify_block_new
A new block was received and passed initial consensus validation
validator/sawtooth_validator/consensus/notifier.py
def notify_block_new(self, block): """A new block was received and passed initial consensus validation""" payload = block.SerializeToString() self._notify( "consensus_notifier_notify_block_new", payload, len(payload))
def notify_block_new(self, block): """A new block was received and passed initial consensus validation""" payload = block.SerializeToString() self._notify( "consensus_notifier_notify_block_new", payload, len(payload))
[ "A", "new", "block", "was", "received", "and", "passed", "initial", "consensus", "validation" ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/consensus/notifier.py#L151-L155
[ "def", "notify_block_new", "(", "self", ",", "block", ")", ":", "payload", "=", "block", ".", "SerializeToString", "(", ")", "self", ".", "_notify", "(", "\"consensus_notifier_notify_block_new\"", ",", "payload", ",", "len", "(", "payload", ")", ")" ]
8cf473bc2207e51f02bd182d825158a57d72b098
train
ConsensusNotifier.notify_engine_activated
The consensus engine has been activated.
validator/sawtooth_validator/consensus/notifier.py
def notify_engine_activated(self, chain_head): """The consensus engine has been activated.""" chain_head_bytes = chain_head.SerializeToString() self._notify( "consensus_notifier_notify_engine_activated", chain_head_bytes, len(chain_head_bytes))
def notify_engine_activated(self, chain_head): """The consensus engine has been activated.""" chain_head_bytes = chain_head.SerializeToString() self._notify( "consensus_notifier_notify_engine_activated", chain_head_bytes, len(chain_head_bytes))
[ "The", "consensus", "engine", "has", "been", "activated", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/consensus/notifier.py#L169-L175
[ "def", "notify_engine_activated", "(", "self", ",", "chain_head", ")", ":", "chain_head_bytes", "=", "chain_head", ".", "SerializeToString", "(", ")", "self", ".", "_notify", "(", "\"consensus_notifier_notify_engine_activated\"", ",", "chain_head_bytes", ",", "len", "...
8cf473bc2207e51f02bd182d825158a57d72b098
train
Tree.update
Walk to ADDRESS, creating nodes if necessary, and set the data there to UPDATER(data). Arguments: address (str): the address to be updated
validator/sawtooth_validator/execution/scheduler_parallel.py
def update(self, address, updater, prune=False): ''' Walk to ADDRESS, creating nodes if necessary, and set the data there to UPDATER(data). Arguments: address (str): the address to be updated ''' node = self._get_or_create(address) node.data = updat...
def update(self, address, updater, prune=False): ''' Walk to ADDRESS, creating nodes if necessary, and set the data there to UPDATER(data). Arguments: address (str): the address to be updated ''' node = self._get_or_create(address) node.data = updat...
[ "Walk", "to", "ADDRESS", "creating", "nodes", "if", "necessary", "and", "set", "the", "data", "there", "to", "UPDATER", "(", "data", ")", "." ]
hyperledger/sawtooth-core
python
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/scheduler_parallel.py#L91-L105
[ "def", "update", "(", "self", ",", "address", ",", "updater", ",", "prune", "=", "False", ")", ":", "node", "=", "self", ".", "_get_or_create", "(", "address", ")", "node", ".", "data", "=", "updater", "(", "node", ".", "data", ")", "if", "prune", ...
8cf473bc2207e51f02bd182d825158a57d72b098