2 # Copyright (c) 2013 The Bitcoin Core developers
3 # Distributed under the MIT software license, see the accompanying
4 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
9 echo "Usage: $0 <datadir>" >&2
10 echo "Removes obsolete Bitcoin database files" >&2
15 if [ -f wallet.dat
-a -f addr.dat
-a -f blkindex.dat
-a -f blk0001.dat
]; then LEVEL
=1; fi
16 if [ -f wallet.dat
-a -f peers.dat
-a -f blkindex.dat
-a -f blk0001.dat
]; then LEVEL
=2; fi
17 if [ -f wallet.dat
-a -f peers.dat
-a -f coins
/CURRENT
-a -f blktree
/CURRENT
-a -f blocks
/blk00000.dat
]; then LEVEL
=3; fi
18 if [ -f wallet.dat
-a -f peers.dat
-a -f chainstate
/CURRENT
-a -f blocks
/index
/CURRENT
-a -f blocks
/blk00000.dat
]; then LEVEL
=4; fi
22 echo "Error: no Bitcoin datadir detected."
26 echo "Detected old Bitcoin datadir (before 0.7)."
31 echo "Detected Bitcoin 0.7 datadir."
34 echo "Detected Bitcoin pre-0.8 datadir."
37 echo "Detected Bitcoin 0.8 datadir."
44 if [ $LEVEL -ge 3 ]; then FILES
=$
(echo $FILES blk????.dat blkindex.dat
); fi
45 if [ $LEVEL -ge 2 ]; then FILES
=$
(echo $FILES addr.dat
); fi
46 if [ $LEVEL -ge 4 ]; then DIRS
=$
(echo $DIRS coins blktree
); fi
48 for FILE
in $FILES; do
50 echo "Deleting: $FILE"
57 echo "Deleting: $DIR/"