Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Oct 22, 2024
1 parent bfa24b1 commit 53c4d9c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
24 changes: 18 additions & 6 deletions Boka/Sources/Boka.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import ServiceLifecycle
import TracingUtils
import Utils

private let logger = Logger(label: "cli")

extension Genesis: @retroactive ExpressibleByArgument {
public init?(argument: String) {
if let preset = GenesisPreset(rawValue: argument) {
Expand Down Expand Up @@ -80,6 +78,9 @@ struct Boka: AsyncParsableCommand {
@Option(name: .long, help: "For development only. Seed for validator keys.")
var devSeed: UInt32?

@Option(name: .long, help: "Node name. For telemetry only.")
var name: String?

mutating func run() async throws {
let services = try await Tracing.bootstrap("Boka", loggerOnly: true)
for service in services {
Expand All @@ -88,21 +89,32 @@ struct Boka: AsyncParsableCommand {
}
}

let logger = Logger(label: "cli")

logger.info("Starting Boka. Chain: \(chain)")

if let name {
logger.info("Node name: \(name)")
}

if let basePath {
logger.info("Base path: \(basePath)")
}

print("Peers: \(peers)")
logger.info("Peers: \(peers)")

if validator {
print("Running as validator")
logger.info("Running as validator")
} else {
logger.info("Running as fullnode")
}

if let operatorRpc {
print("Operator RPC listen address: \(operatorRpc)")
logger.info("Operator RPC listen address: \(operatorRpc)")
}

let rpcConfig = rpc.asOptional.map { addr -> RPCConfig in
logger.info("RPC listen address: \(addr)")
let (address, port) = addr.getAddressAndPort()
return RPCConfig(listenAddress: address, port: Int(port))
}
Expand Down Expand Up @@ -146,6 +158,6 @@ struct Boka: AsyncParsableCommand {

try await node.wait()

print("Shutting down...")
logger.notice("Shutting down...")
}
}
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ format-all: format format-cargo
.PHONY: format-clang
format-clang:
find . \( -name "*.c" -o -name "helpers.h" \) -exec clang-format -i {} +

.PHONY: run
run: githooks
swift run --package-path Boka
swift run --package-path Boka Boka --validator

.PHONY: devnet
devnet:
./scripts/devnet.sh
2 changes: 1 addition & 1 deletion scripts/devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ do
create_node $i
done

# Attach to the tmux session
# Attach to the tmux session, -CC for iTerm2 integration
tmux -CC attach-session -t boka

0 comments on commit 53c4d9c

Please sign in to comment.