getditto / DittoSwiftTools

Diagnostic and Debugging Tools for DittoSwift
MIT License
9 stars 2 forks source link

Update peers list #76

Closed texasRanger09 closed 9 months ago

texasRanger09 commented 9 months ago

updates the peers list to use the the peerKey instead of the addressSiteId. The peerKey is a unique identifier to each device and will allow for identifying a device in the logs with the peerKey.

texasRanger09 commented 9 months ago

Uses this algorithm to convert the peerKey byte array

    func convertData(_ data: Data) -> String {
        let hash = Insecure.MD5.hash(data: data)
        return hash.map { String(format: "%02hhx", $0) }.joined()
    }

This same algorithm should be used in the Android version in order to keep the peerKeys comparable.

magicwave commented 9 months ago

Good job finding the peerKey hashing algorithm! I suggest we create an extension on DittoPeer in a dedicated file in the PeersList module that vends a public var peerKeyString: String

magicwave commented 9 months ago

The connected peer peerKey hash is wrong in the PeersListView in the local peer view. Please see my fix PR which should merge to Walker's/this PR, not to main.