Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPFS Improvements #284

Merged
merged 24 commits into from
Mar 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/ipfs/install
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ true

set -e

GO_IPFS_VERSION=v0.4.18
GO_IPFS_VERSION=v0.4.19

# Hyperborea connected peer used to bootstrap hyperborea only ipfs nodes
# DarkDrgn2k's peer
Expand Down Expand Up @@ -38,6 +38,16 @@ ipfs config Pubsub.Router gossipsub
# Enable Filestore for --nocopy capability
ipfs config --bool Experimental.FilestoreEnabled true

# Setup connection management - Reduce connections to stress the Pi less
# XXX: These values need to be tweaked and tested
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makeworld-the-better-one How will you measure whether these values provide an improvement or otherwise?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CPU and RAM usage can be looked, as well as file retrieval times and IPNS resolve. It will require a formal test, but I know that these values will be better than the ones we have now, especially since this is on such limited hardware.

ipfs config Swarm.ConnMgr.Type basic
ipfs config Swarm.ConnMgr.LowWater 100
ipfs config Swarm.ConnMgr.HighWater 200
ipfs config Swarm.ConnMgr.GracePeriod 60s

# Enable QUIC for better connections when possible
ipfs config --bool Experimental.QUIC true

# Configure HTTP to IPFS gateway
sudo cp "$BASE_DIR/ipfs-http-gateway.conf" /etc/nginx/site-path-enabled/ipfs-http-gateway.conf
sudo systemctl restart nginx.service
Expand Down
29 changes: 20 additions & 9 deletions scripts/ipfs/ipfs-swarm.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#!/bin/bash
# shellcheck disable=SC2162
true

# Wait for ipfs to initalize
attempts=15
# This script connects to local mesh peers,
# and it sets up connection filters based on what networks this node can access.
# It runs continually, to change IPFS settings as the environment around the node changes.


# Wait for IPFS to initalize
attempts=10
until [[ $(curl http://localhost:5001/api/v0/id -s 2>/dev/null) || ${attempts} -eq 0 ]]; do
sleep 1
sleep 3
attempts=$((attempts-1))
done

if [[ ${attempts} -eq 0 ]]; then
echo "Error: Failed to connect to local IPFS daemon. Is it running?"
exit 1
fi

Expand All @@ -21,9 +25,16 @@ function addPeer {
id=$(echo "${res}" | jq -r -M '.services.ipfs.ID')
# Value is found
if [[ ! ${id} == "null" ]] && [[ ! "${id}" == "" ]]; then
# Connect to neighbouring ipfs
ipfs swarm connect "/ip6/${addr}/tcp/4001/ipfs/${id}"
echo "Connecting to ${addr}"
# Connect to neighbouring IPFS nodes
# Check for QUIC connections first
if [ "$(echo "${res}" | jq -r -M '.services.IPFS.quic_enabled')" == 'true' ]; then
# ID is not needed for QUIC connections
echo "Connecting to ${addr} with QUIC"
ipfs swarm connect "/ip6/${addr}/udp/4001/quic"
else
echo "Connecting to ${addr} over TCP"
ipfs swarm connect "/ip6/${addr}/tcp/4001/ipfs/${id}"
fi
fi
fi
}
Expand All @@ -47,4 +58,4 @@ if [ "$(which yggdrasil)" ]; then
fi

# Update peers data since ipfs just started
sudo /usr/local/bin/nodeinfo-update.sh
sudo /usr/local/bin/nodeinfo-update.sh
6 changes: 6 additions & 0 deletions scripts/ipfs/nodeinfo-ipfs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ fi
echo '"ipfs":{'
echo '"version":'${version}','

if [ quic_enabled = "$(ipfs config Experimental.QUIC)" ]; then
echo '"quic_enabled":"'${quic_enabled}'",'
else
echo '"quic_enabled":"false",'
fi

echo '"ID":'${id}

echo "},"
2 changes: 1 addition & 1 deletion scripts/ipfs/uninstall
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

# Remove script and service for ipfs bootstrap
sudo rm -r /usr/local/bin/ipfs-swarm-cjdns.sh || true
sudo rm -r /usr/local/bin/ipfs-swarm.sh || true

# Uninstall dependencies
sudo apt-get remove -y jq
Expand Down