Skip to content

Commit

Permalink
chore: warning cleanup (#1055)
Browse files Browse the repository at this point in the history
* chore: warning cleanup

* chore: fix proper disabling of warning

* chore: ignore the import when not needed
  • Loading branch information
AuHau authored Jan 8, 2025
1 parent 145aa5d commit 407f778
Show file tree
Hide file tree
Showing 52 changed files with 20 additions and 110 deletions.
1 change: 0 additions & 1 deletion codex.nim
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import ./codex/codextypes
export codex, conf, libp2p, chronos, logutils

when isMainModule:
import std/sequtils
import std/os
import pkg/confutils/defs
import ./codex/utils/fileutils
Expand Down
6 changes: 5 additions & 1 deletion codex/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
{.push raises: [].}

import std/os
import std/terminal

{.push warning[UnusedImport]: on.}
import std/terminal # Is not used in tests
{.pop.}

import std/options
import std/strutils
import std/typetraits
Expand Down
1 change: 0 additions & 1 deletion codex/contracts/requests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import pkg/nimcrypto
import pkg/ethers/fields
import pkg/questionable/results
import pkg/stew/byteutils
import pkg/upraises
import ../logutils
import ../utils/json

Expand Down
1 change: 0 additions & 1 deletion codex/node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import ./indexingstrategy
import ./utils
import ./errors
import ./logutils
import ./utils/poseidon2digest
import ./utils/asynciter

export logutils
Expand Down
1 change: 0 additions & 1 deletion codex/purchasing/purchaseid.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import std/hashes
import pkg/nimcrypto
import ../logutils

type PurchaseId* = distinct array[32, byte]
Expand Down
4 changes: 2 additions & 2 deletions codex/purchasing/states/started.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ method run*(state: PurchaseStarted, machine: Machine): Future[?State] {.async.}
let fut = await one(ended, failed)
await subscription.unsubscribe()
if fut.id == failed.id:
ended.cancel()
ended.cancelSoon()
return some State(PurchaseFailed())
else:
failed.cancel()
failed.cancelSoon()
return some State(PurchaseFinished())
2 changes: 1 addition & 1 deletion codex/sales/salesagent.nim
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ proc subscribeCancellation(agent: SalesAgent) {.async.} =
method onFulfilled*(agent: SalesAgent, requestId: RequestId) {.base, gcsafe, upraises: [].} =
if agent.data.requestId == requestId and
not agent.data.cancelled.isNil:
agent.data.cancelled.cancel()
agent.data.cancelled.cancelSoon()

method onFailed*(agent: SalesAgent, requestId: RequestId) {.base, gcsafe, upraises: [].} =
without request =? agent.data.request:
Expand Down
4 changes: 3 additions & 1 deletion codex/sales/states/filled.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import ./errored
import ./cancelled
import ./failed
import ./proving
import ./provingsimulated

when codex_enable_proof_failures:
import ./provingsimulated

logScope:
topics = "marketplace sales filled"
Expand Down
1 change: 0 additions & 1 deletion codex/sales/states/provingsimulated.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ when codex_enable_proof_failures:
import std/strutils
import pkg/stint
import pkg/ethers
import pkg/ethers/testing

import ../../contracts/requests
import ../../logutils
Expand Down
2 changes: 0 additions & 2 deletions codex/sales/states/slotreserving.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import pkg/questionable
import pkg/questionable/results
import pkg/metrics

import ../../logutils
Expand All @@ -9,7 +8,6 @@ import ../statemachine
import ./errorhandling
import ./cancelled
import ./failed
import ./filled
import ./ignored
import ./downloading
import ./errored
Expand Down
1 change: 0 additions & 1 deletion codex/slots/builder/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import ../../utils
import ../../stores
import ../../manifest
import ../../merkletree
import ../../utils/digest
import ../../utils/asynciter
import ../../indexingstrategy

Expand Down
1 change: 0 additions & 1 deletion codex/slots/proofs/prover.nim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import ../builder
import ../sampler

import ./backends
import ./backendfactory
import ../types

export backends
Expand Down
2 changes: 0 additions & 2 deletions codex/units.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import std/hashes
import std/strutils

import pkg/upraises

import ./logutils

type
Expand Down
1 change: 0 additions & 1 deletion codex/utils/asyncstatemachine.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import std/sugar
import pkg/questionable
import pkg/chronos
import ../logutils
Expand Down
3 changes: 1 addition & 2 deletions codex/utils/options.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import macros
import strutils
import std/macros
import pkg/questionable
import pkg/questionable/operators

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import std/sequtils
import std/sugar
import std/tables

import pkg/chronos
Expand Down
7 changes: 2 additions & 5 deletions tests/codex/blockexchange/engine/testadvertiser.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import std/sequtils
import std/random

import pkg/chronos
import pkg/libp2p/routing_record
import pkg/codexdht/discv5/protocol as discv5
Expand Down Expand Up @@ -49,7 +46,7 @@ asyncchecksuite "Advertiser":
teardown:
await advertiser.stop()

proc waitTillQueueEmpty() {.async.} =
proc waitTillQueueEmpty() {.async.} =
check eventually advertiser.advertiseQueue.len == 0

test "blockStored should queue manifest Cid for advertising":
Expand All @@ -70,7 +67,7 @@ asyncchecksuite "Advertiser":

test "blockStored should not queue non-manifest non-tree CIDs for discovery":
let blk = bt.Block.example

(await localStore.putBlock(blk)).tryGet()

await waitTillQueueEmpty()
Expand Down
1 change: 0 additions & 1 deletion tests/codex/blockexchange/engine/testblockexc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import std/algorithm
import pkg/chronos
import pkg/stew/byteutils

import pkg/codex/rng
import pkg/codex/stores
import pkg/codex/blockexchange
import pkg/codex/chunker
Expand Down
1 change: 0 additions & 1 deletion tests/codex/blockexchange/engine/testengine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import pkg/codex/chunker
import pkg/codex/discovery
import pkg/codex/blocktype
import pkg/codex/utils/asyncheapqueue
import pkg/codex/manifest

import ../../../asynctest
import ../../helpers
Expand Down
12 changes: 4 additions & 8 deletions tests/codex/helpers/mockchunker.nim
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import std/sequtils

import pkg/chronos

import pkg/codex/chunker
import pkg/codex/rng

export chunker

Expand All @@ -19,23 +15,23 @@ proc new*(
## Create a chunker that produces data
##

let
let
chunkSize = chunkSize.NBytes
dataset = @dataset

var consumed = 0
proc reader(data: ChunkBuffer, len: int): Future[int] {.async, gcsafe, raises: [Defect].} =

if consumed >= dataset.len:
return 0

var read = 0
while read < len and
while read < len and
read < chunkSize.int and
(consumed + read) < dataset.len:
data[read] = dataset[consumed + read]
read.inc

consumed += read
return read

Expand Down
1 change: 0 additions & 1 deletion tests/codex/helpers/mockrepostore.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
## those terms.

import std/sequtils
import std/sugar
import pkg/chronos
import pkg/libp2p
import pkg/questionable
Expand Down
1 change: 0 additions & 1 deletion tests/codex/merkletree/generictreetests.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import std/unittest
import std/sequtils

import pkg/codex/merkletree

Expand Down
1 change: 0 additions & 1 deletion tests/codex/merkletree/testcodexcoders.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import std/unittest
import std/sequtils

import pkg/questionable/results
import pkg/stew/byteutils
Expand Down
2 changes: 0 additions & 2 deletions tests/codex/merkletree/testcodextree.nim
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import std/unittest
import std/sequtils
import std/tables

import pkg/questionable/results
import pkg/stew/byteutils
import pkg/nimcrypto/sha2
import pkg/libp2p

import pkg/codex/codextypes
Expand Down
4 changes: 0 additions & 4 deletions tests/codex/merkletree/testmerkledigest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import std/unittest
import std/sequtils
import std/random

import pkg/constantine/math/arithmetic

import pkg/poseidon2
import pkg/poseidon2/io
import pkg/poseidon2/sponge

import pkg/questionable/results

import pkg/codex/merkletree
import pkg/codex/utils/digest
import pkg/codex/utils/poseidon2digest

import ./helpers
Expand Down
5 changes: 0 additions & 5 deletions tests/codex/merkletree/testposeidon2tree.nim
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import std/unittest
import std/sequtils
import std/sugar

import pkg/poseidon2
import pkg/poseidon2/io
import pkg/questionable/results
import pkg/results
import pkg/stew/byteutils
import pkg/stew/arrayops
import constantine/math/arithmetic
import constantine/math/io/io_bigints
import pkg/constantine/math/io/io_fields
import pkg/constantine/platforms/abstractions

import pkg/codex/merkletree

Expand Down
3 changes: 0 additions & 3 deletions tests/codex/node/helpers.nim
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import std/tables
import std/times
import std/cpuinfo

import pkg/libp2p
import pkg/chronos
import pkg/taskpools
import pkg/codex/codextypes
import pkg/codex/chunker
import pkg/codex/stores
import pkg/codex/slots

import ../../asynctest

Expand Down
6 changes: 0 additions & 6 deletions tests/codex/node/testcontracts.nim
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
import std/os
import std/options
import std/math
import std/times
import std/sequtils
import std/importutils
import std/cpuinfo

import pkg/chronos
import pkg/stew/byteutils
import pkg/datastore
import pkg/datastore/typedds
import pkg/questionable
import pkg/questionable/results
import pkg/stint
import pkg/poseidon2
import pkg/poseidon2/io
import pkg/taskpools

import pkg/nitro
Expand All @@ -31,7 +26,6 @@ import pkg/codex/slots
import pkg/codex/manifest
import pkg/codex/discovery
import pkg/codex/erasure
import pkg/codex/merkletree
import pkg/codex/blocktype as bt
import pkg/codex/stores/repostore/coders
import pkg/codex/utils/asynciter
Expand Down
2 changes: 0 additions & 2 deletions tests/codex/node/testnode.nim
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import std/os
import std/options
import std/math
import std/times
import std/sequtils
import std/importutils
import std/cpuinfo

Expand Down
1 change: 0 additions & 1 deletion tests/codex/sales/states/testdownloading.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import pkg/questionable
import pkg/codex/contracts/requests
import pkg/codex/sales/states/cancelled
import pkg/codex/sales/states/downloading
import pkg/codex/sales/states/errored
import pkg/codex/sales/states/failed
import pkg/codex/sales/states/filled
import ../../examples
Expand Down
1 change: 0 additions & 1 deletion tests/codex/sales/states/testfilled.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import pkg/codex/sales/salescontext
import pkg/codex/sales/states/filled
import pkg/codex/sales/states/errored
import pkg/codex/sales/states/proving
import pkg/codex/sales/states/finished

import ../../../asynctest
import ../../helpers/mockmarket
Expand Down
1 change: 0 additions & 1 deletion tests/codex/sales/states/testfilling.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import pkg/codex/contracts/requests
import pkg/codex/sales/states/filling
import pkg/codex/sales/states/cancelled
import pkg/codex/sales/states/failed
import pkg/codex/sales/states/filled
import ../../examples
import ../../helpers

Expand Down
1 change: 0 additions & 1 deletion tests/codex/sales/states/testpreparing.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pkg/chronos
import pkg/questionable
import pkg/datastore
import pkg/stew/byteutils
import pkg/codex/contracts/requests
import pkg/codex/sales/states/preparing
import pkg/codex/sales/states/slotreserving
Expand Down
2 changes: 0 additions & 2 deletions tests/codex/sales/states/testslotreserving.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import pkg/codex/sales/states/slotreserving
import pkg/codex/sales/states/downloading
import pkg/codex/sales/states/cancelled
import pkg/codex/sales/states/failed
import pkg/codex/sales/states/filled
import pkg/codex/sales/states/ignored
import pkg/codex/sales/states/errored
import pkg/codex/sales/salesagent
Expand All @@ -16,7 +15,6 @@ import ../../../asynctest
import ../../helpers
import ../../examples
import ../../helpers/mockmarket
import ../../helpers/mockreservations
import ../../helpers/mockclock

asyncchecksuite "sales state 'SlotReserving'":
Expand Down
1 change: 0 additions & 1 deletion tests/codex/sales/testreservations.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import std/random
import std/sequtils

import pkg/questionable
import pkg/questionable/results
Expand Down
1 change: 0 additions & 1 deletion tests/codex/sales/testslotqueue.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import std/sequtils
import pkg/chronos
import pkg/datastore
import pkg/questionable
import pkg/questionable/results

Expand Down
Loading

0 comments on commit 407f778

Please sign in to comment.