Skip to content

Commit cbba824

Browse files
committed
renaming: AsyncResultIterator => AsyncResultIter to have it consistent with other iterators
1 parent 025b63e commit cbba824

File tree

16 files changed

+113
-117
lines changed

16 files changed

+113
-117
lines changed

codex/erasure/erasure.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ func indexToPos(steps, idx, step: int): int {.inline.} =
121121

122122
proc getPendingBlocks(
123123
self: Erasure, manifest: Manifest, indices: seq[int]
124-
): AsyncResultIterator[(?!bt.Block, int)] =
124+
): AsyncResultIter[(?!bt.Block, int)] =
125125
## Get pending blocks iterator
126126
##
127127

128128
if indices.len == 0:
129129
trace "No indices to fetch blocks for", treeCid = manifest.treeCid
130-
return AsyncResultIterator[(?!bt.Block, int)].empty()
130+
return AsyncResultIter[(?!bt.Block, int)].empty()
131131

132132
var pendingBlocks: seq[Future[(?!bt.Block, int)].Raising([CancelledError])] = @[]
133133

@@ -162,8 +162,8 @@ proc getPendingBlocks(
162162
# but we check for that at the very beginning -
163163
# thus, if this happens, we raise an assert
164164
raiseAssert("fatal: pendingBlocks is empty - this should never happen")
165-
166-
AsyncResultIterator[(?!bt.Block, int)].new(genNext, isFinished)
165+
166+
AsyncResultIter[(?!bt.Block, int)].new(genNext, isFinished)
167167

168168
proc prepareEncodingData(
169169
self: Erasure,

codex/stores/blockstore.nim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,7 @@ method hasBlock*(
154154

155155
method listBlocks*(
156156
self: BlockStore, blockType = BlockType.Manifest
157-
): Future[?!AsyncResultIterator[Cid]] {.
158-
base, async: (raises: [CancelledError]), gcsafe
159-
.} =
157+
): Future[?!AsyncResultIter[Cid]] {.base, async: (raises: [CancelledError]), gcsafe.} =
160158
## Get the list of blocks in the BlockStore. This is an intensive operation
161159
##
162160

codex/stores/cachestore.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func cids(self: CacheStore): (iterator (): Cid {.gcsafe, raises: [].}) =
139139

140140
method listBlocks*(
141141
self: CacheStore, blockType = BlockType.Manifest
142-
): Future[?!AsyncResultIterator[Cid]] {.async: (raises: [CancelledError]).} =
142+
): Future[?!AsyncResultIter[Cid]] {.async: (raises: [CancelledError]).} =
143143
## Get the list of blocks in the BlockStore. This is an intensive operation
144144
##
145145

@@ -152,7 +152,7 @@ method listBlocks*(
152152
success(cids())
153153

154154
let iter = await (
155-
AsyncResultIterator[Cid].new(genNext, isFinished).filter(
155+
AsyncResultIter[Cid].new(genNext, isFinished).filter(
156156
proc(cid: ?!Cid): Future[bool] {.async: (raises: [CancelledError]).} =
157157
without cid =? cid, err:
158158
trace "Cannot get Cid from the iterator", err = err.msg

codex/stores/maintenance.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import pkg/questionable/results
1818

1919
import ./repostore
2020
import ../utils/timer
21-
import ../utils/asyncresultiterator
21+
import ../utils/asyncresultiter
2222
import ../clock
2323
import ../logutils
2424
import ../systemclock

codex/stores/networkstore.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import ../blockexchange
1919
import ../logutils
2020
import ../merkletree
2121
import ../utils/asyncheapqueue
22-
import ../utils/asyncresultiterator
22+
import ../utils/asyncresultiter
2323
import ./blockstore
2424

2525
export blockstore, blockexchange, asyncheapqueue
@@ -127,7 +127,7 @@ method ensureExpiry*(
127127

128128
method listBlocks*(
129129
self: NetworkStore, blockType = BlockType.Manifest
130-
): Future[?!AsyncResultIterator[Cid]] {.async: (raw: true, raises: [CancelledError]).} =
130+
): Future[?!AsyncResultIter[Cid]] {.async: (raw: true, raises: [CancelledError]).} =
131131
self.localStore.listBlocks(blockType)
132132

133133
method delBlock*(

codex/stores/queryiterhelper.nim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import pkg/chronos
44
import pkg/chronicles
55
import pkg/datastore/typedds
66

7-
import ../utils/asyncresultiterator
7+
import ../utils/asyncresultiter
88

99
{.push raises: [].}
1010

1111
type KeyVal*[T] = tuple[key: Key, value: T]
1212

13-
proc toAsyncResultIterator*[T](
13+
proc toAsyncResultIter*[T](
1414
queryIter: QueryIter[T], finishOnErr: bool = true
15-
): Future[?!AsyncResultIterator[QueryResponse[T]]] {.async: (raises: [CancelledError]).} =
16-
## Converts `QueryIter[T]` to `AsyncResultIterator[QueryResponse[T]]` and automatically
15+
): Future[?!AsyncResultIter[QueryResponse[T]]] {.async: (raises: [CancelledError]).} =
16+
## Converts `QueryIter[T]` to `AsyncResultIter[QueryResponse[T]]` and automatically
1717
## runs dispose whenever `QueryIter` finishes or whenever an error occurs (only
1818
## if the flag finishOnErr is set to true)
1919
##
@@ -22,7 +22,7 @@ proc toAsyncResultIterator*[T](
2222
trace "Disposing iterator"
2323
if error =? (await queryIter.dispose()).errorOption:
2424
return failure(error)
25-
return success(AsyncResultIterator[QueryResponse[T]].empty())
25+
return success(AsyncResultIter[QueryResponse[T]].empty())
2626

2727
var errOccurred = false
2828

@@ -42,11 +42,11 @@ proc toAsyncResultIterator*[T](
4242
proc isFinished(): bool =
4343
queryIter.finished
4444

45-
AsyncResultIterator[QueryResponse[T]].new(genNext, isFinished).success
45+
AsyncResultIter[QueryResponse[T]].new(genNext, isFinished).success
4646

4747
proc filterSuccess*[T](
48-
iter: AsyncResultIterator[QueryResponse[T]]
49-
): Future[AsyncResultIterator[tuple[key: Key, value: T]]] {.
48+
iter: AsyncResultIter[QueryResponse[T]]
49+
): Future[AsyncResultIter[tuple[key: Key, value: T]]] {.
5050
async: (raises: [CancelledError])
5151
.} =
5252
## Filters out any items that are not success

codex/stores/repostore/store.nim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,12 @@ method hasBlock*(
295295

296296
method listBlocks*(
297297
self: RepoStore, blockType = BlockType.Manifest
298-
): Future[?!AsyncResultIterator[Cid]] {.async: (raises: [CancelledError]).} =
298+
): Future[?!AsyncResultIter[Cid]] {.async: (raises: [CancelledError]).} =
299299
## Get the list of blocks in the RepoStore.
300300
## This is an intensive operation
301301
##
302302

303-
var iter = AsyncResultIterator[Cid]()
303+
var iter = AsyncResultIter[Cid]()
304304

305305
let key =
306306
case blockType
@@ -346,7 +346,7 @@ proc blockRefCount*(self: RepoStore, cid: Cid): Future[?!Natural] {.async.} =
346346

347347
method getBlockExpirations*(
348348
self: RepoStore, maxNumber: int, offset: int
349-
): Future[?!AsyncResultIterator[BlockExpiration]] {.
349+
): Future[?!AsyncResultIter[BlockExpiration]] {.
350350
async: (raises: [CancelledError]), base, gcsafe
351351
.} =
352352
## Get iterator with block expirations
@@ -360,11 +360,11 @@ method getBlockExpirations*(
360360
error "Unable to execute block expirations query", err = err.msg
361361
return failure(err)
362362

363-
without asyncQueryIter =? (await queryIter.toAsyncResultIterator()), err:
363+
without asyncQueryIter =? (await queryIter.toAsyncResultIter()), err:
364364
error "Unable to convert QueryIter to AsyncIter", err = err.msg
365365
return failure(err)
366366

367-
let filteredIter: AsyncResultIterator[KeyVal[BlockMetadata]] =
367+
let filteredIter: AsyncResultIter[KeyVal[BlockMetadata]] =
368368
await asyncQueryIter.filterSuccess()
369369

370370
proc mapping(

codex/utils.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import pkg/chronos
1919
import ./utils/asyncheapqueue
2020
import ./utils/fileutils
2121
import ./utils/iter
22-
import ./utils/asyncresultiterator
22+
import ./utils/asyncresultiter
2323

24-
export asyncheapqueue, fileutils, iter, asyncresultiterator, chronos
24+
export asyncheapqueue, fileutils, iter, asyncresultiter, chronos
2525

2626
when defined(posix):
2727
import os, posix

codex/utils/asynciter.nim

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,9 @@ import ./iter
4040
## - empty - to create an empty async iterator (AsyncIter)
4141

4242
type
43-
AsyncIterFunc[T, U] =
44-
proc(fut: T): Future[U] {.async.}
43+
AsyncIterFunc[T, U] = proc(fut: T): Future[U] {.async.}
4544
AsyncIterIsFinished = proc(): bool {.raises: [], gcsafe.}
46-
AsyncIterGenNext[T] =
47-
proc(): Future[T] {.async.}
45+
AsyncIterGenNext[T] = proc(): Future[T] {.async.}
4846

4947
AsyncIter*[T] = ref object
5048
finished: bool
@@ -218,4 +216,4 @@ proc empty*[T](_: type AsyncIter[T]): AsyncIter[T] =
218216
proc isFinished(): bool =
219217
true
220218

221-
AsyncIter[T].new(genNext, isFinished)
219+
AsyncIter[T].new(genNext, isFinished)

0 commit comments

Comments
 (0)