Skip to content

Commit

Permalink
feat(protocol): VersionMessage with (de)serialization (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro authored Sep 10, 2024
1 parent 4597bfa commit d6241c6
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 53 deletions.
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
.hash = "1220f9e1eb744c8dc2750c1e6e1ceb1c2d521bedb161ddead1a6bb772032e576d74a",
},
.@"bitcoin-primitives" = .{
.url = "git+https://github.com/zig-bitcoin/bitcoin-primitives#17430ab361bb966b7cabb6c835adbe79c72276aa",
.hash = "12205840417b3b689acadf210bf1c815de4045381aa744d64e93e332bb49e9714d5f",
.url = "git+https://github.com/zig-bitcoin/bitcoin-primitives#4d179bb3027dbc35a99a56938c05008b62e4bf7e",
.hash = "1220a65f6105a79c9347449d2553e7abf965b3f61fa883478954d861e824631d5396",
},
},
.paths = .{
Expand Down
15 changes: 12 additions & 3 deletions src/config/config.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
const std = @import("std");

const dns_seed = [:0]const u8;

const DNS_SEEDS = [3]dns_seed{
"seed.bitcoin.sipa.be",
"seed.bitcoin.sprovoost.nl",
"seed.btc.petertodd.net",
};

/// Global configuration for the node
///
/// This is loaded from the `bitcoin.conf` file
Expand All @@ -20,8 +28,6 @@ pub const Config = struct {
/// Data directory
datadir: [:0]const u8,

seednode: []const u8,

/// Load the configuration from a file
///
/// # Arguments
Expand All @@ -46,7 +52,6 @@ pub const Config = struct {
.p2p_port = 8333,
.testnet = false,
.datadir = ".bitcoin",
.seednode = "",
};

var buf: [1024]u8 = undefined;
Expand All @@ -69,6 +74,10 @@ pub const Config = struct {
return config;
}

pub inline fn dnsSeeds() [3]dns_seed {
return DNS_SEEDS;
}

pub fn deinit(self: *Config) void {
self.allocator.free(self.datadir);
}
Expand Down
1 change: 0 additions & 1 deletion src/core/mempool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ test "Mempool" {
.p2p_port = 8333,
.testnet = false,
.datadir = "/tmp/btczee",
.seednode = "",
};
var mempool = try Mempool.init(allocator, &config);
defer mempool.deinit();
Expand Down
Loading

0 comments on commit d6241c6

Please sign in to comment.