Remove ghost sync (#468)

* delete stale peers and messages from sync manager

* ignore old announcenements
This commit is contained in:
callebtc
2025-10-12 19:41:44 +02:00
committed by GitHub
parent ad28cc710c
commit c61347defe
4 changed files with 95 additions and 11 deletions
@@ -210,6 +210,14 @@ class MessageHandler(private val myPeerID: String, private val appContext: andro
val peerID = routed.peerID ?: "unknown"
if (peerID == myPeerID) return false
// Ignore stale announcements older than STALE_PEER_TIMEOUT
val now = System.currentTimeMillis()
val age = now - packet.timestamp.toLong()
if (age > com.bitchat.android.util.AppConstants.STALE_PEER_TIMEOUT_MS) {
Log.w(TAG, "Ignoring stale ANNOUNCE from ${peerID.take(8)} (age=${age}ms > ${com.bitchat.android.util.AppConstants.STALE_PEER_TIMEOUT_MS}ms)")
return false
}
// Try to decode as iOS-compatible IdentityAnnouncement with TLV format
val announcement = IdentityAnnouncement.decode(packet.payload)