Add LokiAPI.ping(_:)

This commit is contained in:
Niels Andriesse 2019-05-08 10:04:19 +10:00
parent cdf958ccba
commit b2309cdf48
2 changed files with 6 additions and 0 deletions

View File

@ -57,6 +57,10 @@ import PromiseKit
return getRandomSnode().then { invoke(.sendMessage, on: $0, with: lokiMessage.toJSON()) } // TODO: Use getSwarm()
}
public static func ping(_ hexEncodedPublicKey: String) -> Promise<RawResponse> {
return getRandomSnode().then { invoke(.sendMessage, on: $0, with: [ "destination" : hexEncodedPublicKey ]) } // TODO: Use getSwarm() and figure out correct parameters
}
public static func getSwarm(for hexEncodedPublicKey: String) -> Promise<Set<Target>> {
return getRandomSnode().then { invoke(.getSwarm, on: $0, with: [ "pubKey" : hexEncodedPublicKey ]) }.map { rawResponse in return [] } // TODO: Parse targets from raw response
}

View File

@ -8,6 +8,8 @@ public struct LokiMessage {
/// The time to live for the message.
let ttl: UInt64
/// When the proof of work was calculated, if applicable.
///
/// - Note: Expressed as seconds since 00:00:00 UTC on 1 January 1970.
let timestamp: UInt64?
/// The base 64 encoded proof of work, if applicable.
let nonce: String?