JWWeatherman / yeticold

https://yeticold.com
Other
66 stars 23 forks source link

Setting prune and dbcache #145

Open BenWestgate opened 3 years ago

BenWestgate commented 3 years ago

Yeti uses fixed values for dbcache and prune, which occasionally causes problems, but we can make optimum use of the user's machine's resources if we call a command to check for available memory and free disc space on first start up.

## custom prune code
installed=$(mkdir .bitcoin 2>&1 | grep "File exists" -c)  # makes ~/.bitcoin folder. If it didn't exist, installed=0
touch .bitcoin/bitcoin.conf
if [ ${installed} -eq 0 ]; then
    free_space=$(awk 'FNR ==2 {print $4+0}' <(df -BM /))  # free space in MB
    echo "prune=$(( free_space - 10000 ))" >> .bitcoin/bitcoin.conf     # subtracts 10 GB from freespace to allow for chainstate, allocates the rest to block storage.
fi
## custom dbcache code
available=$(awk '/^Mem/ {print $7}' <(free -m))     # total available memory
gnome-terminal -- ./bitcoin-qt -server -dbcache=$((available - 300)) #-proxy=127.0.0.1:9050         # Launch Bitcoin Core in new window, necessary to use Bitcoin-cli command line interface in this script, -proxy tells it to use Tor. Sets dbcache to use all available memory less the <300 MB core uses when dbcache=0
willweatherman commented 3 years ago

This defiantly sounds like it's worth implementing Ill play with it shortly.