From 3570a2438c195996035c458cb2f45a7947d4b24e Mon Sep 17 00:00:00 2001 From: Mikunj Date: Fri, 3 May 2019 12:55:34 +1000 Subject: [PATCH] Update proof of work access. --- LokiKit/LokiKit/ProofOfWork.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/LokiKit/LokiKit/ProofOfWork.swift b/LokiKit/LokiKit/ProofOfWork.swift index e64108421..3c08ca014 100644 --- a/LokiKit/LokiKit/ProofOfWork.swift +++ b/LokiKit/LokiKit/ProofOfWork.swift @@ -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)