mirror of https://github.com/skygpu/skynet.git
parent
fe4574c5dc
commit
504d6cd730
|
@ -21,6 +21,7 @@ key = 5Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|||
node_url = https://testnet.skygpu.net
|
||||
hyperion_url = https://testnet.skygpu.net
|
||||
ipfs_gateway_url = /ip4/169.197.140.154/tcp/4001/p2p/12D3KooWKWogLFNEcNNMKnzU7Snrnuj84RZdMBg3sLiQSQc51oEv
|
||||
ipfs_url = http://127.0.0.1:5001
|
||||
|
||||
token = XXXXXXXXXX:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
|
@ -32,5 +33,6 @@ key = 5Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|||
node_url = https://testnet.skygpu.net
|
||||
hyperion_url = https://testnet.skygpu.net
|
||||
ipfs_gateway_url = /ip4/169.197.140.154/tcp/4001/p2p/12D3KooWKWogLFNEcNNMKnzU7Snrnuj84RZdMBg3sLiQSQc51oEv
|
||||
ipfs_url = http://127.0.0.1:5001
|
||||
|
||||
token = XXXXXXXXXX:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
|
|
@ -388,7 +388,9 @@ def dgpu(
|
|||
@click.option(
|
||||
'--node-url', '-n', default=f'https://testnet.{DEFAULT_DOMAIN}')
|
||||
@click.option(
|
||||
'--ipfs-gateway-url', '-i', default=DEFAULT_IPFS_REMOTE)
|
||||
'--ipfs-url', '-i', default=DEFAULT_IPFS_LOCAL)
|
||||
@click.option(
|
||||
'--ipfs-gateway-url', '-I', default=None)
|
||||
@click.option(
|
||||
'--db-host', '-h', default='localhost:5432')
|
||||
@click.option(
|
||||
|
@ -401,6 +403,7 @@ def telegram(
|
|||
permission: str,
|
||||
key: str | None,
|
||||
hyperion_url: str,
|
||||
ipfs_url: str,
|
||||
ipfs_gateway_url: str,
|
||||
node_url: str,
|
||||
db_host: str,
|
||||
|
@ -414,7 +417,7 @@ def telegram(
|
|||
key, account, permission = load_account_info(
|
||||
'telegram', key, account, permission)
|
||||
|
||||
node_url, _, ipfs_gateway_url, _ = load_endpoint_info(
|
||||
node_url, _, ipfs_gateway_url, ipfs_url = load_endpoint_info(
|
||||
'telegram', node_url=node_url, ipfs_gateway_url=ipfs_gateway_url)
|
||||
|
||||
async def _async_main():
|
||||
|
@ -425,6 +428,7 @@ def telegram(
|
|||
node_url,
|
||||
hyperion_url,
|
||||
db_host, db_user, db_pass,
|
||||
ipfs_url,
|
||||
remote_ipfs_node=ipfs_gateway_url,
|
||||
key=key
|
||||
)
|
||||
|
@ -449,7 +453,9 @@ def telegram(
|
|||
@click.option(
|
||||
'--node-url', '-n', default=f'https://testnet.{DEFAULT_DOMAIN}')
|
||||
@click.option(
|
||||
'--ipfs-gateway-url', '-i', default=DEFAULT_IPFS_REMOTE)
|
||||
'--ipfs-url', '-i', default=DEFAULT_IPFS_LOCAL)
|
||||
@click.option(
|
||||
'--ipfs-gateway-url', '-I', default=DEFAULT_IPFS_REMOTE)
|
||||
@click.option(
|
||||
'--db-host', '-h', default='localhost:5432')
|
||||
@click.option(
|
||||
|
@ -462,6 +468,7 @@ def discord(
|
|||
permission: str,
|
||||
key: str | None,
|
||||
hyperion_url: str,
|
||||
ipfs_url: str,
|
||||
ipfs_gateway_url: str,
|
||||
node_url: str,
|
||||
db_host: str,
|
||||
|
@ -475,8 +482,8 @@ def discord(
|
|||
key, account, permission = load_account_info(
|
||||
'discord', key, account, permission)
|
||||
|
||||
node_url, _, ipfs_gateway_url, _ = load_endpoint_info(
|
||||
'telegram', node_url=node_url, ipfs_gateway_url=ipfs_gateway_url)
|
||||
node_url, _, ipfs_gateway_url, ipfs_url = load_endpoint_info(
|
||||
'discord', node_url=node_url, ipfs_gateway_url=ipfs_gateway_url)
|
||||
|
||||
async def _async_main():
|
||||
frontend = SkynetDiscordFrontend(
|
||||
|
@ -486,6 +493,7 @@ def discord(
|
|||
node_url,
|
||||
hyperion_url,
|
||||
db_host, db_user, db_pass,
|
||||
ipfs_url,
|
||||
remote_ipfs_node=ipfs_gateway_url,
|
||||
key=key
|
||||
)
|
||||
|
|
|
@ -185,6 +185,7 @@ CONFIG_ATTRS = [
|
|||
DEFAULT_DOMAIN = 'skygpu.net'
|
||||
|
||||
DEFAULT_IPFS_REMOTE = '/ip4/169.197.140.154/tcp/4001/p2p/12D3KooWKWogLFNEcNNMKnzU7Snrnuj84RZdMBg3sLiQSQc51oEv'
|
||||
DEFAULT_IPFS_LOCAL = 'http://127.0.0.1:5001'
|
||||
|
||||
TG_MAX_WIDTH = 1280
|
||||
TG_MAX_HEIGHT = 1280
|
||||
|
|
|
@ -19,9 +19,8 @@ from leap.hyperion import HyperionAPI
|
|||
import discord
|
||||
import io
|
||||
|
||||
from skynet.db import open_new_database, open_database_connection
|
||||
from skynet.ipfs import get_ipfs_file
|
||||
from skynet.ipfs.docker import open_ipfs_node
|
||||
from skynet.db import open_database_connection
|
||||
from skynet.ipfs import get_ipfs_file, AsyncIPFSHTTP
|
||||
from skynet.constants import *
|
||||
|
||||
from . import *
|
||||
|
@ -44,6 +43,7 @@ class SkynetDiscordFrontend:
|
|||
db_host: str,
|
||||
db_user: str,
|
||||
db_pass: str,
|
||||
ipfs_url: str,
|
||||
remote_ipfs_node: str,
|
||||
key: str
|
||||
):
|
||||
|
@ -55,23 +55,21 @@ class SkynetDiscordFrontend:
|
|||
self.db_host = db_host
|
||||
self.db_user = db_user
|
||||
self.db_pass = db_pass
|
||||
self.ipfs_url = ipfs_url
|
||||
self.remote_ipfs_node = remote_ipfs_node
|
||||
self.key = key
|
||||
|
||||
self.bot = DiscordBot(self)
|
||||
self.cleos = CLEOS(None, None, url=node_url, remote=node_url)
|
||||
self.hyperion = HyperionAPI(hyperion_url)
|
||||
self.ipfs_node = AsyncIPFSHTTP(ipfs_node)
|
||||
|
||||
self._exit_stack = ExitStack()
|
||||
self._async_exit_stack = AsyncExitStack()
|
||||
|
||||
async def start(self):
|
||||
self.ipfs_node = self._exit_stack.enter_context(
|
||||
open_ipfs_node())
|
||||
|
||||
self.ipfs_node.connect(self.remote_ipfs_node)
|
||||
logging.info(
|
||||
f'connected to remote ipfs node: {self.remote_ipfs_node}')
|
||||
if self.remote_ipfs_node:
|
||||
await self.ipfs_node.connect(self.remote_ipfs_node)
|
||||
|
||||
self.db_call = await self._async_exit_stack.enter_async_context(
|
||||
open_database_connection(
|
||||
|
|
|
@ -217,10 +217,12 @@ def create_handler_context(frontend: 'SkynetDiscordFrontend'):
|
|||
image.thumbnail((512, 512))
|
||||
logging.warning(f'resized it to {image.size}')
|
||||
|
||||
image.save(f'ipfs-docker-staging/image.png', format='PNG')
|
||||
image_loc = 'ipfs-staging/image.png'
|
||||
image.save(image_loc, format='PNG')
|
||||
|
||||
ipfs_hash = ipfs_node.add('image.png')
|
||||
ipfs_node.pin(ipfs_hash)
|
||||
ipfs_info = await ipfs_node.add(image_loc)
|
||||
ipfs_hash = ipfs_info['Hash']
|
||||
await ipfs_node.pin(ipfs_hash)
|
||||
|
||||
logging.info(f'published input image {ipfs_hash} on ipfs')
|
||||
|
||||
|
|
|
@ -217,9 +217,10 @@ def create_handler_context(frontend: 'SkynetTelegramFrontend'):
|
|||
image.thumbnail((512, 512))
|
||||
logging.warning(f'resized it to {image.size}')
|
||||
|
||||
image.save(f'ipfs-docker-staging/image.png', format='PNG')
|
||||
image_loc = 'ipfs-staging/image.png'
|
||||
image.save(image_loc, format='PNG')
|
||||
|
||||
ipfs_info = await ipfs_node.add('image.png')
|
||||
ipfs_info = await ipfs_node.add(image_loc)
|
||||
ipfs_hash = ipfs_info['Hash']
|
||||
await ipfs_node.pin(ipfs_hash)
|
||||
|
||||
|
|
Loading…
Reference in New Issue