diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 6b977f7..56144ca 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -7,7 +7,7 @@ on: branches: [main] env: - ZIG_VERSION: 0.14.0-dev.1550+4fba7336a + ZIG_VERSION: 0.13.0 jobs: build: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index adef7a1..4a2f31a 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -7,7 +7,7 @@ on: permissions: write-all env: - ZIG_VERSION: 0.14.0-dev.1550+4fba7336a + ZIG_VERSION: 0.13.0 jobs: docs: diff --git a/build.zig b/build.zig index f337d32..c56f905 100644 --- a/build.zig +++ b/build.zig @@ -21,6 +21,10 @@ const external_dependencies = [_]build_helpers.Dependency{ .name = "bitcoin-primitives", .module_name = "bitcoin-primitives", }, + .{ + .name = "libxev", + .module_name = "xev", + }, }; pub fn build(b: *std.Build) !void { diff --git a/build.zig.zon b/build.zig.zon index 8a26c05..ea0f537 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -6,14 +6,6 @@ .url = "https://github.com/karlseguin/zul/archive/ae0c27350c0db6b460f22cba30b6b0c4a02d1ffd.zip", .hash = "1220457e2c8867f6734520d9b335f01e1d851d6fe7adaa7f6f0756158acaf6c5e87f", }, - .httpz = .{ - .url = "git+https://github.com/karlseguin/http.zig#d3e3fb3cf2f3caa2432338282dbe750f85e24254", - .hash = "12205748a52926d9e6dbb1ac07462d8772c1e2fd6f52e4d822d8bf282f425efd1330", - }, - .clap = .{ - .url = "git+https://github.com/Hejsil/zig-clap#2d9db156ae928860a9acf2f1260750d3b44a4c98", - .hash = "122005e589ab3b6bff8e589b45f5b12cd27ce79f266bdac17e9f33ebfe2fbaff7fe3", - }, .lmdb = .{ .url = "git+https://github.com/zig-bitcoin/zig-lmdb#eb7436d091464131551759b0f80d4f1d1a15ece1", .hash = "1220f9e1eb744c8dc2750c1e6e1ceb1c2d521bedb161ddead1a6bb772032e576d74a", @@ -22,6 +14,18 @@ .url = "git+https://github.com/zig-bitcoin/bitcoin-primitives#6595846b34c8c157175c52380f5c7cc6fc9ca108", .hash = "12208a138853cd57db1c5e3348d60a74aa54d5c0a63393b6367098f1c150a0c31438", }, + .clap = .{ + .url = "https://github.com/Hejsil/zig-clap/archive/refs/tags/0.9.1.tar.gz", + .hash = "122062d301a203d003547b414237229b09a7980095061697349f8bef41be9c30266b", + }, + .libxev = .{ + .url = "https://github.com/mitchellh/libxev/archive/main.tar.gz", + .hash = "1220612bc023c21d75234882ec9a8c6a1cbd9d642da3dfb899297f14bb5bd7b6cd78", + }, + .httpz = .{ + .url = "https://github.com/karlseguin/http.zig/archive/zig-0.13.tar.gz", + .hash = "12208c1f2c5f730c4c03aabeb0632ade7e21914af03e6510311b449458198d0835d6", + }, }, .paths = .{ "build.zig", diff --git a/src/network/protocol/messages/lib.zig b/src/network/protocol/messages/lib.zig index fa25f2d..8d897d9 100644 --- a/src/network/protocol/messages/lib.zig +++ b/src/network/protocol/messages/lib.zig @@ -18,7 +18,6 @@ const Sha256 = std.crypto.hash.sha2.Sha256; pub const NotFoundMessage = @import("notfound.zig").NotFoundMessage; pub const SendHeadersMessage = @import("sendheaders.zig").SendHeadersMessage; pub const FilterLoadMessage = @import("filterload.zig").FilterLoadMessage; -pub const GetdataMessage = @import("getdata.zig").GetdataMessage; pub const HeadersMessage = @import("headers.zig").HeadersMessage; pub const CmpctBlockMessage = @import("cmpctblock.zig").CmpctBlockMessage; @@ -98,10 +97,7 @@ pub const Message = union(MessageTypes) { .block => |*m| m.deinit(allocator), .filteradd => |*m| m.deinit(allocator), .getdata => |*m| m.deinit(allocator), - .notfound => {}, .cmpctblock => |*m| m.deinit(allocator), - .sendheaders => {}, - .filterload => {}, .headers => |*m| m.deinit(allocator), else => {} } @@ -125,7 +121,7 @@ pub const Message = union(MessageTypes) { .notfound => |*m| m.checksum(), .sendheaders => |*m| m.checksum(), .filterload => |*m| m.checksum(), - .getdata => |m| *m.checksum(), + .getdata => |*m| m.checksum(), .headers => |*m| m.checksum(), .cmpctblock => |*m| m.checksum(), }; diff --git a/src/network/rpc.zig b/src/network/rpc.zig index 56c24de..7e0e44a 100644 --- a/src/network/rpc.zig +++ b/src/network/rpc.zig @@ -54,13 +54,12 @@ pub const RPC = struct { /// The RPC server will start a HTTP server and listen on the RPC port. pub fn start(self: *RPC) !void { std.log.info("Starting RPC server on port {}", .{self.config.rpc_port}); - var handler = Handler{}; - var server = try httpz.Server(*Handler).init(self.allocator, .{ .port = self.config.rpc_port }, &handler); - var router = server.router(.{}); + var server = try httpz.Server().init(self.allocator, .{ .port = self.config.rpc_port }); + var router = server.router(); // Register routes. - router.get("/", index, .{}); - router.get("/error", @"error", .{}); + router.get("/", index); + router.get("/error", @"error"); std.log.info("RPC server listening on http://localhost:{d}/\n", .{self.config.rpc_port}); @@ -74,7 +73,7 @@ const Handler = struct { // If the handler defines a special "notFound" function, it'll be called // when a request is made and no route matches. - pub fn notFound(_: *Handler, _: *httpz.Request, res: *httpz.Response) !void { + pub fn notFound(_: *httpz.Request, res: *httpz.Response) !void { res.status = 404; res.body = "NOPE!"; } @@ -83,7 +82,7 @@ const Handler = struct { // called when an action returns an error. // Note that this function takes an additional parameter (the error) and // returns a `void` rather than a `!void`. - pub fn uncaughtError(_: *Handler, req: *httpz.Request, res: *httpz.Response, err: anyerror) void { + pub fn uncaughtError(req: *httpz.Request, res: *httpz.Response, err: anyerror) void { std.debug.print("uncaught http error at {s}: {}\n", .{ req.url.path, err }); // Alternative to res.content_type = .TYPE @@ -96,13 +95,13 @@ const Handler = struct { } }; -fn index(_: *Handler, _: *httpz.Request, res: *httpz.Response) !void { +fn index(_: *httpz.Request, res: *httpz.Response) !void { res.body = \\ \\

Running Bitcoin. ; } -fn @"error"(_: *Handler, _: *httpz.Request, _: *httpz.Response) !void { +fn @"error"(_: *httpz.Request, _: *httpz.Response) !void { return error.ActionError; } diff --git a/src/vanitygen.zig b/src/vanitygen.zig index cf33704..74f3dbf 100644 --- a/src/vanitygen.zig +++ b/src/vanitygen.zig @@ -151,7 +151,6 @@ fn threadSearcher( // send to sender if (f) { - @branchHint(.cold); return sender.send(keys_and_address) catch return; } }