Created
March 6, 2019 21:08
-
-
Save Stebalien/397ea4b31c2ea43cb24ff61df33f03c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REPO="$(mktemp -d)" | |
IPFS_PATH="$REPO" | |
trap "$(printf 'rm -rf "%s"' "$REPO")" INT EXIT | |
ipfs init >/dev/null | |
ipfs daemon --routing=dhtclient >&2 & | |
while ! ( [[ -e "$IPFS_PATH/api" ]] && ipfs id >/dev/null >&1 ); do sleep 1; done | |
echo "Bootstrapping..." >&2 | |
ipfs --timeout=10s dht findprovs "$(ipfs id --format='<id>')" >/dev/null 2>&1 | |
FILE="$(echo "Gateway Latency Test: $(date)" | ipfs add -q)" | |
echo "Added file: $FILE" >&2 | |
echo "Providing..." >&2 | |
ipfs --timeout=20s dht provide "$FILE" >/dev/null 2>&1 | |
echo "Retrieving..." >&2 | |
# Test it. | |
RESP=$(curl --write-out '{"code": %{http_code}, "time": %{time_total}}' "https://ipfs.io/ipfs/${FILE}") | |
ipfs shutdown >/dev/null >&2 | |
wait | |
echo "$RESP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment