code: async def set_version(self, tp, params, version=None, elem=None):
          
          self.registry.set_tr(None)
          tw = TypeWrapper(tp, params)
          if not tw.is_versioned():
              return TypeWrapper.ELEMENTARY_RES
  
          # If not in the DB, store to the archive at the current position
          if not self.version_db.is_versioned(tw):
              if version is None:
                  version = self._cur_version(tw, elem)
  
              await dump_uvarint(self.iobj, 0)
              await dump_uvarint(self.iobj, version)
              self.version_db.set_version(tw, 0, version)
  
          return self.version_db.get_version(tw)[1]
docs: Stores version to the stream if not stored yet
  
          :param tp:
          :param params:
          :param version:
          :param elem:
          :return: