Skip to content

Commit

Permalink
change cardano-node module to take socketPath
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru authored and Jimbo4350 committed Dec 6, 2019
1 parent 0bf1d3d commit ccb0657
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
20 changes: 15 additions & 5 deletions nix/nixos/cardano-node-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ let
let exec = "cardano-node";
cmd = builtins.filter (x: x != "") [
"${cfg.package}/bin/${exec}"
"run"
"--genesis-file ${cfg.genesisFile}"
"--genesis-hash ${cfg.genesisHash}"
"--config ${cfg.nodeConfigFile}"
"--database-path ${cfg.databasePath}"
"--socket-path ${if (cfg.runtimeDir == null) then "${cfg.stateDir}/socket" else "/run/${cfg.runtimeDir}"}"
"--socket-path ${cfg.socketPath}"
"--topology ${cfg.topology}"
"--host-addr ${cfg.hostAddr}"
"--port ${toString cfg.port}"
Expand All @@ -28,11 +29,12 @@ let
] ++ cfg.extraArgs;
in ''
choice() { i=$1; shift; eval "echo \''${$((i + 1))}"; }
echo "Starting ${exec}: '' + concatStringsSep "\"\n echo \"" cmd + ''"
echo "Starting ${exec}: ${concatStringsSep "\"\n echo \"" cmd}"
echo "..or, once again, in a single line:"
echo "'' + toString cmd + ''"
ls -l ${if (cfg.runtimeDir == null) then "${cfg.stateDir}/socket" else "/run/${cfg.runtimeDir}"} || true
'' + toString cmd;
echo "${toString cmd}"
ls -l ${cfg.socketPath} || true
${toString cmd}
'';
in {
options = {
services.cardano-node = {
Expand Down Expand Up @@ -150,6 +152,14 @@ in {
'';
};

socketPath = mkOption {
type = types.str;
default = "${cfg.stateDir}/socket/node-core-${cfg.environment}.socket";
description = ''
Socket that the node will be listening on
'';
};

databasePath = mkOption {
type = types.str;
default = "${cfg.stateDir}/${cfg.dbPrefix}";
Expand Down
11 changes: 9 additions & 2 deletions nix/nixos/chairman-as-a-service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let
envConfig = environments.${cfg.environment};
mkChairmanConfig = nodeConfig: chairmanConfig: {
inherit (nodeConfig) package genesisFile genesisHash stateDir pbftThreshold consensusProtocol;
inherit (chairmanConfig) timeout maxBlockNo k slot-length node-ids nodeConfigFile nodeConfig timeoutIsSuccess;
inherit (chairmanConfig) timeout maxBlockNo k slot-length socketPath node-ids nodeConfigFile nodeConfig timeoutIsSuccess;
};
mkScript = cfg:
let nodeIdArgs = builtins.toString
Expand All @@ -26,7 +26,7 @@ let
"--security-param ${toString cfg.k}"
"--genesis-file ${cfg.genesisFile}"
"--genesis-hash ${cfg.genesisHash}"
"--socket-path ${if (ncfg.runtimeDir == null) then "${ncfg.stateDir}/socket" else "/run/${ncfg.runtimeDir}"}"
"--socket-path ${cfg.socketPath}"
"--config ${cfg.nodeConfigFile}"
"${optionalString cfg.timeoutIsSuccess "--timeout-is-success"}"
];
Expand Down Expand Up @@ -107,6 +107,13 @@ in {
default = 20;
description = ''Duration of a slot, in seconds.'';
};
socketPath = mkOption {
type = types.str;
default = "${cfg.stateDir}/socket/node-core-0.socket";
description = ''
Socket that the chairman will be connect to
'';
};
};
};
config = mkIf cfg.enable ( let stateDirBase = "/var/lib/"; in {
Expand Down
2 changes: 1 addition & 1 deletion nix/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let
signingKey = null;
delegationCertificate = null;
nodeId = 0;
stateDir = "./";
stateDir = ".";
# defaults to proxy if env has no relays
edgeHost = "127.0.0.1";
edgeNodes = [];
Expand Down
7 changes: 3 additions & 4 deletions nix/svclib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ let
}) topoSpec;
};
in toFile "legacy-topology.json" (toJSON (mkTopo));

## mkFullyConnectedLocalClusterTopology
## :: String Address -> String Port -> Int PortNo -> Int Valency
## -> Topology FilePath
Expand All @@ -70,8 +70,7 @@ let
mkShelleyNode = id: {
nodeId = id;
nodeAddress = { port = port-base + id; addr = addr-fn id; };
producers = map (mkPeer) (remove id shelley-ids) ++
[ { inherit valency; port = proxy-port; addr = proxy-addr; } ];
producers = { inherit valency; port = proxy-port; addr = proxy-addr; } ;
};
topology = map mkShelleyNode shelley-ids;
in toFile "topology.yaml" (toJSON topology);
Expand Down Expand Up @@ -226,7 +225,7 @@ let
enable = true;
legacy-node-count = 4;
shelley-node-count = 3;
genesis-dir = "${../configuration/b0109}";
genesis-dir = "${../configuration/c0c75}";
}
## NOTE: we do the above defaulting, so the following works, FWIW
## nix-build -A scripts.mainnet.chairman
Expand Down

0 comments on commit ccb0657

Please sign in to comment.