Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 134
Explicit IPFS peering between discprov and creator nodes#24
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
6c211fdaea860e2c66ce4bbfa1c06f86f91647f8bd484a96a42ca2c2a9d85670948333File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| import logging | ||
| from urllib.parse import urljoin | ||
| from datetime import datetime | ||
| from sqlalchemy.orm.session import make_transient | ||
| import requests | ||
| from src import contract_addresses | ||
| from src.utils import helpers | ||
| from src.models import User, BlacklistedIPLD | ||
| @@ -211,8 +213,34 @@ def get_metadata_overrides_from_ipfs(session, update_task, user_record): | ||
| if ipld_blacklist_entry: | ||
| return None | ||
| # Manually peer with user creator nodes | ||
| update_ipfs_peers_from_user_endpoint( | ||
hareeshnagaraj marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| update_task, | ||
| user_record.creator_node_endpoint) | ||
| user_metadata = update_task.ipfs_client.get_metadata( | ||
| user_record.metadata_multihash, | ||
| user_metadata_format) | ||
| return user_metadata | ||
| def get_ipfs_info_from_cnode_endpoint(url): | ||
| id_url = urljoin(url, 'ipfs_peer_info') | ||
| resp = requests.get(id_url, timeout=5) | ||
| json_resp = resp.json() | ||
| ipfs_multiaddr_entries = json_resp['addresses'] | ||
| for multiaddr in ipfs_multiaddr_entries: | ||
| if ('127.0.0.1' not in multiaddr) and ('ip6' not in multiaddr): | ||
| return multiaddr | ||
| raise Exception('Failed to find valid multiaddr') | ||
| def update_ipfs_peers_from_user_endpoint(update_task, cnode_url_list): | ||
| if cnode_url_list is None: | ||
| return | ||
| redis = update_task.redis | ||
| cnode_entries = cnode_url_list.split(',') | ||
| interval = int(update_task.shared_config["discprov"]["peer_refresh_interval"]) | ||
| for cnode_url in cnode_entries: | ||
| multiaddr = get_ipfs_info_from_cnode_endpoint(cnode_url) | ||
| update_task.ipfs_client.connect_peer(multiaddr) | ||
| redis.set(cnode_url, multiaddr, interval) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env bash | ||
| API_PORT=6001 | ||
| SWARM_PORT=6002 | ||
| CONTAINER_NAME=local_ipfs_node | ||
| if [[ "$1" =~ ^up|down$ ]]; then | ||
| echo "Local ipfs operations:" | ||
| else | ||
| echo "Must be a valid command - ./scripts/ipfs.sh <up|down>" | ||
| exit 1 | ||
| fi | ||
| if [[ "$1" == 'up' ]]; then | ||
| if [[ -z "$2" ]]; then | ||
| echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort>" | ||
| exit 1 | ||
| else | ||
| CONTAINER_NAME=$2 | ||
| fi | ||
| if [[ -z "$3" ]]; then | ||
| echo "Using default apiPort - $API_PORT" | ||
| echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort>" | ||
| else | ||
| API_PORT=$3 | ||
| fi | ||
| if [[ -z "$4" ]]; then | ||
| echo "Using default swarmPort - $SWARM_PORT" | ||
| echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort>" | ||
| else | ||
| SWARM_PORT=$4 | ||
| fi | ||
| docker run -d --name $CONTAINER_NAME -p 127.0.0.1:$API_PORT:5001 -p 127.0.0.1:$SWARM_PORT:4001 ipfs/go-ipfs:release daemon | ||
| elif [[ "$1" == 'down' ]]; then | ||
| if [[ -z "$2" ]]; then | ||
| echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort>" | ||
| exit 1 | ||
| else | ||
| CONTAINER_NAME=$2 | ||
| fi | ||
| docker stop $CONTAINER_NAME | ||
| docker rm $CONTAINER_NAME | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.