-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
206 additions
and
254 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,52 @@ | ||
#!/bin/bash | ||
|
||
TOTAL_ACCOUNTS=50000 | ||
PARALLEL_JOBS=8 | ||
ACCOUNTS_PER_JOB=$((TOTAL_ACCOUNTS / PARALLEL_JOBS)) | ||
|
||
create_accounts() { | ||
local start=$1 | ||
local end=$2 | ||
local job_id=$3 | ||
|
||
for i in $(seq $start $end); do | ||
if ! poktrolld keys add "app-$i" > /dev/null 2>&1; then | ||
echo "Job $job_id: Error creating account app-$i" | ||
continue | ||
fi | ||
TOTAL_ADDRESSES=${1:-50000} | ||
PARALLEL_JOBS=${2:-8} | ||
SEGMENTS_DIR="./segments" | ||
OUTPUT_FILE="app_addresses.txt" | ||
|
||
create_segment() { | ||
local job_id=$1 | ||
local start_idx=$2 | ||
local num_addresses=$3 | ||
local segment_file="$SEGMENTS_DIR/segment_$job_id.txt" | ||
|
||
> "$segment_file" | ||
for i in $(seq 0 $(($num_addresses-1))); do | ||
addr_idx=$(($start_idx + $i + 1)) | ||
output=$(poktrolld keys add "app-$addr_idx" --output json | jq -r .address 2>&1) | ||
echo "$output" >> "$segment_file" | ||
done | ||
} | ||
|
||
if [ $((i % 100)) -eq 0 ]; then | ||
echo "Job $job_id: Progress $i/$end accounts created" | ||
merge_segments() { | ||
> "$OUTPUT_FILE" | ||
for i in $(seq 0 $((PARALLEL_JOBS-1))); do | ||
if [ -f "$SEGMENTS_DIR/segment_$i.txt" ]; then | ||
cat "$SEGMENTS_DIR/segment_$i.txt" >> "$OUTPUT_FILE" | ||
else | ||
echo "Missing segment file: segment_$i.txt" >&2 | ||
return 1 | ||
fi | ||
done | ||
} | ||
|
||
echo "Starting parallel account creation with $PARALLEL_JOBS jobs..." | ||
main() { | ||
rm -rf $SEGMENTS_DIR | ||
mkdir -p $SEGMENTS_DIR | ||
|
||
# Launch parallel jobs | ||
for job in $(seq 0 $((PARALLEL_JOBS-1))); do | ||
start=$((job * ACCOUNTS_PER_JOB + 1)) | ||
if [ $job -eq $((PARALLEL_JOBS-1)) ]; then | ||
end=$TOTAL_ACCOUNTS | ||
else | ||
end=$((start + ACCOUNTS_PER_JOB - 1)) | ||
fi | ||
ADDRS_PER_JOB=$(( (TOTAL_ADDRESSES + PARALLEL_JOBS - 1) / PARALLEL_JOBS )) | ||
echo "Creating $TOTAL_ADDRESSES addresses using $PARALLEL_JOBS parallel jobs" | ||
|
||
create_accounts $start $end $job & | ||
done | ||
for job_id in $(seq 0 $((PARALLEL_JOBS-1))); do | ||
start_idx=$((job_id * ADDRS_PER_JOB)) | ||
create_segment "$job_id" "$start_idx" "$ADDRS_PER_JOB" & | ||
done | ||
|
||
# Wait for all background jobs to complete | ||
wait | ||
wait | ||
merge_segments | ||
rm -rf $SEGMENTS_DIR | ||
echo "Complete - addresses written to $OUTPUT_FILE" | ||
} | ||
|
||
echo "All account creation jobs completed!" | ||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.