Last active
March 30, 2018 01:36
-
-
Save petersjt014/f645f8ca54e35707aa90c7047e17debf to your computer and use it in GitHub Desktop.
see instead the working one here: https://gist.github.com/petersjt014/57debf01da5064f6120616ac983139d0
This file contains 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/sh | |
# this script is mostly just a pile of debug echos and such right now, as recursion within bash still mystifies me | |
# For testing, the following dag is very lightweight and shouldn't crash anything: | |
# QmRCJXG7HSmprrYwDrK1GctXHgbV7EYpVcJPQPwevoQuqF | |
# a diagram of the dag can be found here (or on your local gateway, of course): | |
# http://ipfs.io/ipfs/Qma8EX27uA27ASxseUuvnLPp8nUHtSDqJJZwCnU4D3uZHn | |
echo; echo "starting..." | |
recur(){ | |
echo "recursing" | |
echo "var1: $1"; echo; | |
local refs=$(ipfs refs $1); echo "refs: $refs" | |
local nrefs=$(echo $refs | wc -w); echo "nrefs: $nrefs" | |
if [ $nrefs -eq 0 ] | |
then | |
echo; echo "leaf node" | |
echo -n $(ipfs dht findprovs -n 10 $1 | wc -l) | |
else | |
echo; echo "non-leaf" | |
echo "REFS:"; echo $refs; echo "END REFS" | |
echo "WC:" | |
wc $refs | |
echo "END WC" | |
# the agonizing part: | |
echo $refs | xargs -P 8 -d '\n' -n 1 -L 1 -t -I {} bash -c "wc {}" # recur() will go here, wc currently is for tinkering/testing purposes | |
fi | |
} | |
export -f recur | |
recur $1 | |
# this is a version that works(?) for top-level nodes only | |
#refs=$(ipfs refs $1) | |
#num=$(echo $refs | wc -w) | |
#echo "top-level nodes: $num" | |
#peers=$(echo $refs | xargs -n1 ipfs dht findprovs -n 10) | |
#total=$(echo $peers | wc -w) | |
#echo "total peers for refs: $total" | |
#avail=$(($total/$num/10)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment