code: def namedb_state_create_sanity_check( opcode, op_data, history_id, preorder_record, record_table ):
      
  
      namedb_op_sanity_check( opcode, op_data, preorder_record )
      preorder_opcode = op_get_opcode_name(preorder_record['op'])
  
      if opcode in OPCODE_NAME_STATE_CREATIONS:
          # name state transition 
          assert record_table == "name_records", "BUG: name state transition opcode (%s) on table %s" % (opcode, record_table)
          assert preorder_opcode in OPCODE_NAME_STATE_PREORDER, "BUG: preorder record opcode '%s' is not a name preorder" % (preorder_opcode)
  
          assert 'name' in op_data, 'BUG: no name in op_data'
          assert 'block_number' in op_data, 'BUG: no block_number in op_data'
  
      elif opcode in OPCODE_NAMESPACE_STATE_CREATIONS:
          # namespace state transition 
          assert record_table == "namespaces", "BUG: namespace state transition opcode (%s) on table %s" % (opcode, record_table)
          assert preorder_opcode in OPCODE_NAMESPACE_STATE_PREORDER, "BUG: preorder record opcode '%s' is not a namespace preorder" % (preorder_opcode)
          
          assert 'namespace_id' in op_data, 'BUG: no namespace_id in op_data'
          assert 'block_number' in op_data, 'BUG: no block_number in op_data'
  
      return True
docs: Sanity checks on a preorder and a state-creation operation:
      * the opcode must match the op_data
      * the history_id and operation must match the preorder
      * everything must match the record table.
  
      Return True on success
      Raise an exception on error.
  
      DO NOT CALL THIS METHOD DIRECTLY.