extension Storage { private static let receivedCallsCollection = "LokiReceivedCallsCollection" public func getReceivedCalls(for publicKey: String, using transaction: Any) -> Set { var result: Set? guard let transaction = transaction as? YapDatabaseReadTransaction else { return [] } result = transaction.object(forKey: publicKey, inCollection: Storage.receivedCallsCollection) as? Set return result ?? [] } public func setReceivedCalls(to receivedCalls: Set, for publicKey: String, using transaction: Any) { (transaction as! YapDatabaseReadWriteTransaction).setObject(receivedCalls, forKey: publicKey, inCollection: Storage.receivedCallsCollection) } }