Praise be to Allah.
Purity – greater and lesser – is a condition of tawaaf being valid according to the majority of scholars. If a person does tawaaf when he is in a state of greater or lesser impurity (if he is junub or has broken his wudoo’) his tawaaf is not valid and he has not exited ihram fully, so it is forbidden for him to have intercourse, and he has not exited ihram until he performs tawaaf.
If a person is not sure whether he is taahir and is uncertain about that, then he does not have to do ghusl, because the basic principle is that a person is taahir. Based on this, your tawaaf is valid so long as you were not certain that you had had an erotic dream and did not see any maniy (fluid emitted at climax). So there is no need to worry in this case.
And Allaah knows best.