mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-11-18 09:57:17 +01:00
adding bitcoin presync
This commit is contained in:
@@ -63,6 +63,13 @@ while :
|
||||
if [ ${bootstrapInfoExists} -eq 1 ]; then
|
||||
# load the data from the info file - overwrite state & message
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" = "presync" ]; then
|
||||
# get blockchain sync progress
|
||||
blockchaininfo="$(bitcoin-cli -datadir=/mnt/hdd/bitcoin getblockchaininfo 2>/dev/null)"
|
||||
if [ ${#blockchaininfo} -gt 0 ]; then
|
||||
message="$(echo "${blockchaininfo}" | jq -r '.verificationprogress')"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# setup process has not started yet
|
||||
|
||||
@@ -12,10 +12,17 @@ if [ ${bootstrapInfoExists} -eq 1 ]; then
|
||||
|
||||
# if pre-sync is running - stop it
|
||||
if [ "${state}" = "presync" ]; then
|
||||
echo "TODO: Stop pre-sync ... press key to continue"
|
||||
read key
|
||||
|
||||
# stopping the pre-sync
|
||||
echo "Stopping pre-sync ..."
|
||||
sudo systemctl stop bitcoind.service
|
||||
sudo systemctl disable bitcoind.service
|
||||
sudo rm /mnt/hdd/bitcoin/bitcoin.conf
|
||||
sudo rm /etc/systemd/system/bitcoind.service
|
||||
|
||||
# unmount the temporary mount
|
||||
sudo umount -l /mnt/hdd
|
||||
|
||||
# update info file
|
||||
state=waitsetup
|
||||
echo "state=waitsetup" > $infoFile
|
||||
|
||||
@@ -174,13 +174,25 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
|
||||
echo "Check if HDD contains pre-loaded blockchain data .." >> $logFile
|
||||
blockchainDataExists=$(ls /mnt/hdd/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
|
||||
if [ ${blockchainDataExists} -eq 1 ]; then
|
||||
// TODO: Pre-Sync Blockchain
|
||||
echo "Found pre-loaded blockchain - TODO start pre-sync!" >> $logFile
|
||||
|
||||
# activating presync
|
||||
# so that on a hackathon you can just connect a RaspiBlitz
|
||||
# to the network and have it up-to-date for setting up
|
||||
echo "Found pre-loaded blockchain - starting pre-sync" >> $logFile
|
||||
sudo cp /home/admin/assets/bitcoin.conf /mnt/hdd/bitcoin/bitcoin.conf
|
||||
sudo cp /home/admin/assets/bitcoind.service /etc/systemd/system/bitcoind.service
|
||||
sudo chmod +x /etc/systemd/system/bitcoind.service
|
||||
sudo systemctl enable bitcoind.service
|
||||
sudo systemctl start bitcoind.service
|
||||
|
||||
# update info file
|
||||
echo "state=presync" > $infoFile
|
||||
echo "message='TODO: start pre-sync'" >> $infoFile
|
||||
echo "message='starting pre-sync'" >> $infoFile
|
||||
echo "device=${hddDeviceName}" >> $infoFile
|
||||
|
||||
# after admin login, presync will be stoped and HDD unmounted
|
||||
exit 1
|
||||
|
||||
else
|
||||
ls /mnt/hdd/bitcoin/blocks/blk00000.dat >> $logFile
|
||||
echo "OK - No blockchain data found" >> $logFile
|
||||
|
||||
Reference in New Issue
Block a user