# Polkadot Node Environment Configuration
# Generated by provisioning system

POLKADOT_VERSION={{ polkadot_node.version }}
POLKADOT_RUN_USER={{ polkadot_node.run_user.name }}
POLKADOT_RUN_GROUP={{ polkadot_node.run_user.group }}
POLKADOT_RUN_USER_HOME={{ polkadot_node.run_user.home }}
POLKADOT_WORK_PATH={{ polkadot_node.work_path }}
POLKADOT_CONFIG_PATH={{ polkadot_node.config_path }}
POLKADOT_BIN_PATH={{ polkadot_node.bin_path }}
POLKADOT_BASE_PATH={{ polkadot_node.base_path }}

# Node Configuration
POLKADOT_NODE_NAME={{ polkadot_node.name }}
POLKADOT_NODE_TYPE={{ polkadot_node.node_type }}
POLKADOT_SYNC_MODE={{ polkadot_node.sync_mode }}
POLKADOT_ARCHIVE_MODE={{ polkadot_node.archive_mode | lower }}

# Network Configuration
POLKADOT_CHAIN={{ polkadot_node.network.chain }}
POLKADOT_LISTEN_ADDR="{{ polkadot_node.network.listen_addr }}"
{% if polkadot_node.network.public_addr is defined %}
POLKADOT_PUBLIC_ADDR="{{ polkadot_node.network.public_addr }}"
{% endif %}
POLKADOT_MAX_PEERS={{ polkadot_node.network.max_peers }}
POLKADOT_MAX_PEERS_LIGHT={{ polkadot_node.network.max_peers_light }}
POLKADOT_RESERVED_ONLY={{ polkadot_node.network.reserved_only | lower }}

# Bootnodes and Reserved Nodes
{% if polkadot_node.network.bootnodes %}
POLKADOT_BOOTNODES="{{ polkadot_node.network.bootnodes | join(',') }}"
{% endif %}
{% if polkadot_node.network.reserved_nodes %}
POLKADOT_RESERVED_NODES="{{ polkadot_node.network.reserved_nodes | join(',') }}"
{% endif %}

# RPC Configuration
POLKADOT_RPC_ENABLED={{ polkadot_node.rpc.enabled | lower }}
POLKADOT_RPC_BIND_ADDR={{ polkadot_node.rpc.bind_addr }}
POLKADOT_RPC_PORT={{ polkadot_node.rpc.port }}
POLKADOT_WS_PORT={{ polkadot_node.rpc.ws_port }}
POLKADOT_HTTP_PORT={{ polkadot_node.rpc.http_port }}
POLKADOT_RPC_MAX_CONNECTIONS={{ polkadot_node.rpc.max_connections }}
POLKADOT_RPC_CORS="{{ polkadot_node.rpc.cors | join(',') }}"
POLKADOT_RPC_METHODS="{{ polkadot_node.rpc.methods | join(',') }}"
{% if polkadot_node.rpc.rate_limit is defined %}
POLKADOT_RPC_RATE_LIMIT={{ polkadot_node.rpc.rate_limit }}
{% endif %}

# Pruning Configuration
POLKADOT_PRUNING_ENABLED={{ polkadot_node.pruning.enabled | lower }}
POLKADOT_PRUNING_MODE={{ polkadot_node.pruning.mode }}
POLKADOT_BLOCKS_TO_KEEP={{ polkadot_node.pruning.blocks_to_keep }}
POLKADOT_STATE_PRUNING={{ polkadot_node.pruning.state_pruning }}
{% if polkadot_node.pruning.block_pruning is defined %}
POLKADOT_BLOCK_PRUNING={{ polkadot_node.pruning.block_pruning }}
{% endif %}

# Execution and Performance
POLKADOT_EXECUTION={{ polkadot_node.execution }}
POLKADOT_WASM_EXECUTION={{ polkadot_node.wasm_execution }}
POLKADOT_STATE_CACHE_SIZE={{ polkadot_node.state_cache_size }}
POLKADOT_DB_CACHE={{ polkadot_node.db_cache }}

# Logging Configuration
POLKADOT_LOG_LEVEL={{ polkadot_node.log_level }}
{% if polkadot_node.log_targets %}
POLKADOT_LOG_TARGETS="{{ polkadot_node.log_targets | join(',') }}"
{% endif %}

# Telemetry Configuration
POLKADOT_TELEMETRY_ENABLED={{ polkadot_node.telemetry.enabled | lower }}
POLKADOT_TELEMETRY_URL="{{ polkadot_node.telemetry.url }}"
POLKADOT_TELEMETRY_VERBOSITY={{ polkadot_node.telemetry.verbosity }}

# WSS Configuration
POLKADOT_WSS_ENABLED={{ polkadot_node.wss.enabled | lower }}
{% if polkadot_node.wss.enabled %}
POLKADOT_WSS_PORT={{ polkadot_node.wss.port }}
POLKADOT_WSS_DOMAIN="{{ polkadot_node.wss.domain }}"
POLKADOT_WSS_PROXY_TYPE={{ polkadot_node.wss.proxy_type }}
POLKADOT_WSS_RATE_LIMIT={{ polkadot_node.wss.rate_limit }}

# SSL Configuration for WSS
POLKADOT_SSL_ENABLED={{ polkadot_node.wss.ssl.enabled | lower }}
{% if polkadot_node.wss.ssl.enabled %}
POLKADOT_SSL_CERT_FILE="{{ polkadot_node.wss.ssl.cert_file }}"
POLKADOT_SSL_KEY_FILE="{{ polkadot_node.wss.ssl.key_file }}"
{% if polkadot_node.wss.ssl.ca_file is defined %}
POLKADOT_SSL_CA_FILE="{{ polkadot_node.wss.ssl.ca_file }}"
{% endif %}
{% endif %}
{% endif %}