Skip to content

Commit

Permalink
chore: remove warnings (#3106)
Browse files Browse the repository at this point in the history
- Removes deprecation and unused import warnings for libwaku
- Removes unused imports
- Adds .base. pragma to `SubscriptionObserver.onSubscribe`
- Uses casting for uint to enums conversions
- Bumps nim-chronicles
  • Loading branch information
richard-ramos authored Oct 10, 2024
1 parent 21b0355 commit c861fa9
Show file tree
Hide file tree
Showing 24 changed files with 32 additions and 38 deletions.
4 changes: 2 additions & 2 deletions library/events/json_message_event.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import system, std/[json, sequtils]
import stew/[byteutils, results]
import system, results, std/json
import stew/byteutils
import
../../waku/common/base64,
../../waku/waku_core/message,
Expand Down
2 changes: 1 addition & 1 deletion library/libwaku.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
when defined(linux):
{.passl: "-Wl,-soname,libwaku.so".}

import std/[json, sequtils, atomics, strformat, options, atomics]
import std/[json, atomics, strformat, options, atomics]
import chronicles, chronos
import
waku/common/base64,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import std/[json, sequtils]
import std/json
import chronos, chronicles, results, libp2p/multiaddress
import
../../../../waku/factory/waku,
../../../../waku/discovery/waku_dnsdisc,
../../../../waku/discovery/waku_discv5,
../../../../waku/waku_peer_exchange,
../../../../waku/waku_core/peers,
../../../../waku/node/waku_node,
../../../alloc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import std/[options, sequtils, json, strutils, net]
import std/[options, json, strutils, net]
import chronos, chronicles, results, confutils, confutils/std/net

import
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import std/net, options
import chronicles, chronos, stew/byteutils, results
import options
import chronicles, chronos, results
import
../../../../../waku/waku_core/message/message,
../../../../../waku/factory/waku,
Expand Down
2 changes: 1 addition & 1 deletion vendor/nim-chronicles
4 changes: 2 additions & 2 deletions waku.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,14 @@ task libwakuStatic, "Build the cbindings waku node library":
let name = "libwaku"
buildLibrary name,
"library/",
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" """,
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on """,
"static"

task libwakuDynamic, "Build the cbindings waku node library":
let name = "libwaku"
buildLibrary name,
"library/",
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" """,
"""-d:chronicles_line_numbers -d:chronicles_runtime_filtering=on -d:chronicles_sinks="textlines,json" -d:chronicles_default_output_device=Dynamic -d:chronicles_disabled_topics="eth,dnsdisc.client" --warning:Deprecated:off --warning:UnusedImport:on """,
"dynamic"

### Mobile Android
Expand Down
2 changes: 1 addition & 1 deletion waku/common/rate_limit/per_peer_limiter.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{.push raises: [].}

import std/[options, tables], chronos/timer, libp2p/stream/connection, libp2p/utility
import std/[options, tables], libp2p/stream/connection

import ./[single_token_limiter, service_metrics], ../../utils/tableutils

Expand Down
2 changes: 1 addition & 1 deletion waku/factory/waku.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{.push raises: [].}

import
std/[options, sequtils],
std/options,
results,
chronicles,
chronos,
Expand Down
2 changes: 1 addition & 1 deletion waku/node/delivery_monitor/recv_monitor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## receive and is backed by store-v3 requests to get an additional degree of certainty
##

import std/[tables, sequtils, sets, options]
import std/[tables, sequtils, options]
import chronos, chronicles, libp2p/utility
import
../../waku_core,
Expand Down
4 changes: 2 additions & 2 deletions waku/node/delivery_monitor/send_monitor.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## This module reinforces the publish operation with regular store-v3 requests.
##

import std/[sets, sequtils]
import std/sequtils
import chronos, chronicles, libp2p/utility
import
./delivery_callback,
Expand Down Expand Up @@ -206,7 +206,7 @@ proc startSendMonitor*(self: SendMonitor) =
self.msgStoredCheckerHandle = self.checkIfMessagesStored()

proc stopSendMonitor*(self: SendMonitor) =
self.msgStoredCheckerHandle.cancel()
discard self.msgStoredCheckerHandle.cancelAndWait()

proc setDeliveryCallback*(self: SendMonitor, deliveryCb: DeliveryFeedbackCallback) =
self.deliveryCb = deliveryCb
2 changes: 1 addition & 1 deletion waku/node/delivery_monitor/subscriptions_observer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ method onSubscribe*(

method onUnsubscribe*(
self: SubscriptionObserver, pubsubTopic: string, contentTopics: seq[string]
) {.gcsafe, raises: [].} =
) {.base, gcsafe, raises: [].} =
error "onUnsubscribe not implemented"
3 changes: 2 additions & 1 deletion waku/waku_archive/archive.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import
std/[times, options, sequtils, algorithm],
stew/[results, byteutils],
stew/[byteutils],
chronicles,
chronos,
results,
metrics
import
../common/paging,
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_archive/common.nim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{.push raises: [].}

import std/options, results, stew/byteutils, stew/arrayops, nimcrypto/sha2
import std/options, results
import ../waku_core, ../common/paging

## Public API types
Expand Down
7 changes: 4 additions & 3 deletions waku/waku_archive_legacy/archive.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ else:
{.push raises: [].}

import
std/[times, options, sequtils, strutils, algorithm],
stew/[results, byteutils],
std/[times, options, sequtils, algorithm],
stew/byteutils,
chronicles,
chronos,
metrics
metrics,
results
import
../common/paging,
./driver,
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_archive_legacy/driver/queue_driver/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ when (NimMajor, NimMinor) < (1, 4):
else:
{.push raises: [].}

import stew/byteutils, nimcrypto/sha2
import nimcrypto/sha2
import ../../../waku_core, ../../common

type Index* = object
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_filter_v2/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ proc serviceUnavailable*(
proc parse*(T: type FilterSubscribeErrorKind, kind: uint32): T =
case kind
of 000, 200, 300, 400, 404, 429, 503:
FilterSubscribeErrorKind(kind)
cast[FilterSubscribeErrorKind](kind)
else:
FilterSubscribeErrorKind.UNKNOWN

Expand Down
2 changes: 1 addition & 1 deletion waku/waku_filter_v2/subscriptions.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{.push raises: [].}

import std/[sets, tables], chronicles, chronos, libp2p/peerid, stew/shims/sets
import ../waku_core, ../utils/tableutils, ../common/rate_limit/setting
import ../waku_core, ../utils/tableutils

logScope:
topics = "waku filter subscriptions"
Expand Down
1 change: 0 additions & 1 deletion waku/waku_lightpush/callbacks.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import
../waku_core,
../waku_relay,
./common,
./protocol,
./protocol_metrics,
../waku_rln_relay,
../waku_rln_relay/protocol_types
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_peer_exchange/protocol.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/[options, sequtils, random, sugar],
std/[options, sequtils, random],
results,
chronicles,
chronos,
Expand Down
2 changes: 1 addition & 1 deletion waku/waku_peer_exchange/rpc_codec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ proc decode*(T: type PeerExchangePeerInfo, buffer: seq[byte]): ProtoResult[T] =
proc parse*(T: type PeerExchangeResponseStatusCode, status: uint32): T =
case status
of 200, 400, 429, 503:
PeerExchangeResponseStatusCode(status)
cast[PeerExchangeResponseStatusCode](status)
else:
PeerExchangeResponseStatusCode.UNKNOWN

Expand Down
8 changes: 1 addition & 7 deletions waku/waku_rln_relay/protocol_metrics.nim
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{.push raises: [].}

import
chronicles,
chronos,
metrics,
metrics/chronos_httpserver,
./constants,
../utils/collector
import chronicles, metrics, metrics/chronos_httpserver, ./constants, ../utils/collector

export metrics

Expand Down
4 changes: 2 additions & 2 deletions waku/waku_store/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type
StoreQueryResult* = Result[StoreQueryResponse, StoreError]

proc into*(errCode: ErrorCode): StatusCode =
StatusCode(uint32(errCode))
cast[StatusCode](uint32(errCode))

proc new*(T: type StoreError, code: uint32, desc: string): T =
let kind = ErrorCode.parse(code)
Expand All @@ -98,7 +98,7 @@ proc new*(T: type StoreError, code: uint32, desc: string): T =
proc parse*(T: type ErrorCode, kind: uint32): T =
case kind
of 000, 300, 400, 429, 503, 504:
ErrorCode(kind)
cast[ErrorCode](kind)
else:
ErrorCode.UNKNOWN

Expand Down
2 changes: 1 addition & 1 deletion waku/waku_store_legacy/rpc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type
proc parse*(T: type HistoryResponseErrorRPC, kind: uint32): T =
case kind
of 0, 1, 429, 503:
HistoryResponseErrorRPC(kind)
cast[HistoryResponseErrorRPC](kind)
else:
# TODO: Improve error variants/move to satus codes
HistoryResponseErrorRPC.INVALID_CURSOR
Expand Down

0 comments on commit c861fa9

Please sign in to comment.