Skip to content

Commit

Permalink
build: revert to zig v0.13 (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro authored and ybensacq committed Oct 3, 2024
1 parent 1028fa7 commit 346312d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
branches: [main]

env:
ZIG_VERSION: 0.14.0-dev.1550+4fba7336a
ZIG_VERSION: 0.13.0

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
permissions: write-all

env:
ZIG_VERSION: 0.14.0-dev.1550+4fba7336a
ZIG_VERSION: 0.13.0

jobs:
docs:
Expand Down
4 changes: 4 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 12 additions & 8 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 1 addition & 5 deletions src/network/protocol/messages/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 => {}
}
Expand All @@ -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(),
};
Expand Down
17 changes: 8 additions & 9 deletions src/network/rpc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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});

Expand All @@ -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!";
}
Expand All @@ -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
Expand All @@ -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 =
\\<!DOCTYPE html>
\\ <p>Running Bitcoin.
;
}

fn @"error"(_: *Handler, _: *httpz.Request, _: *httpz.Response) !void {
fn @"error"(_: *httpz.Request, _: *httpz.Response) !void {
return error.ActionError;
}
1 change: 0 additions & 1 deletion src/vanitygen.zig
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ fn threadSearcher(
// send to sender

if (f) {
@branchHint(.cold);
return sender.send(keys_and_address) catch return;
}
}
Expand Down

0 comments on commit 346312d

Please sign in to comment.