2019-09-24 01:50:19 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
sleep 5m
|
|
|
|
|
2019-10-09 23:53:23 +00:00
|
|
|
last_invalid_block=""
|
2019-09-24 01:50:19 +00:00
|
|
|
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}')
|
2019-10-09 23:53:23 +00:00
|
|
|
if [ "$block" = "$last_invalid_block" ]; then
|
|
|
|
echo "ALREADY FIXED INVALID BLOCK: $block"
|
|
|
|
else
|
|
|
|
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
|
|
|
|
last_invalid_block=$block
|
|
|
|
echo "Done fixing block $block"
|
|
|
|
sleep 5m
|
|
|
|
fi
|
2019-09-24 01:50:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
2019-10-09 23:53:23 +00:00
|
|
|
sleep 3m
|
2019-09-24 01:50:19 +00:00
|
|
|
done
|