PeerID 15/n: Bitchat Message & Packet accept in init (#754)

This commit is contained in:
Islam
2025-10-06 17:16:11 +02:00
committed by GitHub
parent 01ec4573f8
commit 5f44c56a90
10 changed files with 45 additions and 34 deletions
+2 -2
View File
@@ -34,12 +34,12 @@ struct BitchatPacket: Codable {
}
// Convenience initializer for new binary format
init(type: UInt8, ttl: UInt8, senderID: String, payload: Data) {
init(type: UInt8, ttl: UInt8, senderID: PeerID, payload: Data) {
self.version = 1
self.type = type
// Convert hex string peer ID to binary data (8 bytes)
var senderData = Data()
var tempID = senderID
var tempID = senderID.id
while tempID.count >= 2 {
let hexByte = String(tempID.prefix(2))
if let byte = UInt8(hexByte, radix: 16) {