Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisvander/filrepswift
A Swift package to find Filecoin miners by reputation, using the filrep.io API.
https://github.com/chrisvander/filrepswift
blockchain filecoin filecoin-protocol ipfs swift
Last synced: about 2 months ago
JSON representation
A Swift package to find Filecoin miners by reputation, using the filrep.io API.
- Host: GitHub
- URL: https://github.com/chrisvander/filrepswift
- Owner: chrisvander
- License: mit
- Created: 2022-02-20T15:31:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-20T17:41:18.000Z (almost 3 years ago)
- Last Synced: 2024-11-16T07:34:21.428Z (2 months ago)
- Topics: blockchain, filecoin, filecoin-protocol, ipfs, swift
- Language: Swift
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FilRep API - Swift Wrapper
A lightweight Swift wrapper around the [filrep.io](https://filrep.io) API. You can fetch using callbacks or async/await (iOS 15/macOS 12.0):
```swift
import FilRepSwiftfilrep = FilRepSwift()
let miners = try await filrep.getMiners()
// or
filrep.getMiners() { result in
switch result {
case .success(let miners):
// use list of miners
case .failure(let error):
// handle error
}
}
```By default, getMiners will fetch with a limit of 10 and otherwise leave default parameters going to the API. All query parameters are implemented into the getMiners function, so you could request the first hundred from a Europe sorted by freeSpace by using:
```swift
let miners = try await filrep.getMiners(limit: 100, region: .Europe, sortBy: .freeSpace)
```The `Miner` class exposes the following class with constants, parsed directly from the JSON response:
```swift
public class Miner: Codable {
let id: Int
let address: String
let status: Bool
let uptimeAverage: Float
let price: String
let rawPower: String
let qualityAdjPower: String
let isoCode: String
let region: Region
let freeSpace: String
let storageDeals: MinerStorageDeals
let scores: MinerScores
let rank: String
let regionRank: String
public class MinerStorageDeals: Codable {
let total: Int
let noPenalties: Int
let successRate: String
let averagePrice: String
let dataStored: String
let slashed: Int
}
public class MinerScores: Codable {
let total: String
let uptime: String
let storageDeals: String
let committedSectorsProofs: String
}
}
```