示例#1
0
async def get_ipfs_api(timeout=60, reset=False):
    global API
    if API is None or reset:
        from aleph.web import app
        host = app['config'].ipfs.host.value
        port = app['config'].ipfs.port.value

        API = aioipfs.AsyncIPFS(host=host,
                                port=port,
                                read_timeout=timeout,
                                conns_max=100)

    return API
示例#2
0
async def get_ipfs_api(timeout=5, reset=False):
    global API
    if API is None or reset:
        from aleph.web import app

        host = app["config"].ipfs.host.value
        port = app["config"].ipfs.port.value

        API = aioipfs.AsyncIPFS(
            host=host,
            port=port,
            read_timeout=timeout,
            conns_max=25,
            conns_max_per_host=10,
            debug=(app["config"].logging.level.value <= logging.DEBUG))

    return API
示例#3
0
    async def updateIpfsClient(self):
        from galacteek.ipfs import ConnectionError

        connParams = self.getIpfsConnectionParams()
        client = aioipfs.AsyncIPFS(host=connParams.host,
                                   port=connParams.apiPort,
                                   loop=self.loop)
        self.ipfsClient = client
        self.ipfsCtx.ipfsClient = client
        self.ipfsOpMain = self.getIpfsOperator()
        self.ipfsOpMain.ipidManager = self.ipidManager

        IPFSOpRegistry.regDefault(self.ipfsOpMain)

        try:
            await self.setupRepository()
        except ConnectionError:
            await messageBoxAsync(
                'IPFS connection error (is your daemon running ?)')

        await self.ipfsCtx.ipfsConnectionReady.emit()
示例#4
0
async def serve(topic):
    async with aioipfs.AsyncIPFS() as cli:
        async for message in cli.pubsub.sub(topic):
            print('Received message', message['data'], 'from', message['from'])
            d = await cli.pubsub.pub('othertopic', 'Cool')
示例#5
0
async def ipfs_find_main(args):
    client = aioipfs.AsyncIPFS(host=args.apihost, port=args.apiport)

    await find(client, args)
    await client.close()
示例#6
0
def localipfsclient(mockApp):
    client = aioipfs.AsyncIPFS(loop=mockApp.loop, host='127.0.0.1', port=5042)
    yield client
示例#7
0
def iclient2(event_loop):
    return aioipfs.AsyncIPFS(port=apiport + 10, loop=event_loop)
示例#8
0
async def pubsub_serve(topic):
    async with aioipfs.AsyncIPFS() as cli:
        async for message in cli.pubsub.sub(topic):
            print('Received message from', message['from'])
            await cli.pubsub.pub(topic, message['data'])
示例#9
0
def localipfsclient(event_loop):
    client = aioipfs.AsyncIPFS(loop=event_loop, host='127.0.0.1', port=5001)
    yield client
示例#10
0
async def get_ipfs_api(timeout=60):
    from nulsexplorer.web import app
    host = app['config'].ipfs.host.value
    port = app['config'].ipfs.port.value

    return aioipfs.AsyncIPFS(host=host, port=port, read_timeout=timeout)
示例#11
0
 def client(self):
     return aioipfs.AsyncIPFS(host='127.0.0.1',
                              port=self.apiport, loop=self.loop)
示例#12
0
 def get_client(self) -> aioipfs.AsyncIPFS:
     return aioipfs.AsyncIPFS(**self.aioipfs_config)