Created
January 18, 2021 01:16
-
-
Save geolffreym/e502cbf44ed4b4c375934452e5f93c1f to your computer and use it in GitHub Desktop.
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
function db.oplog.values.hashes () { | |
local host | |
local dbAddr | |
host=${2:-${ORBIT_DB_HOST}} | |
dbAddr=$(rawurlencode "${1}") | |
_curl "${host}/db/${dbAddr}/oplog/values" | jsawk "'return this.hash'" -a "'return this.join(\" \")'" | |
} | |
function db.heads.pin () { | |
declare -a hashes=() | |
for hash in $(db.oplog.values.hashes "${@}") | |
do | |
hashes+=("$hash") | |
if [[ ${#hashes[@]} -ge ${ORBIT_DB_PIN_BATCH_COUNT} ]]; then | |
echo "Pinning ${hashes[*]}" | |
ipfs pin add --progress --timeout "${ORBIT_DB_PIN_TIMEOUT}" "${hashes[@]}" | |
hashes=() | |
sleep 30 | |
fi | |
done | |
# Pin leftover hashes batch < 100 | |
echo "Pinning ${hashes[*]}" | |
ipfs pin add --progress --timeout "${ORBIT_DB_PIN_TIMEOUT}" "${hashes[@]}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment