Fix PoW calculation

pull/26/head
Niels Andriesse 6 years ago
parent fddee1db3d
commit b20ac237b2

@ -40,7 +40,8 @@ public extension LokiAPI {
if isPoWRequired {
// The storage server takes a time interval in milliseconds
let now = NSDate.ows_millisecondTimeStamp()
if let nonce = ProofOfWork.calculate(data: data, pubKey: destination, timestamp: now, ttl: ttl) {
let ttlInSeconds = ttl / 1000
if let nonce = ProofOfWork.calculate(data: data, pubKey: destination, timestamp: now, ttl: ttlInSeconds) {
let result = Message(destination: destination, data: data, ttl: ttl, timestamp: now, nonce: nonce)
seal.fulfill(result)
} else {

@ -63,7 +63,7 @@ public enum ProofOfWork {
/// - data: The message data
/// - pubKey: The message recipient
/// - timestamp: The timestamp
/// - ttl: The message time to live
/// - ttl: The message time to live, in **seconds**
/// - Returns: A nonce string or `nil` if it failed
public static func calculate(data: String, pubKey: String, timestamp: UInt64, ttl: UInt64) -> String? {
let payload = createPayload(pubKey: pubKey, data: data, timestamp: timestamp, ttl: ttl)

Loading…
Cancel
Save