mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-07-04 16:30:02 +00:00
fix: mix pool format and string inlining into config (#1479)
This commit is contained in:
parent
8e0fb9f53e
commit
5a31e67ce8
@ -1,24 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Script for generating configuration files and network presets for
|
||||
# Logos Storage.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Valid networks
|
||||
declare -A _networks
|
||||
#_networks=([test]="Logos testnet" [dev]="Logos devnet")
|
||||
_networks=([dev]="Logos devnet")
|
||||
|
||||
echoerr() {
|
||||
echo "[storage_config] $1" >&2
|
||||
}
|
||||
|
||||
require() {
|
||||
if ! command -v "$1" &> /dev/null; then
|
||||
echoerr "Error: $1 is not installed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
# Needs bash 4 or higher
|
||||
if ((${BASH_VERSION:-0} < 4)); then
|
||||
echoerr "Error: This script requires Bash 4 or higher."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Needs jq
|
||||
if ! command -v jq &> /dev/null; then
|
||||
echoerr "Error: jq is not installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Valid networks
|
||||
declare -A _networks
|
||||
_networks=([dev]="Logos devnet" [test]="Logos testnet")
|
||||
|
||||
check_network() {
|
||||
local network=$1
|
||||
@ -37,12 +40,15 @@ raw_data() {
|
||||
mix_pool_json() {
|
||||
local network=$1
|
||||
check_network "$network"
|
||||
raw_data "$network" | jq 'map({
|
||||
"peerId": .peerId,
|
||||
"mixPubKey": .mixPubKey,
|
||||
"libp2pPubKey": .libp2pPubKey,
|
||||
"multiAddr": "/ip4/\(.address)/tcp/\(.port)",
|
||||
})'
|
||||
raw_data "$network" | jq -c '{
|
||||
"version": 1,
|
||||
"relays": map({
|
||||
"peerId": .peerId,
|
||||
"mixPubKey": .mixPubKey,
|
||||
"libp2pPubKey": .libp2pPubKey,
|
||||
"multiAddr": "/ip4/\(.address)/tcp/\(.port)",
|
||||
})
|
||||
}'
|
||||
}
|
||||
|
||||
bootstrap_sprs() {
|
||||
@ -67,7 +73,7 @@ full_config() {
|
||||
"network": "logos.${network}",
|
||||
"mix-enabled": true,
|
||||
"dht-mix-proxy": $(mix_proxy_sprs "$network"),
|
||||
"mix-pool-json": $(mix_pool_json "$network"),
|
||||
"mix-pool-json": $(mix_pool_json "$network" | jq -c '. | tostring')
|
||||
}
|
||||
EOF
|
||||
}
|
||||
@ -98,8 +104,6 @@ EOF
|
||||
EOF
|
||||
}
|
||||
|
||||
require jq
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
Usage: $0 <command> [network]
|
||||
@ -110,7 +114,7 @@ Commands:
|
||||
raw_data <network> Fetch raw storage-network data from fleets.logos.co
|
||||
mix_pool_json <network> Generate mix pool JSON configuration
|
||||
bootstrap_sprs <network> List bootstrap SPRs
|
||||
mix_proxy_sprs <network> List mix proxy SPRs (tcpSpr)
|
||||
mix_proxy_sprs <network> List mix proxy SPRs
|
||||
full_config <network> Generate full node configuration JSON
|
||||
presets Generate network presets JSON for all networks
|
||||
|
||||
@ -124,7 +128,7 @@ Examples:
|
||||
EOF
|
||||
}
|
||||
|
||||
if [[ $# -eq 0 || "$1" == "-h" || "$1" == "--help" || "$1" == "help" ]]; then
|
||||
if [[ $# -eq 0 ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user