@@ -24,10 +24,12 @@ type Cleaner struct {
 
 // SessionStorage keeps sessions and allows removing them by proposal id
 type SessionStorage interface {
-	RemoveForService(serviceId string)
+	RemoveForService(serviceID string)
 }
 
 // Cleanup removes sessions of stopped service
-func (cleaner *Cleaner) Cleanup(instance *Instance) {
-	cleaner.SessionStorage.RemoveForService(string(instance.id))
+func (cleaner *Cleaner) Cleanup(event EventPayload) {
+	if event.Status == string(NotRunning) {
+		cleaner.SessionStorage.RemoveForService(event.ID)
+	}
 }
/*
 * Copyright (C) 2019 The "MysteriumNetwork/node" Authors.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package service

// Cleaner cleans up when service is stopped
type Cleaner struct {
	SessionStorage SessionStorage
}

// SessionStorage keeps sessions and allows removing them by proposal id
type SessionStorage interface {
	RemoveForService(serviceId string)
}

// Cleanup removes sessions of stopped service
func (cleaner *Cleaner) Cleanup(instance *Instance) {
	cleaner.SessionStorage.RemoveForService(string(instance.id))
}

Its probably not a `Cleanup` then, since imho its should be called only once and we don't care about event's state.