@@ -222,19 +222,23 @@ func NewFSM(ctx context.Context, deposit *Deposit, cfg *ManagerConfig,
222222func (f * FSM ) handleBlockNotification (ctx context.Context ,
223223 currentHeight uint32 ) {
224224
225+ expire := func () {
226+ err := f .SendEvent (ctx , OnExpiry , nil )
227+ if err != nil {
228+ log .Debugf ("error sending OnExpiry event: %v" , err )
229+ }
230+ }
231+
225232 // If the deposit is expired but not yet sufficiently confirmed, we
226233 // republish the expiry sweep transaction.
227234 if f .deposit .IsExpired (currentHeight , f .params .Expiry ) {
228235 if f .deposit .IsInState (WaitForExpirySweep ) {
229- f .PublishDepositExpirySweepAction (ctx , nil )
236+ event := f .PublishDepositExpirySweepAction (ctx , nil )
237+ if event != OnExpiryPublished {
238+ go expire ()
239+ }
230240 } else {
231- go func () {
232- err := f .SendEvent (ctx , OnExpiry , nil )
233- if err != nil {
234- log .Debugf ("error sending OnExpiry " +
235- "event: %v" , err )
236- }
237- }()
241+ go expire ()
238242 }
239243 }
240244}
@@ -267,6 +271,7 @@ func (f *FSM) DepositStatesV0() fsm.States {
267271 Transitions : fsm.Transitions {
268272 OnRecover : PublishExpirySweep ,
269273 OnExpiryPublished : WaitForExpirySweep ,
274+ OnExpiry : Expired ,
270275 // If the timeout sweep failed we go back to
271276 // Deposited, hoping that another timeout sweep
272277 // attempt will be successful. Alternatively,
0 commit comments