Update proof of work access.

pull/5/head
Mikunj 6 years ago
parent 9e388e16de
commit 3570a2438c

@ -59,12 +59,19 @@ public enum ProofOfWork {
}
}()
struct Configuration {
public struct Configuration {
var pubKey: String
var data: String
var timestamp: Date
var ttl: Int
public init(pubKey: String, data: String, timestamp: Date, ttl: Int) {
self.pubKey = pubKey
self.data = data
self.timestamp = timestamp
self.ttl = ttl
}
var payload: [UInt8] {
let timestampString = String(Int(timestamp.timeIntervalSince1970))
let ttlString = String(ttl)
@ -80,7 +87,7 @@ public enum ProofOfWork {
///
/// - Parameter config: The configuration data
/// - Returns: A nonce string or nil if it failed
static func calculate(with config: Configuration) -> String? {
public static func calculate(with config: Configuration) -> String? {
let payload = config.payload
let target = calcTarget(ttl: config.ttl, payloadLength: payload.count, nonceTrials: nonceTrialCount)

Loading…
Cancel
Save