Skip to content

Commit 7cdb46f

Browse files
authored
Database interface (#26)
rm unused interface codes from old impl
1 parent af9a49f commit 7cdb46f

File tree

9 files changed

+459
-654
lines changed

9 files changed

+459
-654
lines changed

src/core/database/database.zig

+428
Large diffs are not rendered by default.

src/core/database/mint_memory.zig

+4-4
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub const MintMemoryDatabase = struct {
285285
pub fn getMintQuoteByRequestLookupId(
286286
self: *Self,
287287
allocator: std.mem.Allocator,
288-
request: []const u8,
288+
request: zul.UUID,
289289
) !?MintQuote {
290290
var arena = std.heap.ArenaAllocator.init(allocator);
291291
defer arena.deinit();
@@ -294,7 +294,7 @@ pub const MintMemoryDatabase = struct {
294294
const quotes = try self.getMintQuotes(arena.allocator());
295295
for (quotes.items) |q| {
296296
// if we found, cloning with allocator, so caller responsible on free resources
297-
if (std.mem.eql(u8, q.request_lookup_id, request)) return try q.clone(allocator);
297+
if (q.request_lookup_id.eql(request)) return try q.clone(allocator);
298298
}
299299

300300
return null;
@@ -386,7 +386,7 @@ pub const MintMemoryDatabase = struct {
386386
pub fn getMeltQuoteByRequestLookupId(
387387
self: *Self,
388388
allocator: std.mem.Allocator,
389-
request: []const u8,
389+
request: zul.UUID,
390390
) !?MeltQuote {
391391
var arena = std.heap.ArenaAllocator.init(allocator);
392392
defer arena.deinit();
@@ -395,7 +395,7 @@ pub const MintMemoryDatabase = struct {
395395
const quotes = try self.getMeltQuotes(arena.allocator());
396396
for (quotes.items) |q| {
397397
// if we found, cloning with allocator, so caller responsible on free resources
398-
if (std.mem.eql(u8, q.request_lookup_id, request)) return try q.clone(allocator);
398+
if (std.mem.eql(u8, q.request_lookup_id, &request.bin)) return try q.clone(allocator);
399399
}
400400

401401
return null;

src/core/lib.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ pub const secret = @import("secret.zig");
33
pub const amount = @import("amount.zig");
44
pub const nuts = @import("nuts/lib.zig");
55
pub const mint = @import("mint/mint.zig");
6-
pub const mint_memory = @import("database/mint_memory.zig");
6+
pub const mint_memory = @import("database/database.zig");
77
pub const lightning = @import("lightning/lightning.zig");

0 commit comments

Comments
 (0)