def set_state(self, entries, timeout=None): """ set an address to a value in the validator's merkle state Args: entries (dict): dictionary where addresses are the keys and data is the value. timeout: optional timeout, in seconds Returns: addresses (list): a list of addresses that were set """ state_entries = [ state_context_pb2.Entry(address=e, data=entries[e]) for e in entries ] request = state_context_pb2.TpStateSetRequest( entries=state_entries, context_id=self._context_id).SerializeToString() response = state_context_pb2.TpStateSetResponse() response.ParseFromString( self._stream.send(Message.TP_STATE_SET_REQUEST, request).result(timeout).content) if response.status == \ state_context_pb2.TpStateSetResponse.AUTHORIZATION_ERROR: addresses = [e.address for e in entries] raise AuthorizationException( 'Tried to set unauthorized address: {}'.format(addresses)) return response.addresses
def set(self, entries, timeout=None): """ set an address to a value in the validator's merkle state Args: entries (list): list of StateEntry timeout: optional timeout, in seconds Returns: addresses (list): a list of addresses that were set """ state_entries = [state_context_pb2.Entry( address=e.address, data=e.data) for e in entries] request = state_context_pb2.TpStateSetRequest( entries=state_entries, context_id=self._context_id).SerializeToString() response = state_context_pb2.TpStateSetResponse() response.ParseFromString( self._stream.send(Message.TP_STATE_SET_REQUEST, request).result(timeout).content) if response.status == \ state_context_pb2.TpStateSetResponse.AUTHORIZATION_ERROR: addresses = [e.address for e in entries] raise InvalidTransaction( "Tried to set unauthorized address: %s", addresses) return response.addresses
def set(self, entries, timeout=None): """ set an address to a value in the validator's merkle state Args: entries (list): list of StateEntry timeout: optional timeout, in seconds Returns: addresses (list): a list of addresses that were set """ state_entries = [ state_context_pb2.Entry(address=e.address, data=e.data) for e in entries ] request = state_context_pb2.TpStateSetRequest( entries=state_entries, context_id=self._context_id).SerializeToString() response = state_context_pb2.TpStateSetResponse() response.ParseFromString( self._stream.send(Message.TP_STATE_SET_REQUEST, request).result(timeout).content) return response.addresses