diff --git a/LokiKit/ProofOfWork.swift b/LokiKit/ProofOfWork.swift index 34295573a..6e3dc6e91 100644 --- a/LokiKit/ProofOfWork.swift +++ b/LokiKit/ProofOfWork.swift @@ -1,6 +1,7 @@ import CryptoSwift private extension UInt64 { + init(_ decimal: Decimal) { self.init(truncating: decimal as NSDecimalNumber) } @@ -17,16 +18,10 @@ private extension Array where Element == UInt8 { self.init(array) } - /// Compare if lhs array is greater than rhs array - static func >(lhs: [UInt8], rhs: [UInt8]) -> Bool { + static func > (lhs: [UInt8], rhs: [UInt8]) -> Bool { guard lhs.count == rhs.count else { return false } - - for i in (0.. rhs[i] - } - return false + guard let (lhsElement, rhsElement) = zip(lhs, rhs).first(where: { $0 != $1 }) else { return false } + return lhsElement > rhsElement } /// Increment the UInt8 array by a given amount