Skip to content

Commit

Permalink
Accept config file (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
lynshi authored Apr 1, 2020
1 parent 6f7b4dc commit d827694
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
37 changes: 37 additions & 0 deletions sphinx/source/operators/start_network.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,43 @@ If the network has already been opened to users, members need to trust the joini
.. note:: When starting up the network or when joining an existing network, the secrets required to decrypt the ledger are sealed and written to a file so that the network can later be recovered. See :ref:`operators/recovery:Catastrophic Recovery` for more details on how to recover a crashed network.
.. note:: If starting up the network with PBFT enabled as the consensus protocol, be sure to add the ``--consensus pbft`` CLI argument when starting up the node. For more info on the provided consensus protocols please see :ref:`here <developers/consensus:Consensus Protocols>`

Using a Configuration File
--------------------------

``cchost`` can be started using a configuration file in TOML or INI format.

.. code-block:: toml
# config.toml
enclave-file = <enclave-file>
enclave-type = debug
consensus = raft
node-address = <node-address>
rpc-address = <rpc-address>
public-rpc-address = <public-rpc-address>
[<subcommand, one of [start, join, recover]>]
network-cert-file = <network-cert-file-name>
member-info = "<member_cert.pem>,<member_kshare_pub.pem>"
gov-script = <gov-script-name>
.. code-block:: ini
; config.ini
enclave-file = <enclave-file>
enclave-type = debug
consensus = raft
node-address = <node-address>
rpc-address = <rpc-address>
public-rpc-address = <public-rpc-address>
[<subcommand, one of [start, join, recover]>]
network-cert-file = <network-cert-file-name>
member-info = "<member_cert.pem>,<member_kshare_pub.pem>"
gov-script = <gov-script-name>
To pass configuration files, use the ``--config`` option: ``./cchost --config=config.ini``. An error will be generated if the configuration file contains extra fields. Options in the configuration file will be read along with normal command line arguments. Additional information for configuration files in CLI11 can be found `here <https://cliutils.github.io/CLI11/book/chapters/config.html>`_.

Opening a Network to Users
--------------------------

Expand Down
2 changes: 1 addition & 1 deletion sphinx/source/quickstart/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Once this is done, you can quickly spin up a CCF network and start :ref:`issuing
[2019-10-29 14:48:12.138] See https://microsoft.github.io/CCF/users/issue_commands.html for more information.
[2019-10-29 14:48:12.138] Press Ctrl+C to shutdown the network.
You should also get familiar with some of :ref:`concepts:CCF's concepts`. You will then be able to:
You should also get familiar with some of :ref:`CCF's concepts <concepts:CCF Concepts>`. You will then be able to:

1. :ref:`Create a consortium and agree on the constitution <members/index:Member Governance>`
2. :ref:`Develop a CCF application, based on the example logging application <developers/example:Example Application>`
Expand Down
9 changes: 9 additions & 0 deletions src/host/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ int main(int argc, char** argv)

CLI::App app{"ccf"};

app.set_config("--config", "", "Read an INI or TOML file", false);
app.allow_config_extras(false);

app.require_subcommand(1, 1);

std::string enclave_file;
Expand Down Expand Up @@ -263,6 +266,8 @@ int main(int argc, char** argv)
std::string network_enc_pubk_file = "network_enc_pubk.pem";

auto start = app.add_subcommand("start", "Start new network");
start->configurable();

start
->add_option(
"--network-cert-file",
Expand Down Expand Up @@ -299,6 +304,8 @@ int main(int argc, char** argv)
->required();

auto join = app.add_subcommand("join", "Join existing network");
join->configurable();

join
->add_option(
"--network-cert-file",
Expand All @@ -325,6 +332,8 @@ int main(int argc, char** argv)
->required();

auto recover = app.add_subcommand("recover", "Recover crashed network");
recover->configurable();

recover
->add_option(
"--network-cert-file",
Expand Down

0 comments on commit d827694

Please sign in to comment.