Skip to content

Instantly share code, notes, and snippets.

@pyropy
Last active February 27, 2025 09:40
Show Gist options
  • Save pyropy/2d7c3ca02820a756bcd6155e7491831f to your computer and use it in GitHub Desktop.
Save pyropy/2d7c3ca02820a756bcd6155e7491831f to your computer and use it in GitHub Desktop.

Revisions

  1. pyropy renamed this gist Feb 27, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. pyropy revised this gist Feb 27, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ export const retrievalTasks = [
    EOF

    # Call the binary with the generated config file and write output to the log file
    ./zinnia run main.js > "$LOG_FILE" 2>&1
    XDG_CACHE_HOME=/downloads ./zinnia run main.js > "$LOG_FILE" 2>&1

    # Clean up config file after execution
    rm -f "$CONFIG_FILE"
  3. pyropy created this gist Feb 27, 2025.
    49 changes: 49 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    #!/bin/bash

    # Define the JSON file
    JSON_FILE="tasks.json"

    # Check if jq is installed
    if ! command -v jq &> /dev/null; then
    echo "jq is required but not installed. Please install jq first."
    exit 1
    fi

    # Counter for log filenames
    INDEX=0

    # Read JSON array and iterate over items
    jq -c '.[]' "$JSON_FILE" | while IFS= read -r task; do
    # Define config file and log file
    CONFIG_FILE="config.js"
    LOG_FILE="output_${INDEX}.log"

    # Create config.js with JSON content
    cat <<EOF > "$CONFIG_FILE"
    // Specifies which round to analyze (default: undefined, uses current round)
    export const roundId = undefined
    // Limits the number of tasks to process (default: undefined, processes all tasks)
    export const maxTasks = undefined
    // Focuses spot check on a specific storage provider (default: undefined, spot checks all miners)
    export const minerId = undefined
    // Sets a size limit for single spot check data retrieval (default: undefined, no size limit)
    export const maxByteLength = undefined
    // Array of tasks to execute retrievals (default: [] - tasks will be loaded from the network)
    export const retrievalTasks = [
    $task
    ]
    EOF

    # Call the binary with the generated config file and write output to the log file
    ./zinnia run main.js > "$LOG_FILE" 2>&1

    # Clean up config file after execution
    rm -f "$CONFIG_FILE"

    # Increment log index
    ((INDEX++))
    done