From 5a36e26e7c6bc67ec28967b6934f2cbb69d92ac3 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Thu, 14 Jan 2021 14:04:04 +0100 Subject: [PATCH] Change type and proc names to better match IPFS API --- ipfs.nim | 16 ++++++++-------- tests/ipfs/testIpfs.nim | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/ipfs.nim b/ipfs.nim index ff12850b..905bc651 100644 --- a/ipfs.nim +++ b/ipfs.nim @@ -1,22 +1,22 @@ import pkg/chronos type - DaggerPeer* = ref object + Ipfs* = ref object -proc newDaggerPeer*: DaggerPeer = - DaggerPeer() +proc create*(t: typedesc[Ipfs]): Ipfs = + Ipfs() -proc listen*(peer: DaggerPeer, address: TransportAddress) = +proc listen*(peer: Ipfs, address: TransportAddress) = discard -proc dial*(peer: DaggerPeer, address: TransportAddress) = +proc connect*(peer: Ipfs, address: TransportAddress) = discard -proc upload*(peer: DaggerPeer, input: File): Future[string] {.async.} = +proc add*(peer: Ipfs, input: File): Future[string] {.async.} = discard -proc download*(peer: DaggerPeer, identifier: string, output: File) {.async.} = +proc get*(peer: Ipfs, identifier: string, output: File) {.async.} = discard -proc close*(peer: DaggerPeer) = +proc stop*(peer: Ipfs) = discard diff --git a/tests/ipfs/testIpfs.nim b/tests/ipfs/testIpfs.nim index d651e15a..606f119c 100644 --- a/tests/ipfs/testIpfs.nim +++ b/tests/ipfs/testIpfs.nim @@ -7,14 +7,14 @@ suite "integration": let address = initTAddress("127.0.0.1:48952") - var peer1, peer2: DaggerPeer + var peer1, peer2: Ipfs var input, output: File proc setupPeers = - peer1 = newDaggerPeer() - peer2 = newDaggerPeer() + peer1 = Ipfs.create() + peer2 = Ipfs.create() peer1.listen(address) - peer2.dial(address) + peer2.connect(address) proc setupFiles = input = open("tests/input.txt", fmReadWrite) @@ -23,8 +23,8 @@ suite "integration": input.setFilePos(0) proc teardownPeers = - peer1.close() - peer2.close() + peer1.stop() + peer2.stop() proc teardownFiles = input.close() @@ -41,8 +41,8 @@ suite "integration": teardownFiles() test "file can be transferred from one peer to another": - let identifier = await peer1.upload(input) - await peer2.download(identifier, output) + let identifier = await peer1.add(input) + await peer2.get(identifier, output) input.setFilePos(0) output.setFilePos(0)