package services import ( "time" "ripple/commands" "ripple/config" "ripple/types" ) const cleanupPaymentInterval = config.CleanupRate func (pm *PaymentManager) CleanupPaymentRoutine() { for paymentID, payment := range pm.st.Storage.Payments { if payment.PenaltyTicker() < payment.Amount { continue } instr := types.Instruction{ Command: commands.LOCKSTEP_CLEANUP_PAYMENT, Arguments: paymentID[:], } if payment.Incoming != (types.UserIdentifier{}) && !pm.lockstep.InQueue(payment.Incoming, instr) { pm.lockstep.Enqueue(payment.Incoming, instr) } if payment.Outgoing != (types.UserIdentifier{}) && !pm.lockstep.InQueue(payment.Outgoing, instr) { pm.lockstep.Enqueue(payment.Outgoing, instr) } } } func (pm *PaymentManager) RunCleanupPaymentRoutine() { for { pm.CleanupPaymentCh <- struct{}{} time.Sleep(cleanupPaymentInterval) } }