Skip to content

Commit

Permalink
slight change to ReconstructRequest struct; no longer need to restruc…
Browse files Browse the repository at this point in the history
…ture JSON in frontend when sending back shares
  • Loading branch information
diegoandino committed Nov 25, 2024
1 parent 0cb0434 commit 18f91ec
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions server/src/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ const SharesRequest = struct {
count: u8,
};

const u64Share = struct {
x: usize,
y: u64,
};

const ReconstructRequest = struct {
shares: []const []const u64,
shares: []const u64Share,
};

const ErrorResponse = struct {
Expand Down Expand Up @@ -102,11 +107,6 @@ fn handleShares(req: *httpz.Request, res: *httpz.Response) !void {
return sendError(res, "Not enough shares to give");
}

const u64Share = struct {
x: usize,
y: u64,
};

const shares = try allocator.alloc(u64Share, parsed.count);
defer allocator.free(shares);

Expand Down Expand Up @@ -143,8 +143,8 @@ fn handleReconstruct(req: *httpz.Request, res: *httpz.Response) !void {
var i: usize = 0;
for (parsed.shares) |share| {
shares[i] = scheme.Share{
.x = share[0],
.y = try Managed.initSet(allocator, share[1]),
.x = share.x,
.y = try Managed.initSet(allocator, share.y),
};
i += 1;
}
Expand Down

0 comments on commit 18f91ec

Please sign in to comment.