aqua-ipfs/aqua/ipfs-api.aqua

36 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-07-01 23:14:59 +03:00
import "@fluencelabs/aqua-lib/builtin.aqua"
import "ipfs.aqua"
alias Multiaddr: string
alias PeerId: string
2021-07-21 20:19:13 +03:00
-- Upload file `path` to IPFS node running on `node`
-- path should exist & be available to `ipfs-adapter`
2021-07-09 15:52:41 +03:00
func put(node: PeerId, path: string) -> IpfsPutResult:
2021-07-01 23:14:59 +03:00
on node:
result <- Ipfs.put(path)
<- result
2021-07-21 20:19:13 +03:00
-- Download file `hash` from IPFS node `from` and save it to `node`
2021-07-20 12:40:33 +03:00
func get_from(node: PeerId, hash: string, from: Multiaddr) -> IpfsGetResult:
2021-07-01 23:14:59 +03:00
on node:
result <- Ipfs.get_from(hash, from)
<- result
2021-07-14 22:09:19 +03:00
2021-07-21 20:19:13 +03:00
-- Set timeout for IPFS calls in `ipfs-adapter`
2021-07-14 22:09:19 +03:00
func set_timeout(node: PeerId, timeout_sec: u64):
on node:
Ipfs.set_timeout(timeout_sec)
2021-07-21 20:19:13 +03:00
-- Get multiaddress of IPFS's HTTP RPC endpoint (usually on port 5001)
func get_external_api_multiaddr(node: PeerId) -> IpfsMultiaddrResult:
on node:
result <- Ipfs.get_external_api_multiaddr()
<- result
-- Get multiaddress of IPFS's Swarm endpoint (usually on port 4001)
func get_external_swarm_multiaddr(node: PeerId) -> IpfsMultiaddrResult:
on node:
result <- Ipfs.get_external_swarm_multiaddr()
<- result