original_docstring: 
      * Check that the record is not final
      * Check that the signer is an authorized reporter
      * Check that the types are correct
      
docstring: Check that the record is not final
  Check that the signer is an authorized reporter
  Check that the types are correct
docstring_tokens: Check that the record is not final Check that the signer is an authorized reporter Check that the types are correct
code: def _update_properties(payload, signer, timestamp, state):
      '''
      * Check that the record is not final
      * Check that the signer is an authorized reporter
      * Check that the types are correct
      '''
      # Check that the record is not final
      record_id = payload.record_id
      record, _, _ = _get_record(state, record_id)
  
      if record.final:
          raise InvalidTransaction(
              'Record is final')
  
      updates = payload.properties
  
      for update in updates:
          name, data_type = update.name, update.data_type
          property_address = addressing.make_property_address(record_id, name)
          property_container = _get_container(state, property_address)
  
          try:
              prop = next(
                  prop
                  for prop in property_container.entries
                  if prop.name == name
              )
          except StopIteration:
              raise InvalidTransaction(
                  'Record does not have property')
  
          try:
              reporter_index = next(
                  reporter.index
                  for reporter in prop.reporters
                  if reporter.public_key == signer and reporter.authorized
              )
          except StopIteration:
              raise InvalidTransaction(
                  'Reporter is not authorized')
  
          if data_type != prop.data_type:
              raise InvalidTransaction(
                  'Update has wrong type')
  
          page_number = prop.current_page
          page_address = addressing.make_property_address(
              record_id, name, page_number)
          page_container = _get_container(state, page_address)
  
          try:
              page = next(
                  page
                  for page in page_container.entries
                  if page.name == name
              )
          except StopIteration:
              raise InternalError(
                  'Property page does not exist')
  
          reported_value = _make_new_reported_value(
              reporter_index=reporter_index,
              timestamp=timestamp,
              prop=update,
          )
  
          page.reported_values.extend([reported_value])
          page.reported_values.sort(
              key=lambda val: (val.timestamp, val.reporter_index))
  
          _set_container(state, page_address, page_container)
  
          # increment page if needed
  
          if len(page.reported_values) >= PROPERTY_PAGE_MAX_LENGTH:
              new_page_number = (
                  page_number + 1
                  if page_number + 1 <= TOTAL_PROPERTY_PAGE_MAX
                  else 1
              )
  
              new_page_address = addressing.make_property_address(
                  record_id, name, new_page_number)
  
              new_page_container = _get_container(state, new_page_address)
  
              try:
                  new_page = next(
                      page
                      for page in new_page_container.entries
                      if page.name == name
                  )
  
                  del new_page.reported_values[:]
  
              except StopIteration:
                  new_page = PropertyPage(
                      name=name,
                      record_id=record_id,
                  )
  
                  new_page_container.entries.extend([new_page])
  
              _set_container(state, new_page_address, new_page_container)
  
              # increment the property's page number (or wrap back to 1)
  
              prop.current_page = new_page_number
  
              if new_page_number == 1 and not prop.wrapped:
                  prop.wrapped = True
  
              _set_container(state, property_address, property_container)
code_tokens: def _update_properties ( payload , signer , timestamp , state ) : record_id = payload . record_id record , _ , _ = _get_record ( state , record_id ) if record . final : raise InvalidTransaction ( 'Record is final' ) updates = payload . properties for update in updates : name , data_type = update . name , update . data_type property_address = addressing . make_property_address ( record_id , name ) property_container = _get_container ( state , property_address ) try : prop = next ( prop for prop in property_container . entries if prop . name == name ) except StopIteration : raise InvalidTransaction ( 'Record does not have property' ) try : reporter_index = next ( reporter . index for reporter in prop . reporters if reporter . public_key == signer and reporter . authorized ) except StopIteration : raise InvalidTransaction ( 'Reporter is not authorized' ) if data_type != prop . data_type : raise InvalidTransaction ( 'Update has wrong type' ) page_number = prop . current_page page_address = addressing . make_property_address ( record_id , name , page_number ) page_container = _get_container ( state , page_address ) try : page = next ( page for page in page_container . entries if page . name == name ) except StopIteration : raise InternalError ( 'Property page does not exist' ) reported_value = _make_new_reported_value ( reporter_index = reporter_index , timestamp = timestamp , prop = update , ) page . reported_values . extend ( [ reported_value ] ) page . reported_values . sort ( key = lambda val : ( val . timestamp , val . reporter_index ) ) _set_container ( state , page_address , page_container ) if len ( page . reported_values ) >= PROPERTY_PAGE_MAX_LENGTH : new_page_number = ( page_number + 1 if page_number + 1 <= TOTAL_PROPERTY_PAGE_MAX else 1 ) new_page_address = addressing . make_property_address ( record_id , name , new_page_number ) new_page_container = _get_container ( state , new_page_address ) try : new_page = next ( page for page in new_page_container . entries if page . name == name ) del new_page . reported_values [ : ] except StopIteration : new_page = PropertyPage ( name = name , record_id = record_id , ) new_page_container . entries . extend ( [ new_page ] ) _set_container ( state , new_page_address , new_page_container ) prop . current_page = new_page_number if new_page_number == 1 and not prop . wrapped : prop . wrapped = True _set_container ( state , property_address , property_container )
short_docstring: Check that the record is not final
   Check that the signer is an authorized reporter
   Check that the types are correct
short_docstring_tokens: Check that the record is not final Check that the signer is an authorized reporter Check that the types are correct
comment: '''
      * Check that the record is not final
      * Check that the signer is an authorized reporter
      * Check that the types are correct
      '''$SEP$# Check that the record is not final$SEP$# increment page if needed$SEP$# increment the property's page number (or wrap back to 1)