Fix timestamp bug causing peer discovery failures

- Fixed BitchatPacket convenience initializer to use milliseconds (was using seconds)
- Fixed BitchatMessage binary encoding to use milliseconds for consistency
- Updated decoding logic to properly handle millisecond timestamps
- This resolves the issue where packets were being dropped due to timestamp validation failures

All timestamps are now consistently in milliseconds throughout the codebase.
This commit is contained in:
jack
2025-07-04 16:07:49 +02:00
parent 6023ff8af0
commit 9ef9ef8056
3 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -1053,7 +1053,7 @@ class BluetoothMeshService: NSObject {
let currentTime = UInt64(Date().timeIntervalSince1970 * 1000) // milliseconds
let timeDiff = abs(Int64(currentTime) - Int64(packet.timestamp))
if timeDiff > 300000 { // 5 minutes in milliseconds
print("[SECURITY] Dropping packet with timestamp too far from current time: \(timeDiff/1000) seconds")
print("[SECURITY] Dropping packet from \(peerID) type:\(packet.type) - timestamp diff: \(timeDiff/1000)s (packet:\(packet.timestamp) vs current:\(currentTime))")
return
}