diff --git a/src/cli.zig b/src/cli.zig index 3fd0171..0e9af32 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -4,14 +4,10 @@ const RPC = @import("rpc.zig").RPC; pub const CLI = struct { allocator: std.mem.Allocator, - config: *const Config, - rpc: *RPC, - pub fn init(allocator: std.mem.Allocator, config: *const Config, rpc: *RPC) !CLI { + pub fn init(allocator: std.mem.Allocator) !CLI { return CLI{ .allocator = allocator, - .config = config, - .rpc = rpc, }; } diff --git a/src/main.zig b/src/main.zig index b6bd0ae..ed5f185 100644 --- a/src/main.zig +++ b/src/main.zig @@ -16,6 +16,9 @@ pub fn main() !void { var config = try Config.load(allocator, "bitcoin.conf.example"); defer config.deinit(); + var cli = try CLI.init(allocator); + defer cli.deinit(); + // Initialize components var mempool = try Mempool.init(allocator, &config); defer mempool.deinit(); @@ -26,17 +29,14 @@ pub fn main() !void { var p2p = try P2P.init(allocator, &config); defer p2p.deinit(); - var rpc = try RPC.init(allocator, &config, &mempool, &storage, &p2p); + var rpc = try RPC.init(allocator, &config, &mempool, &storage); defer rpc.deinit(); - var cli = try CLI.init(allocator, &config, &rpc); - defer cli.deinit(); - // Start the node try startNode(&mempool, &storage, &p2p, &rpc, &cli); } -fn startNode(_: *Mempool, _: *Storage, p2p: *P2P, rpc: *RPC, cli: *CLI) !void { +fn startNode(_: *Mempool, _: *Storage, p2p: *P2P, rpc: *RPC, _: *CLI) !void { std.log.info("Starting btczee node...", .{}); // Start P2P network @@ -45,9 +45,6 @@ fn startNode(_: *Mempool, _: *Storage, p2p: *P2P, rpc: *RPC, cli: *CLI) !void { // Start RPC server try rpc.start(); - // Start CLI - try cli.start(); - // Main event loop while (true) { // Handle events, process blocks, etc. diff --git a/src/rpc.zig b/src/rpc.zig index dfb27d0..dd9f918 100644 --- a/src/rpc.zig +++ b/src/rpc.zig @@ -9,15 +9,18 @@ pub const RPC = struct { config: *const Config, mempool: *Mempool, storage: *Storage, - p2p: *P2P, - pub fn init(allocator: std.mem.Allocator, config: *const Config, mempool: *Mempool, storage: *Storage, p2p: *P2P) !RPC { + pub fn init( + allocator: std.mem.Allocator, + config: *const Config, + mempool: *Mempool, + storage: *Storage, + ) !RPC { return RPC{ .allocator = allocator, .config = config, .mempool = mempool, .storage = storage, - .p2p = p2p, }; }