mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-26 00:05:20 +00:00
fixes
This commit is contained in:
@@ -779,8 +779,7 @@ final class BLEService: NSObject {
|
||||
private func broadcastPacket(_ packet: BitchatPacket, transferId: String? = nil) {
|
||||
// Apply route if recipient exists (centralized route application)
|
||||
let packetToSend: BitchatPacket
|
||||
if let recipientID = packet.recipientID,
|
||||
let recipientPeerID = PeerID(hexData: recipientID) {
|
||||
if let recipientPeerID = PeerID(hexData: packet.recipientID) {
|
||||
packetToSend = applyRouteIfAvailable(packet, to: recipientPeerID)
|
||||
} else {
|
||||
packetToSend = packet
|
||||
@@ -2519,8 +2518,7 @@ extension BLEService {
|
||||
// If we're the last intermediate hop, forward to destination
|
||||
if index == route.count - 1 {
|
||||
guard packet.ttl > 1 else { return true }
|
||||
guard let recipientID = packet.recipientID,
|
||||
let destinationPeer = PeerID(hexData: recipientID),
|
||||
guard let destinationPeer = PeerID(hexData: packet.recipientID),
|
||||
isPeerConnected(destinationPeer) else {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ final class MeshTopologyTracker {
|
||||
|
||||
func computeRoute(from start: Data?, to goal: Data?, maxHops: Int = 10) -> [Data]? {
|
||||
guard let source = sanitize(start), let target = sanitize(goal) else { return nil }
|
||||
if source == target { return nil } // Direct connection, no intermediate hops
|
||||
if source == target { return [] } // Direct connection, no intermediate hops
|
||||
|
||||
let graph = queue.sync { adjacency }
|
||||
guard graph[source] != nil, graph[target] != nil else { return nil }
|
||||
@@ -97,7 +97,7 @@ final class MeshTopologyTracker {
|
||||
nextPath.append(neighbor)
|
||||
if neighbor == target {
|
||||
// Remove start and end, return only intermediate hops
|
||||
guard nextPath.count >= 2 else { return nil }
|
||||
guard nextPath.count >= 2 else { return [] }
|
||||
return Array(nextPath.dropFirst().dropLast())
|
||||
}
|
||||
if nextPath.count <= maxHops {
|
||||
|
||||
Reference in New Issue
Block a user