diff --git a/src/storage/storage.zig b/src/storage/storage.zig index d458f18..9ea6d2a 100644 --- a/src/storage/storage.zig +++ b/src/storage/storage.zig @@ -41,13 +41,16 @@ pub const Storage = struct { } }; +// A Storage transaction pub const Transaction = struct { txn: lmdb.Transaction, + // Abandon the Transaction without applying any change pub fn abort(self: Transaction) void { self.txn.abort(); } + // Serialize and store a block in database pub fn store_block(allocator: std.mem.Allocator, txn: Transaction, block: *Block) !void { const blocks = try txn.txn.database("blocks", .{ .create = true }); try blocks.set(&block.hash, try block.serizalize(allocator)); diff --git a/src/types/block.zig b/src/types/block.zig index ba8389d..c622c9e 100644 --- a/src/types/block.zig +++ b/src/types/block.zig @@ -1,5 +1,6 @@ const std = @import("std"); +// A bitcoin block with additonal usefull data pub const Block = struct { hash: [32]u8, height: i32,