Skip to content

Commit

Permalink
Minor updates for Zig 0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rutgerbrf committed Apr 27, 2024
1 parent a50016c commit 66e0e65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
16 changes: 6 additions & 10 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");

pub fn build(b: *std.build.Builder) !void {
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

Expand All @@ -14,15 +14,11 @@ pub fn build(b: *std.build.Builder) !void {
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&run_lib_tests.step);

const znk_version = "0.2.1";
const znk_version = "0.2.2";

const znk_options = b.addOptions();
znk_options.addOption([]const u8, "version", znk_version);

const nkeys_module = b.addModule("nkeys", .{
.source_file = .{ .path = "src/main.zig" },
});

const lib = b.addStaticLibrary(.{
.name = "nkeys",
.root_source_file = .{ .path = "src/main.zig" },
Expand All @@ -37,8 +33,8 @@ pub fn build(b: *std.build.Builder) !void {
.target = target,
.optimize = optimize,
});
znk_tests.addModule("nkeys", nkeys_module);
znk_tests.addOptions("build_options", znk_options);
znk_tests.root_module.addImport("nkeys", &lib.root_module);
znk_tests.root_module.addOptions("build_options", znk_options);
const run_znk_tests = b.addRunArtifact(znk_tests);

const znk_test_step = b.step("test-znk", "Run znk tests");
Expand All @@ -50,8 +46,8 @@ pub fn build(b: *std.build.Builder) !void {
.target = target,
.optimize = optimize,
});
znk.addModule("nkeys", nkeys_module);
znk.addOptions("build_options", znk_options);
znk.root_module.addImport("nkeys", &lib.root_module);
znk.root_module.addOptions("build_options", znk_options);

b.installArtifact(znk);

Expand Down
4 changes: 2 additions & 2 deletions tool/znk.zig
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {
fn generatePrivate(self: *Self) !void {
var rr = RandomReader.init(&std.crypto.random);
var brr = io.BufferedReader(1024 * 4096, @TypeOf(rr.reader())){ .unbuffered_reader = rr.reader() };
while (!self.done.load(.SeqCst)) {
while (!self.done.load(.seq_cst)) {
const gen_result = if (self.entropy) |entropy|
nkeys.SeedKeyPair.generateWithCustomEntropy(self.role, entropy)
else
Expand All @@ -447,7 +447,7 @@ fn PrefixKeyGenerator(comptime EntropyReaderType: type) type {

var public_key = kp.publicKeyText();
if (mem.startsWith(u8, public_key[1..], self.prefix)) {
if (self.done.swap(true, .SeqCst)) return; // another thread is already done
if (self.done.swap(true, .seq_cst)) return; // another thread is already done

info("{s}", .{kp.seedText()});
info("{s}", .{public_key});
Expand Down

0 comments on commit 66e0e65

Please sign in to comment.