在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:pinnaculum/aioipfs开源软件地址:https://github.com/pinnaculum/aioipfs开源编程语言:Python 100.0%开源软件介绍:aioipfs
aioipfs is a python3 library providing an asynchronous API for IPFS. Supported python versions: 3.6, 3.7, 3.8, 3.9 Installationpip install aioipfs Usage examplesGet an IPFS resourceimport sys
import asyncio
import aioipfs
async def get(ipfshash):
client = aioipfs.AsyncIPFS()
await client.get(ipfshash, dstdir='.')
await client.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(get(sys.argv[1]))
loop.close() Add some filesThis example will import all files and directories specified on the command line. Note that the add API function is an asynchronous generator and therefore needs to be used with the async for syntax. import sys
import asyncio
import aioipfs
async def add_files(files):
client = aioipfs.AsyncIPFS()
async for added_file in client.add(*files, recursive=True):
print('Imported file {0}, CID: {1}'.format(
added_file['Name'], added_file['Hash']))
await client.close()
loop = asyncio.get_event_loop()
loop.run_until_complete(add_files(sys.argv[1:]))
loop.close() Pubsub serviceasync 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']) FeaturesAsync file writing on get operationsThe aiofiles library is used to asynchronously write data retrieved from the IPFS daemon when using the /api/v0/get API call, to avoid blocking the event loop. TAR extraction is done in asyncio's threadpool. RequirementsLicenseaioipfs is offered under the GNU Lesser GPL3 (LGPL3) license. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论