Last active
July 24, 2021 14:36
-
-
Save gotdibbs/e7dcf5fcb2b7095c253366c9357dc0a8 to your computer and use it in GitHub Desktop.
Hacky utility scripts for Chia on Windows
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
# Safely move chia plots from one drive to another on Windows | |
$SOURCE_DIR = 'A:\Chia' | |
$DEST_DIR = 'B:\Chia' | |
$move_count = 0; | |
while (($plot_to_move = (Get-ChildItem $SOURCE_DIR -Filter '*.plot' | Select-Object -First 1)) -ne $null) { | |
$old_name = $plot_to_move.Name | |
# Temporarily rename the plot before moving https://github.com/Chia-Network/chia-blockchain/wiki/Moving-plots | |
$new_name = $old_name.Replace('.plot', '.plot-mv') | |
$new_path = $plot_to_move.FullName.Replace($old_name, $new_name) | |
Rename-Item $plot_to_move.FullName -NewName $new_name | |
$temp_destination = [IO.Path]::Combine($DEST_DIR, $new_name) | |
$final_destination = [IO.Path]::Combine($DEST_DIR, $old_name) | |
echo "- Renamed to: $renamed_path" | |
echo "- Final destination: $final_destination" | |
robocopy $SOURCE_DIR $DEST_DIR $new_name /MOVE | |
Rename-Item $temp_destination -NewName $old_name | |
$move_count++ | |
echo "Moved $move_count plots so far..." | |
} |
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
# Hacky script to check some basic stats | |
$countBad = 0 | |
$countGood = 0 | |
$total = 0 | |
Select-String -Path "~\.chia\mainnet\log\debug.log" -Pattern "(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}).+(\d+) plots were eligible.+Found (\d+) proofs.+Time: (\d+\.\d+)" | | |
ForEach-Object { | |
$time = $_.Matches[0].Groups[1].Value | |
$eligible = $_.Matches[0].Groups[2].Value | |
$found = $_.Matches[0].Groups[3].Value | |
$duration = $_.Matches[0].Groups[4].Value -as [double] | |
$total += $duration | |
if ($duration -gt 5) { | |
echo "$time : $duration (Eligible: $eligible | Found: $found)" | |
$countBad++ | |
} | |
else { | |
$countGood++ | |
} | |
} | |
$avg = $total / ($countBad + $countGood) | |
echo "Good: $countGood | Bad: $countBad | Average: $avg" | |
$count = 0 | |
$total = 0 | |
Select-String -Path "~\.chia\mainnet\plotter\plotter_log_*" -Pattern "^Total time = (\d+\.\d+) seconds" | | |
ForEach-Object { | |
$time = $_.Matches[0].Groups[1].Value -as [double] | |
$count++; | |
$total += $time; | |
} | |
$avg = ($total / $count) / 3600; | |
echo "Average plot time: $avg hours based on $count plots" | |
$count = 0 | |
$total = 0 | |
Get-ChildItem -Force -Recurse -File -Path "~\.chia\mainnet\plotter" -ErrorAction SilentlyContinue | | |
Where-Object { $_.CreationTime.Date -lt (Get-Date).Date } | | |
Sort CreationTime -Descending | | |
Select-String -Pattern "^Total time = (\d+\.\d+) seconds" | | |
Select-Object -First 3 | | |
ForEach-Object { | |
$time = $_.Matches[0].Groups[1].Value -as [double] | |
$count++; | |
$total += $time; | |
} | |
$avg = ($total / $count) / 3600; | |
echo "Average plot time (last 3): $avg hours based on $count plots" |
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
# Search debug logs for warnings and log them out | |
Select-String -Path "~\.chia\mainnet\log\debug.log" -Pattern ".+WARNING(.+)" | | |
ForEach-Object { | |
$msg = $_.Matches[0].Groups[1].Value | |
if ($msg.Contains("H:\Chia\Final") -eq $false) { | |
echo $msg | |
} | |
} |
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
# Check for wins | |
Select-String -Path "~\.chia\mainnet\log\debug.log" -Pattern "(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}).+Found (\d+) proof.+Time: (\d+\.\d+)" | | |
ForEach-Object { | |
$time = $_.Matches[0].Groups[1].Value | |
$found = $_.Matches[0].Groups[2].Value -as [double] | |
$duration = $_.Matches[0].Groups[3].Value -as [double] | |
if ($found -gt 0) { | |
echo "WINNER! $time : $duration (Found: $found)" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment