Skip to content

Commit

Permalink
use completion
Browse files Browse the repository at this point in the history
  • Loading branch information
ieow committed Jan 8, 2025
1 parent fa528f0 commit 742afd2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Sources/mpc-core-kit-swift/Tss.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,23 @@ extension MpcCoreKit {
}


public func tssSignSync(message: Data) throws -> Data {
let semaphore = DispatchSemaphore(value: 0)
var signature: Data?;
private func tssSignCompletion( message: Data, completion: @escaping (Data) -> Void) {
Task {
let localSignature = try await self.tssSign(message: message)
signature = localSignature
completion(localSignature)
}
}

public func tssSignSync(message: Data) throws -> Data {
var signature: Data?;

let semaphore = DispatchSemaphore(value: 0)
tssSignCompletion(message: message){ result in
signature = result
semaphore.signal()
}
semaphore.wait()

return signature ?? Data()
}

Expand Down

0 comments on commit 742afd2

Please sign in to comment.