Node: more CLI argument
This commit is contained in:
parent
2da0c83b5a
commit
b228904bc7
37
README.md
37
README.md
@ -61,7 +61,7 @@ Running the node in a sandbox
|
||||
To run a single instance of a Tezos node in sandbox mode:
|
||||
|
||||
```
|
||||
./tezos-node --sandbox /path/to/a/custom/data/dir --rpc-addr :::8732
|
||||
./tezos-node --sandbox --rpc-addr :::8732
|
||||
```
|
||||
|
||||
This "sandboxed" node will not participate in the P2P network, but will accept
|
||||
@ -77,20 +77,22 @@ test network. Use the following command to run a node that will accept incoming
|
||||
connections:
|
||||
|
||||
```
|
||||
./tezos-node
|
||||
./tezos-node --generate-identity --expected-pow 24.
|
||||
```
|
||||
|
||||
The node will listen to connections coming in on `0.0.0.0:9732` (and
|
||||
`[::]:9732`). All used data is stored at `$HOME/.tezos-node/`. For example,
|
||||
the default configuration file is at `$HOME/.tezos-node/config`.
|
||||
This will first generate a new node identity and compute the associated stamp
|
||||
of proof-of-work. Then, the node will listen to connections coming in on
|
||||
`0.0.0.0:9732` (and`[::]:9732`). All used data is stored at
|
||||
`$HOME/.tezos-node/`. For example, the default configuration file is
|
||||
at `$HOME/.tezos-node/config.json`.
|
||||
|
||||
To run multiple nodes on the same machine, you can duplicate and edit
|
||||
`$HOME/.tezos-node/config` while making sure they don't share paths to the
|
||||
`$HOME/.tezos-node/config.json` while making sure they don't share paths to the
|
||||
database or any other data file (cf. options `db.store` ; `db.context` ;
|
||||
`net.peers` and `protocol.dir`).
|
||||
`db.protocol`, `net.peers-metadata` and `net.identity`).
|
||||
|
||||
You could also let Tezos generate a config file by specifying options on the
|
||||
command line. For instance, if `$dir/config` does not exist, the following
|
||||
command line. For instance, if `$dir/config.json` does not exist, the following
|
||||
command will generate it and replace the default values with the values from
|
||||
the command line:
|
||||
|
||||
@ -102,20 +104,23 @@ The Tezos server has a built-in mechanism to discover peers on the local
|
||||
network (using UDP packets broadcasted on port 7732).
|
||||
|
||||
If this mechanism is not sufficient, one can provide Tezos with a list of
|
||||
initial peers, either by editing the option `net.bootstrap.peers` in the
|
||||
`config` file, or by specifying a command line parameter:
|
||||
initial peers, either by editing the option `net.bootstrap-peers` in the
|
||||
`config.json` file, or by specifying a command line parameter:
|
||||
|
||||
```
|
||||
./tezos-node --base-dir "$dir" --net-addr 127.0.0.1:2023 \
|
||||
--peer 127.0.0.1:2021 --peer 127.0.0.1:2022
|
||||
```
|
||||
|
||||
If `"$dir"/config` exists, the command line options override those read in the
|
||||
config file. Tezos won't modify the content of an existing `"$dir"/config`
|
||||
file.
|
||||
If `"$dir"/config.json` exists, the command line options override those
|
||||
read in the config file. By default, Tezos won't modify the content of an
|
||||
existing `"$dir"/config.json` file. But, you may explicit ask the node
|
||||
to reset or to update the file according to the command line parameters
|
||||
with the following commands line:
|
||||
|
||||
```
|
||||
./tezos-node --config-file "$dir"/config
|
||||
./tezos-node --reset-config --base-dir "$dir" --net-addr 127.0.0.1:9733
|
||||
./tezos-node --update-config --base-dir "$dir" --net-addr 127.0.0.1:9734
|
||||
```
|
||||
|
||||
|
||||
@ -129,7 +134,7 @@ Typically, if you are not trying to run a local network and just want to
|
||||
explore the RPC, you would run:
|
||||
|
||||
```
|
||||
./tezos-node --sandbox /path/to/a/custom/data/dir --rpc-addr :::8732
|
||||
./tezos-node --sandbox --rpc-addr :::8732
|
||||
```
|
||||
|
||||
The RPC interface is self-documented and the `tezos-client` executable is able
|
||||
@ -151,7 +156,7 @@ You might also want the JSON schema describing the expected input and output of
|
||||
a RPC. For instance:
|
||||
|
||||
```
|
||||
./tezos-client rpc schema /block/genesis/hash
|
||||
./tezos-client rpc schema /blocks/genesis/hash
|
||||
```
|
||||
|
||||
Note: you can get the same information, but as a raw JSON object, with a simple
|
||||
|
@ -449,7 +449,7 @@ module Gid_info = struct
|
||||
|
||||
let load path metadata_encoding =
|
||||
let enc = Data_encoding.list (encoding metadata_encoding) in
|
||||
if Sys.file_exists path then
|
||||
if path <> "/dev/null" && Sys.file_exists path then
|
||||
Data_encoding_ezjsonm.read_file path >>=? fun json ->
|
||||
return (Data_encoding.Json.destruct enc json)
|
||||
else
|
||||
|
@ -215,9 +215,17 @@ let init_p2p net_params =
|
||||
Lwt.async (fun () -> Tezos_p2p.maintain p2p) ;
|
||||
Lwt.return p2p
|
||||
|
||||
type config = {
|
||||
genesis: Store.genesis ;
|
||||
store_root: string ;
|
||||
context_root: string ;
|
||||
test_protocol: Protocol_hash.t option ;
|
||||
patch_context: (Context.t -> Context.t Lwt.t) option ;
|
||||
p2p: (P2p.config * P2p.limits) option ;
|
||||
}
|
||||
|
||||
let create
|
||||
~genesis ~store_root ~context_root ?test_protocol ?patch_context net_params =
|
||||
let create { genesis ; store_root ; context_root ;
|
||||
test_protocol ; patch_context ; p2p = net_params } =
|
||||
lwt_debug "-> Node.create" >>= fun () ->
|
||||
init_p2p net_params >>= fun p2p ->
|
||||
lwt_log_info "reading state..." >>= fun () ->
|
||||
|
@ -9,14 +9,16 @@
|
||||
|
||||
type t
|
||||
|
||||
val create:
|
||||
genesis:Store.genesis ->
|
||||
store_root:string ->
|
||||
context_root:string ->
|
||||
?test_protocol:Protocol_hash.t ->
|
||||
?patch_context:(Context.t -> Context.t Lwt.t) ->
|
||||
(P2p.config * P2p.limits) option ->
|
||||
t tzresult Lwt.t
|
||||
type config = {
|
||||
genesis: Store.genesis ;
|
||||
store_root: string ;
|
||||
context_root: string ;
|
||||
test_protocol: Protocol_hash.t option ;
|
||||
patch_context: (Context.t -> Context.t Lwt.t) option ;
|
||||
p2p: (P2p.config * P2p.limits) option ;
|
||||
}
|
||||
|
||||
val create: config -> t tzresult Lwt.t
|
||||
|
||||
module RPC : sig
|
||||
|
||||
|
1105
src/node_main.ml
1105
src/node_main.ml
File diff suppressed because it is too large
Load Diff
@ -5,8 +5,8 @@ set -e
|
||||
DIR=$(dirname "$0")
|
||||
cd "${DIR}"
|
||||
|
||||
DATA_DIR=$(mktemp -d /tmp/tezos_node.XXXXXXXXXX)
|
||||
CLIENT_DIR=$(mktemp -d /tmp/tezos_client.XXXXXXXXXX)
|
||||
DATA_DIR="$(mktemp -td tezos_node.XXXXXXXXXX)"
|
||||
CLIENT_DIR="$(mktemp -td tezos_client.XXXXXXXXXX)"
|
||||
|
||||
cleanup() {
|
||||
rm -fr ${DATA_DIR} ${CLIENT_DIR}
|
||||
@ -17,8 +17,8 @@ trap cleanup EXIT QUIT INT
|
||||
NODE=../tezos-node
|
||||
CLIENT="../tezos-client -base-dir ${CLIENT_DIR}"
|
||||
|
||||
CUSTOM_PARAM="--sandbox-param ./sandbox.json"
|
||||
${NODE} --sandbox "${DATA_DIR}" ${CUSTOM_PARAM} --rpc-addr :::8732 > LOG 2>&1 &
|
||||
CUSTOM_PARAM="--sandbox ./sandbox.json"
|
||||
${NODE} --base-dir "${DATA_DIR}" ${CUSTOM_PARAM} --rpc-addr :::8732 > LOG 2>&1 &
|
||||
NODE_PID="$!"
|
||||
|
||||
sleep 3
|
||||
|
@ -50,8 +50,8 @@ let fork_node () =
|
||||
Unix.create_process
|
||||
Filename.(concat (dirname (Sys.getcwd ())) "tezos-node")
|
||||
[| "tezos-node" ;
|
||||
"--sandbox"; data_dir ;
|
||||
"--sandbox-param"; "./sandbox.json";
|
||||
"--base-dir"; data_dir ;
|
||||
"--sandbox"; "./sandbox.json";
|
||||
"--rpc-addr"; ":::8732" |]
|
||||
null_fd log_fd log_fd in
|
||||
Printf.printf "Created node, pid: %d, log: %s\n%!" pid log_file_name ;
|
||||
|
Loading…
Reference in New Issue
Block a user