creates bitcoin bootstrap file
This commit is contained in:
parent
5533ee1239
commit
c28036bae1
22
mkbootstrapdat/Dockerfile
Normal file
22
mkbootstrapdat/Dockerfile
Normal file
@ -0,0 +1,22 @@
|
||||
FROM ubuntu:14.04
|
||||
|
||||
VOLUME /bitcoin
|
||||
|
||||
ADD ./sources.list /etc/apt/sources.list
|
||||
RUN export DEBIAN_FRONTEND=noninteractive && \
|
||||
apt-get update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install git build-essential jq curl python pv
|
||||
|
||||
RUN cd /usr/local/src && \
|
||||
git clone https://github.com/bitcoin/bitcoin.git && \
|
||||
cd bitcoin && \
|
||||
git checkout a9149688f87cb790a600400abd9af72c3ee0c312
|
||||
|
||||
VOLUME /input
|
||||
VOLUME /output
|
||||
|
||||
ADD ./mkbootstrap /usr/local/bin/mkbootstrap
|
||||
RUN chmod +x /usr/local/bin/mkbootstrap
|
||||
|
||||
ENTRYPOINT /usr/local/bin/mkbootstrap
|
7
mkbootstrapdat/Makefile
Normal file
7
mkbootstrapdat/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
default: build
|
||||
|
||||
build:
|
||||
docker-compose build
|
||||
|
||||
up:
|
||||
docker-compose up
|
16
mkbootstrapdat/docker-compose.yml
Normal file
16
mkbootstrapdat/docker-compose.yml
Normal file
@ -0,0 +1,16 @@
|
||||
version: '2.0'
|
||||
|
||||
services:
|
||||
mkbootstrap:
|
||||
hostname: mkbootstrap.local
|
||||
build: .
|
||||
image: tmp/mkbootstrap
|
||||
network_mode: bridge
|
||||
env_file: "${HOME}/Documents/workstation/envfile/mkbootstrap.env"
|
||||
volumes:
|
||||
- "/storage/nobackup/bitcoin:/input:ro"
|
||||
- "/storage/nobackup/bitcoin/bootstrap:/output"
|
||||
logging:
|
||||
driver: syslog
|
||||
options:
|
||||
syslog-address: "tcp://172.17.0.1:514"
|
57
mkbootstrapdat/mkbootstrap
Normal file
57
mkbootstrapdat/mkbootstrap
Normal file
@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
|
||||
exec 1> >(logger -s -t mkbootstrap) 2>&1
|
||||
|
||||
if [[ ! -d /input/blocks ]]; then
|
||||
echo "unable to find blocksource" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
JSON="$(curl --user $RPCUSER:$RPCPASSWORD \
|
||||
--max-time 20 \
|
||||
--data-binary \
|
||||
'{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' \
|
||||
-H 'content-type: text/plain;' \
|
||||
http://$RPCHOST:8332/)"
|
||||
|
||||
BLOCKS=$(jq -r .result.blocks <<< """$JSON""")
|
||||
HEADERS=$(jq -r .result.headers <<< """$JSON""")
|
||||
|
||||
if [[ ! $BLOCKS -gt 405749 ]]; then
|
||||
echo "bitcoind does not have full chain yet" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! $HEADERS -gt 405749 ]]; then
|
||||
echo "bitcoind does not have full chain yet" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $HEADERS -gt $BLOCKS ]]; then
|
||||
echo "bitcoind does not have full chain yet" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd /usr/local/src/bitcoin/contrib/linearize
|
||||
C="/etc/linearize.conf"
|
||||
|
||||
cat > $C <<EOF
|
||||
rpcuser=$RPCUSER
|
||||
rpcpassword=$RPCPASSWORD
|
||||
host=$RPCHOST
|
||||
min_height=0
|
||||
max_height=$BLOCKS
|
||||
input=/input/blocks
|
||||
hashlist=/tmp/hashlist.txt
|
||||
output_file=/tmp/bootstrap.dat
|
||||
EOF
|
||||
|
||||
python ./linearize-hashes.py $C | tee /tmp/hashlist.new &&
|
||||
mv /tmp/hashlist.new /tmp/hashlist.txt
|
||||
python ./linearize-data.py $C || exit 1
|
||||
YYYYMMDD="$(date -u +%Y%m%d)"
|
||||
|
||||
rsync -avP /tmp/bootstrap.dat /output/bootstrap.tmp && \
|
||||
mv /output/bootstrap.tmp /output/bootstrap.$YYYYMMDD.dat
|
8
mkbootstrapdat/sources.list
Normal file
8
mkbootstrapdat/sources.list
Normal file
@ -0,0 +1,8 @@
|
||||
#deb http://mirror.hetzner.de/ubuntu/packages trusty main restricted universe multiverse
|
||||
#deb http://mirror.hetzner.de/ubuntu/packages trusty-updates main restricted universe multiverse
|
||||
#deb http://mirror.hetzner.de/ubuntu/packages trusty-backports main restricted universe multiverse
|
||||
#deb http://mirror.hetzner.de/ubuntu/security trusty-security main restricted universe multiverse
|
||||
deb http://172.17.0.1/ubuntu trusty main restricted universe multiverse
|
||||
deb http://172.17.0.1/ubuntu trusty-updates main restricted universe multiverse
|
||||
deb http://172.17.0.1/ubuntu trusty-backports main restricted universe multiverse
|
||||
deb http://172.17.0.1/ubuntu trusty-security main restricted universe multiverse
|
Loading…
Reference in New Issue
Block a user