# Moment-generating functions problem, total time before success at performing a task?

I'm facing moment-generating functions for the first time so I'm trying to get some practice and I'm stuck...

Someone's trying to succeed at performing a given task. At each trial he either stops giving up or because he succeeded. I'm given that $X_i$ is the duration of the $i^{th}$ trial and $X_i$ is $Exp(\lambda)$. I'm trying to find out about the distribution of the total time that passed before he succeeds knowing that he has probability $p$ of making it each time. Also, the trials are of course independent and the success is independent of the time spent trying.

Actually my problem is probably not about the generating functions themselves but about modelling the problem in terms of random variables, could you help me?

Here is a modeling: one is given an i.i.d. sequence $(X_n)$ exponentially distributed with parameter $\lambda$ and a geometric random variable $N$ with parameter $p$, such that $P(N=n)=p(1-p)^{n-1}$ for every $n\geqslant1$, and independent of $(X_n)$.
The time to success is $T=X_1+X_2+\cdots+X_N$, or, more rigorously, $$T=\sum_{n=1}^NX_n=\sum_{n=1}^\infty X_n\mathbf 1_{N\geqslant n}.$$