Skip to content

Commit

Permalink
Database interface (#26)
Browse files Browse the repository at this point in the history
rm unused interface codes from old impl
  • Loading branch information
StringNick committed Sep 17, 2024
1 parent af9a49f commit 7cdb46f
Show file tree
Hide file tree
Showing 9 changed files with 459 additions and 654 deletions.
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

0 comments on commit 7cdb46f

Please sign in to comment.