async def set_version(self, tp, params, version=None, elem=None):
self.registry.set_tr(None)<EOL>tw = TypeWrapper(tp, params)<EOL>if not tw.is_versioned():<EOL><INDENT>return TypeWrapper.ELEMENTARY_RES<EOL><DEDENT>if not self.version_db.is_versioned(tw):<EOL><INDENT>if version is None:<EOL><INDENT>version = self._cur_version(tw, elem)<EOL><DEDENT>await dump_uvarint(self.iobj, <NUM_LIT:0>)<EOL>await dump_uvarint(self.iobj, version)<EOL>self.version_db.set_version(tw, <NUM_LIT:0>, version)<EOL><DEDENT>return self.version_db.get_version(tw)[<NUM_LIT:1>]<EOL>
Stores version to the stream if not stored yet

:param tp:
:param params:
:param version:
:param elem:
:return: