环境变量 (Environment variables)

默认情况下,每当启动 namada ledger 时,它将应用 ledger 配置文件中找到的配置。

下面显示了一个 ledger 配置文件的示例。

wasm_dir = "wasm"
 
[ledger]
genesis_time = "2023-06-29T17:00:00+00:00"
chain_id = "<namada-mainnet>"
 
[ledger.shell]
base_dir = "/Users/fraccaman/Library/Application Support/Namada"
storage_read_past_height_limit = 3600
db_dir = "db"
cometbft_dir = "cometbft"
tendermint_mode = "Full"
 
[ledger.cometbft]
proxy_app = "tcp://127.0.0.1:26658"
moniker = "1337-leet-1337"
db_backend = "goleveldb"
db_dir = "data"
log_level = "info"
log_format = "plain"
genesis_file = "config/genesis.json"
node_key_file = "config/node_key.json"
abci = "socket"
filter_peers = false
priv_validator_key_file = "config/priv_validator_key.json"
priv_validator_state_file = "data/priv_validator_state.json"
priv_validator_laddr = ""
 
[ledger.cometbft.rpc]
laddr = "tcp://127.0.0.1:26657"
cors_allowed_origins = []
cors_allowed_methods = ["HEAD", "GET", "POST"]
cors_allowed_headers = ["Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"]
unsafe = false
max_open_connections = 900
max_subscription_clients = 100
max_subscriptions_per_client = 5
timeout_broadcast_tx_commit = "10000ms"
max_body_bytes = 1000000
max_header_bytes = 1048576
tls_cert_file = ""
tls_key_file = ""
pprof_laddr = ""
 
[ledger.cometbft.p2p]
laddr = "tcp://0.0.0.0:26656"
external_address = ""
seeds = ""
persistent_peers = "<peer-id>@<ip>:<port>, ..."
upnp = false
addr_book_file = "config/addrbook.json"
addr_book_strict = true
max_num_inbound_peers = 40
max_num_outbound_peers = 10
unconditional_peer_ids = ""
persistent_peers_max_dial_period = "0ms"
flush_throttle_timeout = "100ms"
max_packet_msg_payload_size = 1024
send_rate = 5120000
recv_rate = 5120000
pex = true
seed_mode = false
private_peer_ids = ""
allow_duplicate_ip = false
handshake_timeout = "20000ms"
dial_timeout = "3000ms"
 
[ledger.cometbft.mempool]
recheck = true
broadcast = true
wal_dir = ""
size = 5000
max_txs_bytes = 1073741824
cache_size = 10000
keep-invalid-txs-in-cache = false
max_tx_bytes = 1048576
max_batch_bytes = 0
 
[ledger.cometbft.consensus]
wal_file = "data/cs.wal/wal"
double_sign_check_height = 0
create_empty_blocks = true
create_empty_blocks_interval = "0ms"
peer_gossip_sleep_duration = "100ms"
peer_query_maj23_sleep_duration = "2000ms"
timeout_propose = "3000ms"
timeout_propose_delta = "500ms"
timeout_prevote = "1000ms"
timeout_prevote_delta = "500ms"
timeout_precommit = "1000ms"
timeout_precommit_delta = "500ms"
timeout_commit = "10000ms"
 
[ledger.cometbft.tx_index]
indexer = "null"
 
[ledger.cometbft.instrumentation]
prometheus = false
prometheus_listen_addr = ":26660"
max_open_connections = 3
namespace = "namada_tm"
 
[ledger.cometbft.statesync]
enable = false
rpc_servers = ""
trust_height = 0
trust_hash = ""
trust_period = "168h0m0s"
discovery_time = "15000ms"
temp_dir = ""

然而,通过设置环境变量可以覆盖配置。配置中的任何变量都可以通过以下方式构造的环境变量进行访问。

构造环境变量 (Constructing environment variables)

识别的环境变量的名称是通过以下方式从配置键派生的:

  1. 在Key前添加 NAMADA_

  2. 将键的每个字母大写。例如,p2p_pex 变为 P2P_PEX

  3. 对于每个嵌套值插入 __。例如,ledger.cometbft 变为 LEDGER__COMETBFT

因此,可以通过以下方式设置 [ledger.cometbft] 中的选项 p2p_pex

NAMADA_LEDGER__COMETBFT__P2P_PEX=true # or false, depending on your heart's desires

在环境中。

注意:原则上,甚至可以为环境变量名称使用 .。然而,在 Bash 中,只能使用双下划线形式,因为 Bash 不允许环境变量名称中有点。因此,我们省略了点形式。

Last updated