mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 19:25:20 +00:00
Add mesh diagnostics: /ping, /trace, and topology map
- New protocol types ping=0x26 / pong=0x27 (9-byte payload: 8-byte nonce + origin TTL) with per-peer inbound rate limiting (5 per 10s) - /ping @name reports RTT and hop count, 10s timeout - /trace @name prints the estimated path from gossiped directNeighbors - Topology map sheet (circular Canvas layout) reachable from App Info - Ping/pong ride the deterministic directed-relay path like DMs - Tests: payload round-trip, hop-count math, command output, edge normalization, layout Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -196,6 +196,27 @@ final class MockTransport: Transport {
|
||||
return courierSendResult
|
||||
}
|
||||
|
||||
// MARK: - Mesh Diagnostics
|
||||
|
||||
private(set) var sentMeshPings: [PeerID] = []
|
||||
var meshPingResult: MeshPingResult?
|
||||
var meshPaths: [PeerID: [PeerID]] = [:]
|
||||
var meshTopologySnapshot: MeshTopologySnapshot?
|
||||
|
||||
func sendMeshPing(to peerID: PeerID, completion: @escaping @MainActor (MeshPingResult?) -> Void) {
|
||||
sentMeshPings.append(peerID)
|
||||
let result = meshPingResult
|
||||
Task { @MainActor in completion(result) }
|
||||
}
|
||||
|
||||
func computeMeshPath(to peerID: PeerID) -> [PeerID]? {
|
||||
meshPaths[peerID]
|
||||
}
|
||||
|
||||
func currentMeshTopology() -> MeshTopologySnapshot? {
|
||||
meshTopologySnapshot
|
||||
}
|
||||
|
||||
// MARK: - Test Helpers
|
||||
|
||||
/// Clears all recorded method calls for fresh assertions
|
||||
|
||||
Reference in New Issue
Block a user