Add uploader capability

This commit is contained in:
Taylor Helsper 2019-07-24 21:51:12 -05:00
parent e22f2bb392
commit 5de2837ea7
9 changed files with 60 additions and 11 deletions

View File

@ -20,7 +20,7 @@ zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# myNode Optimizations
dbcache=500
dbcache=600
maxorphantx=10
maxmempool=200
maxconnections=40

View File

@ -6,6 +6,7 @@ Description=Bitcoin daemon
After=network.target mynode.service
[Service]
ExecStartPre=/usr/bin/wait_on_uploader.sh
ExecStartPre=/bin/sh -c 'cat /mnt/hdd/mynode/quicksync/.quicksync_complete'
EnvironmentFile=/mnt/hdd/mynode/bitcoin/env
ExecStart=/usr/local/bin/bitcoind -daemon $BTCARGS -deprecatedrpc=accounts -par=-1 -conf=/home/bitcoin/.bitcoin/bitcoin.conf -printtoconsole -pid=/home/bitcoin/.bitcoin/bitcoind.pid

View File

@ -8,6 +8,13 @@ source /usr/share/mynode/mynode_config.sh
# Let transmission startup
sleep 60s
# If marked as uploader, dont slow down
while [ -f $UPLOADER_FILE ]; do
echo "Marked as uploader, unlimited upload"
transmission-remote -U
sleep 1h
done
# Upload slowly while downloading
transmission-remote -u 0
@ -25,7 +32,10 @@ done
echo "QuickSync Complete! Enabling Uploading."
while true; do
if [ ! -f "/mnt/hdd/mynode/quicksync/.quicksync_complete" ]; then
if [ -f $UPLOADER_FILE ]; then
echo "Marked as uploader, unlimited upload"
transmission-remote -U
elif [ ! -f "/mnt/hdd/mynode/quicksync/.quicksync_complete" ]; then
echo "QuickSync not complete, stopping upload"
transmission-remote -u 0
elif [ ! -f "/mnt/hdd/mynode/.mynode_bitcoind_synced" ]; then

View File

@ -6,16 +6,23 @@ echo "Waiting until QuickSync is complete..."
while [ ! -f "$QUICKSYNC_COMPLETE_FILE" ]; do
sleep 1m
done
echo "Quicksync Complete! Waiting until Bitcoin Sync is complete..."
while [ ! -f "$BITCOIN_SYNCED_FILE" ]; do
sleep 1m
done
echo "Bitcoin Sync Complete! Checking if there is a new torrent available..."
sleep 1d
if [ ! -f $UPLOADER_FILE ]; then
echo "Quicksync Complete! Waiting until Bitcoin Sync is complete..."
while [ ! -f "$BITCOIN_SYNCED_FILE" ]; do
sleep 1m
done
echo "Bitcoin Sync Complete! Checking if there is a new torrent available..."
sleep 1d
fi
while true; do
# Wait a while... we don't want everyone starting on a new torrent at once
sleep 7d
if [ -f $UPLOADER_FILE ]; then
echo "Marked as uploader, checking for new torrent in 1 day..."
sleep 1d
else
sleep 10d
fi
# Download current torrent
rm -rf /tmp/blockchain_temp.torrent

View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
set -x
source /usr/share/mynode/mynode_config.sh
# Don't start bitcoind if we are marked as an uploader
echo "Checking if uploader..."
while [ -f $UPLOADER_FILE ]; do
echo "We are an uploader, sleeping for 15 minutes..."
/bin/sleep 15m
done
exit 0

View File

@ -20,7 +20,7 @@ zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
# myNode Optimizations
dbcache=500
dbcache=600
maxorphantx=10
maxmempool=200
maxconnections=40

View File

@ -15,7 +15,8 @@ MYNODE_DIR=/mnt/hdd/mynode
QUICKSYNC_DIR=/mnt/hdd/mynode/quicksync
QUICKSYNC_CONFIG_DIR=/mnt/hdd/mynode/.config/transmission
QUICKSYNC_TORRENT_URL="https://mynodebtc.com/device/blockchain.tar.gz.torrent"
QUICKSYNC_BANDWIDTH_FILE="/mnt/hdd/mynode/settings/.bandwidth"
QUICKSYNC_BANDWIDTH_FILE="/mnt/hdd/mynode/settings/bandwidth"
UPLOADER_FILE="/mnt/hdd/mynode/settings/uploader"
LND_BACKUP_FOLDER="/home/bitcoin/lnd_backup/"
LND_TLS_CERT_FILE="/mnt/hdd/mynode/lnd/tls.cert"
LND_WALLET_FILE="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/wallet.db"

View File

@ -44,6 +44,10 @@ def get_device_type():
return CONFIG["device_type"]
def is_uploader():
return os.path.isfile("/mnt/hdd/mynode/settings/uploader")
def set_skipped_product_key():
os.system("touch /home/bitcoin/.mynode/.product_key_skipped")
os.system("touch /mnt/hdd/mynode/settings/.product_key_skipped")

View File

@ -88,6 +88,17 @@ def index():
pk_skipped = skipped_product_key()
pk_error = not is_valid_product_key()
# Show uploader page if we are marked as an uploader
if is_uploader():
status = subprocess.check_output(["mynode-get-quicksync-status"])
status = Markup("<div style='text-align: left; font-size: 12px; width: 800px;'><pre>"+status+"</pre></div>")
templateData = {
"title": "myNode Uploader",
"header_text": "Uploader Device",
"subheader_text": status
}
return render_template('state.html', **templateData)
# Show product key page if key not set
if not has_product_key() and not skipped_product_key():
return redirect("/product-key")