Add service to fix invalid blocks

This commit is contained in:
Taylor Helsper 2019-09-23 20:50:19 -05:00
parent 38cff419c5
commit 9b476d8f5f
4 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# myNode invalid block service
# /etc/systemd/system/invalid_block_check.service
[Unit]
Description=myNode Bitcoin Invalid Block Check
After=network.target mynode.service
[Service]
Type=simple
KillMode=process
ExecStart=/usr/bin/mynode_invalid_block_check.sh
User=root
Group=root
TimeoutSec=300
Restart=always
RestartSec=30
Nice=5
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=bitcoind
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,21 @@
#!/bin/bash
set -e
sleep 5m
while [ 1 ]; do
if [ -f /mnt/hdd/mynode/bitcoin/debug.log ]; then
log=$(tail -n 10 /mnt/hdd/mynode/bitcoin/debug.log | grep "ERROR: AcceptBlockHeader")
if [ $? == 0 ]; then
block=$(tail -n 10 /mnt/hdd/mynode/bitcoin/debug.log | grep "ERROR: AcceptBlockHeader" | tail -n 1 | egrep -o "block [0-9a-f]+" | awk '{print $2}')
echo "INVALID BLOCK FOUND: $block"
echo "Fixing..."
bitcoin-cli -rpccookiefile=/mnt/hdd/mynode/bitcoin/.cookie invalidateblock $block
bitcoin-cli -rpccookiefile=/mnt/hdd/mynode/bitcoin/.cookie reconsiderblock $block
echo "Done fixing block $block"
sleep 10m
fi
fi
sleep 5m
done

View File

@ -134,6 +134,7 @@ fi
# Enable any new/required services
systemctl enable firewall
systemctl enable invalid_block_check
# Disable any old services
sudo systemctl disable hitch

View File

@ -338,6 +338,7 @@ systemctl enable tls_proxy
systemctl enable rtl
systemctl enable lnd_admin
systemctl enable tor
systemctl enable invalid_block_check
# Delete junk