Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
StringNick committed Sep 29, 2024
1 parent c4a3821 commit 5d3ad78
Show file tree
Hide file tree
Showing 9 changed files with 264 additions and 70 deletions.
8 changes: 6 additions & 2 deletions src/core/database/database.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const MintQuote = @import("../mint/mint.zig").MintQuote;
const MeltQuote = @import("../mint/mint.zig").MeltQuote;

pub const MintMemoryDatabase = @import("mint_memory.zig").MintMemoryDatabase;
pub const MintSqliteDatabase = @import("mint_sqlite.zig").Database;

pub const MintDatabase = struct {
const Self = @This();
Expand Down Expand Up @@ -70,6 +71,7 @@ pub const MintDatabase = struct {
ptr: *anyopaque,
blinded_messages: []const secp256k1.PublicKey,
blind_signatures: []const nuts.BlindSignature,
quote_id: ?[]const u8,
) anyerror!void,
getBlindSignaturesFn: *const fn (
ptr: *anyopaque,
Expand Down Expand Up @@ -218,9 +220,10 @@ pub const MintDatabase = struct {
pointer: *anyopaque,
blinded_messages: []const secp256k1.PublicKey,
blind_signatures: []const nuts.BlindSignature,
quote_id: ?[]const u8,
) anyerror!void {
const self: *T = @ptrCast(@alignCast(pointer));
return self.addBlindSignatures(blinded_messages, blind_signatures);
return self.addBlindSignatures(blinded_messages, blind_signatures, quote_id);
}

pub fn getBlindSignatures(
Expand Down Expand Up @@ -406,8 +409,9 @@ pub const MintDatabase = struct {
self: Self,
blinded_messages: []const secp256k1.PublicKey,
blind_signatures: []const nuts.BlindSignature,
quote_id: ?[]const u8,
) anyerror!void {
return self.addBlindSignaturesFn(self.ptr, blinded_messages, blind_signatures);
return self.addBlindSignaturesFn(self.ptr, blinded_messages, blind_signatures, quote_id);
}

pub fn getBlindSignatures(
Expand Down
4 changes: 4 additions & 0 deletions src/core/database/mint_memory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,17 @@ pub const MintMemoryDatabase = struct {
self: *Self,
blinded_messages: []const secp256k1.PublicKey,
blind_signatures: []const nuts.BlindSignature,
quote_id: ?[]const u8,
) !void {
_ = quote_id; // autofix
self.lock.lock();
defer self.lock.unlock();

for (blinded_messages, blind_signatures) |blinded_message, blind_signature| {
try self.blinded_signatures.put(blinded_message.serialize(), blind_signature);
}

// TODO quote signatures
}

pub fn getBlindSignatures(
Expand Down
Loading

0 comments on commit 5d3ad78

Please sign in to comment.