remove obsolete contents

This commit is contained in:
Dmitriy Ryajov 2021-08-27 16:06:55 -06:00
parent 2c919c40e8
commit 02095967f9
No known key found for this signature in database
GPG Key ID: DA8C680CE7C657A4
1 changed files with 0 additions and 49 deletions

View File

@ -1,49 +0,0 @@
import pkg/chronos
import pkg/libp2p/peerinfo
import pkg/libp2p/multiaddress
import ./ipfs/p2p/switch
import ./ipfs/repo
import ./ipfs/chunking
import ./ipfs/bitswap
export peerinfo except IPFS
export multiaddress except IPFS
type
Ipfs* = ref object
repo: Repo
switch: Switch
bitswap: Bitswap
proc info*(ipfs: Ipfs): PeerInfo =
ipfs.switch.peerInfo
proc start*(_: type Ipfs, addresses: seq[MultiAddress]): Future[Ipfs] {.async.} =
let repo = Repo()
let switch = Switch.create()
let bitswap = Bitswap.start(switch, repo)
switch.peerInfo.addrs.add(addresses)
discard await switch.start()
result = Ipfs(repo: repo, switch: switch, bitswap: bitswap)
proc start*(_: type Ipfs, address: MultiAddress): Future[Ipfs] {.async.} =
result = await Ipfs.start(@[address])
proc start*(_: type Ipfs): Future[Ipfs] {.async.} =
result = await Ipfs.start(@[])
proc connect*(peer: Ipfs, info: PeerInfo) {.async.} =
await peer.bitswap.connect(info)
proc add*(peer: Ipfs, input: File): Future[Cid] {.async.} =
let obj = createObject(input)
peer.repo.store(obj)
result = obj.cid
proc get*(peer: Ipfs, identifier: Cid, output: File) {.async.} =
let obj = await peer.bitswap.retrieve(identifier)
if obj.isSome:
obj.get().writeToFile(output)
proc stop*(peer: Ipfs) {.async.} =
await peer.switch.stop()