Skip to content

Commit

Permalink
🚧 clean up unused params
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdelStark committed Sep 3, 2024
1 parent 3a5fdbd commit 3b9a17a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
6 changes: 1 addition & 5 deletions src/cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}

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

Expand Down

0 comments on commit 3b9a17a

Please sign in to comment.