Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database interface #26

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
428 changes: 428 additions & 0 deletions src/core/database/database.zig

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/core/database/mint_memory.zig
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ pub const MintMemoryDatabase = struct {
pub fn getMintQuoteByRequestLookupId(
self: *Self,
allocator: std.mem.Allocator,
request: []const u8,
request: zul.UUID,
) !?MintQuote {
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
Expand All @@ -294,7 +294,7 @@ pub const MintMemoryDatabase = struct {
const quotes = try self.getMintQuotes(arena.allocator());
for (quotes.items) |q| {
// if we found, cloning with allocator, so caller responsible on free resources
if (std.mem.eql(u8, q.request_lookup_id, request)) return try q.clone(allocator);
if (q.request_lookup_id.eql(request)) return try q.clone(allocator);
}

return null;
Expand Down Expand Up @@ -386,7 +386,7 @@ pub const MintMemoryDatabase = struct {
pub fn getMeltQuoteByRequestLookupId(
self: *Self,
allocator: std.mem.Allocator,
request: []const u8,
request: zul.UUID,
) !?MeltQuote {
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
Expand All @@ -395,7 +395,7 @@ pub const MintMemoryDatabase = struct {
const quotes = try self.getMeltQuotes(arena.allocator());
for (quotes.items) |q| {
// if we found, cloning with allocator, so caller responsible on free resources
if (std.mem.eql(u8, q.request_lookup_id, request)) return try q.clone(allocator);
if (std.mem.eql(u8, q.request_lookup_id, &request.bin)) return try q.clone(allocator);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/core/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pub const secret = @import("secret.zig");
pub const amount = @import("amount.zig");
pub const nuts = @import("nuts/lib.zig");
pub const mint = @import("mint/mint.zig");
pub const mint_memory = @import("database/mint_memory.zig");
pub const mint_memory = @import("database/database.zig");
pub const lightning = @import("lightning/lightning.zig");
Loading
Loading