Add uploader capability
This commit is contained in:
parent
e22f2bb392
commit
5de2837ea7
|
@ -20,7 +20,7 @@ zmqpubrawblock=tcp://127.0.0.1:28332
|
||||||
zmqpubrawtx=tcp://127.0.0.1:28333
|
zmqpubrawtx=tcp://127.0.0.1:28333
|
||||||
|
|
||||||
# myNode Optimizations
|
# myNode Optimizations
|
||||||
dbcache=500
|
dbcache=600
|
||||||
maxorphantx=10
|
maxorphantx=10
|
||||||
maxmempool=200
|
maxmempool=200
|
||||||
maxconnections=40
|
maxconnections=40
|
||||||
|
|
|
@ -6,6 +6,7 @@ Description=Bitcoin daemon
|
||||||
After=network.target mynode.service
|
After=network.target mynode.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
|
ExecStartPre=/usr/bin/wait_on_uploader.sh
|
||||||
ExecStartPre=/bin/sh -c 'cat /mnt/hdd/mynode/quicksync/.quicksync_complete'
|
ExecStartPre=/bin/sh -c 'cat /mnt/hdd/mynode/quicksync/.quicksync_complete'
|
||||||
EnvironmentFile=/mnt/hdd/mynode/bitcoin/env
|
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
|
ExecStart=/usr/local/bin/bitcoind -daemon $BTCARGS -deprecatedrpc=accounts -par=-1 -conf=/home/bitcoin/.bitcoin/bitcoin.conf -printtoconsole -pid=/home/bitcoin/.bitcoin/bitcoind.pid
|
||||||
|
|
|
@ -8,6 +8,13 @@ source /usr/share/mynode/mynode_config.sh
|
||||||
# Let transmission startup
|
# Let transmission startup
|
||||||
sleep 60s
|
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
|
# Upload slowly while downloading
|
||||||
transmission-remote -u 0
|
transmission-remote -u 0
|
||||||
|
|
||||||
|
@ -25,7 +32,10 @@ done
|
||||||
echo "QuickSync Complete! Enabling Uploading."
|
echo "QuickSync Complete! Enabling Uploading."
|
||||||
|
|
||||||
while true; do
|
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"
|
echo "QuickSync not complete, stopping upload"
|
||||||
transmission-remote -u 0
|
transmission-remote -u 0
|
||||||
elif [ ! -f "/mnt/hdd/mynode/.mynode_bitcoind_synced" ]; then
|
elif [ ! -f "/mnt/hdd/mynode/.mynode_bitcoind_synced" ]; then
|
||||||
|
|
|
@ -6,16 +6,23 @@ echo "Waiting until QuickSync is complete..."
|
||||||
while [ ! -f "$QUICKSYNC_COMPLETE_FILE" ]; do
|
while [ ! -f "$QUICKSYNC_COMPLETE_FILE" ]; do
|
||||||
sleep 1m
|
sleep 1m
|
||||||
done
|
done
|
||||||
echo "Quicksync Complete! Waiting until Bitcoin Sync is complete..."
|
if [ ! -f $UPLOADER_FILE ]; then
|
||||||
while [ ! -f "$BITCOIN_SYNCED_FILE" ]; do
|
echo "Quicksync Complete! Waiting until Bitcoin Sync is complete..."
|
||||||
sleep 1m
|
while [ ! -f "$BITCOIN_SYNCED_FILE" ]; do
|
||||||
done
|
sleep 1m
|
||||||
echo "Bitcoin Sync Complete! Checking if there is a new torrent available..."
|
done
|
||||||
sleep 1d
|
echo "Bitcoin Sync Complete! Checking if there is a new torrent available..."
|
||||||
|
sleep 1d
|
||||||
|
fi
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
# Wait a while... we don't want everyone starting on a new torrent at once
|
# 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
|
# Download current torrent
|
||||||
rm -rf /tmp/blockchain_temp.torrent
|
rm -rf /tmp/blockchain_temp.torrent
|
||||||
|
|
15
rootfs/standard/usr/bin/wait_on_uploader.sh
Executable file
15
rootfs/standard/usr/bin/wait_on_uploader.sh
Executable 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
|
|
@ -20,7 +20,7 @@ zmqpubrawblock=tcp://127.0.0.1:28332
|
||||||
zmqpubrawtx=tcp://127.0.0.1:28333
|
zmqpubrawtx=tcp://127.0.0.1:28333
|
||||||
|
|
||||||
# myNode Optimizations
|
# myNode Optimizations
|
||||||
dbcache=500
|
dbcache=600
|
||||||
maxorphantx=10
|
maxorphantx=10
|
||||||
maxmempool=200
|
maxmempool=200
|
||||||
maxconnections=40
|
maxconnections=40
|
||||||
|
|
|
@ -15,7 +15,8 @@ MYNODE_DIR=/mnt/hdd/mynode
|
||||||
QUICKSYNC_DIR=/mnt/hdd/mynode/quicksync
|
QUICKSYNC_DIR=/mnt/hdd/mynode/quicksync
|
||||||
QUICKSYNC_CONFIG_DIR=/mnt/hdd/mynode/.config/transmission
|
QUICKSYNC_CONFIG_DIR=/mnt/hdd/mynode/.config/transmission
|
||||||
QUICKSYNC_TORRENT_URL="https://mynodebtc.com/device/blockchain.tar.gz.torrent"
|
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_BACKUP_FOLDER="/home/bitcoin/lnd_backup/"
|
||||||
LND_TLS_CERT_FILE="/mnt/hdd/mynode/lnd/tls.cert"
|
LND_TLS_CERT_FILE="/mnt/hdd/mynode/lnd/tls.cert"
|
||||||
LND_WALLET_FILE="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/wallet.db"
|
LND_WALLET_FILE="/mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/wallet.db"
|
||||||
|
|
|
@ -44,6 +44,10 @@ def get_device_type():
|
||||||
return CONFIG["device_type"]
|
return CONFIG["device_type"]
|
||||||
|
|
||||||
|
|
||||||
|
def is_uploader():
|
||||||
|
return os.path.isfile("/mnt/hdd/mynode/settings/uploader")
|
||||||
|
|
||||||
|
|
||||||
def set_skipped_product_key():
|
def set_skipped_product_key():
|
||||||
os.system("touch /home/bitcoin/.mynode/.product_key_skipped")
|
os.system("touch /home/bitcoin/.mynode/.product_key_skipped")
|
||||||
os.system("touch /mnt/hdd/mynode/settings/.product_key_skipped")
|
os.system("touch /mnt/hdd/mynode/settings/.product_key_skipped")
|
||||||
|
|
|
@ -88,6 +88,17 @@ def index():
|
||||||
pk_skipped = skipped_product_key()
|
pk_skipped = skipped_product_key()
|
||||||
pk_error = not is_valid_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
|
# Show product key page if key not set
|
||||||
if not has_product_key() and not skipped_product_key():
|
if not has_product_key() and not skipped_product_key():
|
||||||
return redirect("/product-key")
|
return redirect("/product-key")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user