Add debugging

This commit is contained in:
Ali
2021-06-28 22:06:25 +04:00
parent a23971c0ef
commit c4d10d07fe
5 changed files with 25 additions and 6 deletions

View File

@@ -162,10 +162,16 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable {
self.id = Id(rawValue: Int64(bitPattern: idHighBits | idLowBits))
}
assert(self.toInt64() == n)
assert(self._toInt64() == n)
}
public func toInt64() -> Int64 {
let result = self._toInt64()
assert(PeerId(result) == self)
return result
}
private func _toInt64() -> Int64 {
let data = UInt64(bitPattern: self.id.rawValue)
let idLowBits = data & 0xffffffff
@@ -191,8 +197,6 @@ public struct PeerId: Hashable, CustomStringConvertible, Comparable, Codable {
result = Int64(bitPattern: data)
}
assert(PeerId(result) == self)
return result
}