feat: refactor core+network+protocol: use platform abstractions,

transport vtable
This commit is contained in:
2026-02-19 11:32:30 -03:00
parent 63e5ac59ce
commit b466979bc7
33 changed files with 884 additions and 624 deletions

View File

@@ -3,6 +3,7 @@ const std = @import("std");
const protocol = @import("protocol.zig");
const message = @import("message.zig");
const crypto = @import("crypto.zig");
const platform_time = @import("platform").time;
/// Helper to read little-endian integers from buffer slices
fn readLittle(comptime T: type, buf: []const u8) T {
@@ -702,7 +703,7 @@ pub const MessageSerializer = struct {
.id = id,
.source = self.local_peer_id,
.dest = self.peer_id,
.timestamp = std.time.timestamp(),
.timestamp = platform_time.timestamp(),
};
}
@@ -1930,7 +1931,7 @@ test "key exchange messages are not encrypted" {
const signature = [_]u8{0xAA} ** 64;
const identity_key = [_]u8{0xBB} ** 32;
const session_nonce = [_]u8{0xCC} ** 32;
const timestamp = std.time.timestamp();
const timestamp = platform_time.timestamp();
const key_exchange = message.KeyExchangeInit.init(public_key, signature, identity_key, session_nonce, timestamp);
const msg = message.Message{ .key_exchange_init = key_exchange };
@@ -2334,7 +2335,7 @@ test "key exchange response serialization roundtrip" {
const signature = [_]u8{0x22} ** 64;
const identity_key = [_]u8{0x33} ** 32;
const initiator_nonce = [_]u8{0x44} ** 32;
const timestamp = std.time.timestamp();
const timestamp = platform_time.timestamp();
const key_resp = message.KeyExchangeResponse.init(public_key, signature, identity_key, timestamp, initiator_nonce);
const msg = message.Message{ .key_exchange_response = key_resp };