diff --git a/Sources/ShadowSwift/BloomFilter.swift b/Sources/ShadowSwift/BloomFilter.swift index ea64761..9734ca9 100644 --- a/Sources/ShadowSwift/BloomFilter.swift +++ b/Sources/ShadowSwift/BloomFilter.swift @@ -26,30 +26,51 @@ public struct BloomFilter: Codable // seeds here are generating random numbers to be mapped seeds = (0..: Codable .forEach({ hash in data[hash % data.count] = true }) + } // Takes the salt we give it, and checks the array if there is a match. If it matches it returns true, false if not. @@ -138,7 +160,7 @@ public struct BloomFilter: Codable return true } - static func createNewBloomFilterFile() -> BloomFilter? + static func getBloomFileURL() -> URL? { guard let supportDirectoryURL = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else { @@ -149,17 +171,7 @@ public struct BloomFilter: Codable let bloomFilterURL = supportDirectoryURL.appendingPathComponent(bloomFilterFilename) - let newBloomFilter = BloomFilter() - if newBloomFilter.save(pathURL: bloomFilterURL) - { - print("Saved your BloomFilter to: \(bloomFilterURL.path)") - - return newBloomFilter - } - else - { - return nil - } + return bloomFilterURL } } diff --git a/Tests/ShadowSwiftTests/ShadowSwiftTests.swift b/Tests/ShadowSwiftTests/ShadowSwiftTests.swift index 01619a2..5420b40 100644 --- a/Tests/ShadowSwiftTests/ShadowSwiftTests.swift +++ b/Tests/ShadowSwiftTests/ShadowSwiftTests.swift @@ -734,15 +734,15 @@ class ShadowSwiftTests: XCTestCase let testString = "something" let testData = Data(string: testString) + let bloomFilterPath = supportDirectoryURL.appendingPathComponent("BloomFilter.json") // instantiate a bloom filter. - let bloomFilterPath = supportDirectoryURL.appendingPathComponent("BloomFilter.json") + var bloomFilter = BloomFilter() // insert some data into the bloom filter. - var bloomFilter = BloomFilter() bloomFilter.insert(testData) - // save the bloom filter JSON file. + // save the bloom filter JSON file. print("Saving BloomFilter to \(bloomFilterPath)") let filterSaved = bloomFilter.save(pathURL: bloomFilterPath) XCTAssertTrue(filterSaved)