chore(core): move utils time module to waku_core

This commit is contained in:
Lorenzo Delgado 2023-04-19 16:39:52 +02:00 committed by GitHub
parent 5598ab64e1
commit 1b1708884b
44 changed files with 42 additions and 70 deletions

View File

@ -34,7 +34,6 @@ import
../../waku/v2/node/peer_manager, ../../waku/v2/node/peer_manager,
../../waku/v2/utils/compat, ../../waku/v2/utils/compat,
../../waku/v2/utils/peers, ../../waku/v2/utils/peers,
../../waku/v2/utils/time,
../../waku/common/utils/nat, ../../waku/common/utils/nat,
./config_chat2 ./config_chat2

View File

@ -24,7 +24,6 @@ import
# Waku v2 imports # Waku v2 imports
libp2p/crypto/crypto, libp2p/crypto/crypto,
libp2p/nameresolving/nameresolver, libp2p/nameresolving/nameresolver,
../../waku/v2/utils/time,
../../waku/v2/waku_core, ../../waku/v2/waku_core,
../../waku/v2/waku_store, ../../waku/v2/waku_store,
../../waku/v2/waku_filter, ../../waku/v2/waku_filter,

View File

@ -12,11 +12,10 @@ import
import import
../../../waku/common/logging, ../../../waku/common/logging,
../../../waku/v2/node/peer_manager, ../../../waku/v2/node/peer_manager,
../../../waku/v2/waku_node,
../../../waku/v2/waku_core, ../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/waku_enr, ../../../waku/v2/waku_enr,
../../../waku/v2/waku_discv5, ../../../waku/v2/waku_discv5
../../../waku/v2/utils/time
proc now*(): Timestamp = proc now*(): Timestamp =
getNanosecondTime(getTime().toUnixFloat()) getNanosecondTime(getTime().toUnixFloat())

View File

@ -12,8 +12,8 @@ import
import import
../../../waku/common/logging, ../../../waku/common/logging,
../../../waku/v2/node/peer_manager, ../../../waku/v2/node/peer_manager,
../../../waku/v2/waku_node,
../../../waku/v2/waku_core, ../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/waku_enr, ../../../waku/v2/waku_enr,
../../../waku/v2/waku_discv5 ../../../waku/v2/waku_discv5

View File

@ -3,8 +3,10 @@
# Waku core test suite # Waku core test suite
import import
./v2/waku_core/test_namespaced_topics, ./v2/waku_core/test_namespaced_topics,
./v2/waku_core/test_time,
./v2/waku_core/test_message_digest ./v2/waku_core/test_message_digest
# Waku archive test suite # Waku archive test suite
import import
./v2/waku_archive/test_driver_queue_index, ./v2/waku_archive/test_driver_queue_index,

View File

@ -5,7 +5,6 @@ import
import import
../../waku/v2/waku_core, ../../waku/v2/waku_core,
../../waku/v2/utils/compat, ../../waku/v2/utils/compat,
../../waku/v2/utils/time,
./testlib/common ./testlib/common
suite "Waku Payload": suite "Waku Payload":

View File

@ -2,17 +2,6 @@ import
std/[times, random], std/[times, random],
bearssl/rand, bearssl/rand,
libp2p/crypto/crypto libp2p/crypto/crypto
import
../../../waku/v2/utils/time
# Time
proc now*(): Timestamp =
getNanosecondTime(getTime().toUnixFloat())
proc ts*(offset=0, origin=now()): Timestamp =
origin + getNanosecondTime(offset)
## Randomization ## Randomization

View File

@ -1,5 +1,5 @@
import import
std/options, std/[options, times],
stew/[results, byteutils], stew/[results, byteutils],
stew/shims/net, stew/shims/net,
chronos, chronos,
@ -14,6 +14,15 @@ import
export switch export switch
# Time
proc now*(): Timestamp =
getNanosecondTime(getTime().toUnixFloat())
proc ts*(offset=0, origin=now()): Timestamp =
origin + getNanosecondTime(offset)
# Switch # Switch
proc generateEcdsaKey*(): libp2p_keys.PrivateKey = proc generateEcdsaKey*(): libp2p_keys.PrivateKey =

View File

@ -8,8 +8,7 @@ import
../../../waku/v2/waku_archive, ../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/queue_driver/queue_driver {.all.}, ../../../waku/v2/waku_archive/driver/queue_driver/queue_driver {.all.},
../../../waku/v2/waku_archive/driver/queue_driver/index, ../../../waku/v2/waku_archive/driver/queue_driver/index,
../../../waku/v2/waku_core, ../../../waku/v2/waku_core
../../../waku/v2/utils/time
# Helper functions # Helper functions

View File

@ -7,8 +7,7 @@ import
nimcrypto nimcrypto
import import
../../../waku/v2/waku_core, ../../../waku/v2/waku_core,
../../../waku/v2/waku_archive/driver/queue_driver/index, ../../../waku/v2/waku_archive/driver/queue_driver/index
../../../waku/v2/utils/time
## Helpers ## Helpers

View File

@ -9,7 +9,6 @@ import
../../../waku/v2/waku_archive/driver/queue_driver/queue_driver {.all.}, ../../../waku/v2/waku_archive/driver/queue_driver/queue_driver {.all.},
../../../waku/v2/waku_archive/driver/queue_driver/index, ../../../waku/v2/waku_archive/driver/queue_driver/index,
../../../waku/v2/waku_core, ../../../waku/v2/waku_core,
../../../waku/v2/utils/time,
../testlib/common, ../testlib/common,
../testlib/wakucore ../testlib/wakucore

View File

@ -7,12 +7,11 @@ import
chronos chronos
import import
../../../waku/common/sqlite, ../../../waku/common/sqlite,
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive, ../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/sqlite_driver, ../../../waku/v2/waku_archive/driver/sqlite_driver,
../../../waku/v2/waku_archive/retention_policy, ../../../waku/v2/waku_archive/retention_policy,
../../../waku/v2/waku_archive/retention_policy/retention_policy_capacity, ../../../waku/v2/waku_archive/retention_policy/retention_policy_capacity,
../../../waku/v2/waku_core,
../../../waku/v2/utils/time,
../testlib/common, ../testlib/common,
../testlib/wakucore ../testlib/wakucore

View File

@ -10,7 +10,6 @@ import
../../../waku/v2/waku_core, ../../../waku/v2/waku_core,
../../../waku/v2/waku_archive/driver/sqlite_driver, ../../../waku/v2/waku_archive/driver/sqlite_driver,
../../../waku/v2/waku_archive, ../../../waku/v2/waku_archive,
../../../waku/v2/utils/time,
../testlib/common, ../testlib/common,
../testlib/wakucore ../testlib/wakucore

View File

@ -1,12 +1,11 @@
{.used.} {.used.}
import import
stew/results,
testutils/unittests testutils/unittests
import import
../../waku/v2/utils/time ../../waku/v2/waku_core/time
suite "Utils - Time": suite "Waku Core - Time":
test "Test timestamp conversion": test "Test timestamp conversion":
## Given ## Given

View File

@ -6,9 +6,9 @@ import
chronos chronos
import import
../../../waku/common/protobuf, ../../../waku/common/protobuf,
../../../waku/v2/waku_core,
../../../waku/v2/waku_store/rpc, ../../../waku/v2/waku_store/rpc,
../../../waku/v2/waku_store/rpc_codec, ../../../waku/v2/waku_store/rpc_codec,
../../../waku/v2/utils/time,
../testlib/common, ../testlib/common,
../testlib/wakucore ../testlib/wakucore

View File

@ -9,16 +9,15 @@ import
json_rpc/[rpcserver, rpcclient] json_rpc/[rpcserver, rpcclient]
import import
../../../waku/v2/node/peer_manager, ../../../waku/v2/node/peer_manager,
../../../waku/v2/waku_core,
../../../waku/v2/waku_node, ../../../waku/v2/waku_node,
../../../waku/v2/node/jsonrpc/store/handlers as store_api, ../../../waku/v2/node/jsonrpc/store/handlers as store_api,
../../../waku/v2/node/jsonrpc/store/client as store_api_client, ../../../waku/v2/node/jsonrpc/store/client as store_api_client,
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive, ../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/queue_driver, ../../../waku/v2/waku_archive/driver/queue_driver,
../../../waku/v2/waku_store, ../../../waku/v2/waku_store,
../../../waku/v2/waku_store/rpc, ../../../waku/v2/waku_store/rpc,
../../../waku/v2/utils/peers, ../../../waku/v2/utils/peers,
../../../waku/v2/utils/time,
../../v2/testlib/common, ../../v2/testlib/common,
../../v2/testlib/wakucore, ../../v2/testlib/wakucore,
../../v2/testlib/wakunode ../../v2/testlib/wakunode

View File

@ -9,6 +9,7 @@ import
libp2p/crypto/crypto libp2p/crypto/crypto
import import
../../waku/common/base64, ../../waku/common/base64,
../../waku/v2/waku_core,
../../waku/v2/waku_node, ../../waku/v2/waku_node,
../../waku/v2/node/rest/server, ../../waku/v2/node/rest/server,
../../waku/v2/node/rest/client, ../../waku/v2/node/rest/client,
@ -17,9 +18,7 @@ import
../../waku/v2/node/rest/relay/handlers as relay_api, ../../waku/v2/node/rest/relay/handlers as relay_api,
../../waku/v2/node/rest/relay/client as relay_api_client, ../../waku/v2/node/rest/relay/client as relay_api_client,
../../waku/v2/node/rest/relay/topic_cache, ../../waku/v2/node/rest/relay/topic_cache,
../../waku/v2/waku_core,
../../waku/v2/waku_relay, ../../waku/v2/waku_relay,
../../waku/v2/utils/time,
../testlib/wakucore, ../testlib/wakucore,
../testlib/wakunode ../testlib/wakunode

View File

@ -9,20 +9,19 @@ import
presto, presto/client as presto_client, presto, presto/client as presto_client,
libp2p/crypto/crypto libp2p/crypto/crypto
import import
../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/node/peer_manager, ../../../waku/v2/node/peer_manager,
../../../waku/v2/node/waku_node, ../../../waku/v2/node/rest/server,
../../waku/v2/node/rest/server, ../../../waku/v2/node/rest/client,
../../waku/v2/node/rest/client, ../../../waku/v2/node/rest/responses,
../../waku/v2/node/rest/responses,
../../../waku/v2/node/rest/store/handlers as store_api, ../../../waku/v2/node/rest/store/handlers as store_api,
../../../waku/v2/node/rest/store/client as store_api_client, ../../../waku/v2/node/rest/store/client as store_api_client,
../../../waku/v2/node/rest/store/types, ../../../waku/v2/node/rest/store/types,
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive, ../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/queue_driver, ../../../waku/v2/waku_archive/driver/queue_driver,
../../../waku/v2/waku_store as waku_store, ../../../waku/v2/waku_store as waku_store,
../../../waku/v2/utils/peers, ../../../waku/v2/utils/peers,
../../../waku/v2/utils/time,
../../v2/testlib/common, ../../v2/testlib/common,
../../v2/testlib/wakucore, ../../v2/testlib/wakucore,
../../v2/testlib/wakunode ../../v2/testlib/wakunode
@ -166,7 +165,7 @@ procSuite "Waku v2 Rest API - Store":
peerSwitch.mount(node.wakuStore) peerSwitch.mount(node.wakuStore)
# Now prime it with some history before tests # Now prime it with some history before tests
let timeOrigin = common.now() let timeOrigin = wakucore.now()
let msgList = @[ let msgList = @[
fakeWakuMessage(@[byte 00], ts=ts(00, timeOrigin)), fakeWakuMessage(@[byte 00], ts=ts(00, timeOrigin)),
fakeWakuMessage(@[byte 01], ts=ts(10, timeOrigin)), fakeWakuMessage(@[byte 01], ts=ts(10, timeOrigin)),

View File

@ -9,7 +9,6 @@ import
../../waku/v2/waku_filter/rpc, ../../waku/v2/waku_filter/rpc,
../../waku/v2/waku_store/rpc, ../../waku/v2/waku_store/rpc,
../../waku/v2/waku_core, ../../waku/v2/waku_core,
../../waku/v2/utils/time,
../../waku/v2/waku_node, ../../waku/v2/waku_node,
../../waku/v2/node/waku_payload, ../../waku/v2/node/waku_payload,
../../waku/v2/node/jsonrpc/[jsonrpc_types,jsonrpc_utils] ../../waku/v2/node/jsonrpc/[jsonrpc_types,jsonrpc_utils]

View File

@ -4,8 +4,7 @@ import
json_rpc/rpcserver json_rpc/rpcserver
import import
../../../common/base64, ../../../common/base64,
../../waku_core, ../../waku_core
../../utils/time
type type

View File

@ -14,7 +14,6 @@ import
../../../waku_core, ../../../waku_core,
../../../waku_relay, ../../../waku_relay,
../../../utils/compat, ../../../utils/compat,
../../../utils/time,
../../waku_node, ../../waku_node,
../../message_cache, ../../message_cache,
./types ./types

View File

@ -7,8 +7,8 @@ import
std/[os, strutils], std/[os, strutils],
json_rpc/rpcclient json_rpc/rpcclient
import import
../../../waku_core,
../../../waku_store/rpc, ../../../waku_store/rpc,
../../../utils/time,
./types ./types
export types export types

View File

@ -8,9 +8,9 @@ import
chronicles, chronicles,
json_rpc/rpcserver json_rpc/rpcserver
import import
../../../waku_core,
../../../waku_store, ../../../waku_store,
../../../waku_store/rpc, ../../../waku_store/rpc,
../../../utils/time,
../../waku_node, ../../waku_node,
../../peer_manager, ../../peer_manager,
./types ./types

View File

@ -13,7 +13,6 @@ import
../../../../common/base64, ../../../../common/base64,
../../../waku_core, ../../../waku_core,
../../../waku_store/common, ../../../waku_store/common,
../../../utils/time,
../../waku_node, ../../waku_node,
../../peer_manager, ../../peer_manager,
../responses, ../responses,

View File

@ -13,7 +13,6 @@ import
import import
../../../waku_store/common as waku_store_common, ../../../waku_store/common as waku_store_common,
../../../../common/base64, ../../../../common/base64,
../../../utils/time,
../../../waku_core, ../../../waku_core,
../serdes ../serdes

View File

@ -39,7 +39,6 @@ import
../waku_discv5, ../waku_discv5,
../waku_peer_exchange, ../waku_peer_exchange,
../utils/peers, ../utils/peers,
../utils/time,
./config, ./config,
./peer_manager, ./peer_manager,
./waku_switch ./waku_switch

View File

@ -11,7 +11,6 @@ import
chronos, chronos,
metrics metrics
import import
../utils/time,
../waku_core, ../waku_core,
./common, ./common,
./archive_metrics, ./archive_metrics,

View File

@ -9,7 +9,6 @@ import
stew/byteutils, stew/byteutils,
nimcrypto/sha2 nimcrypto/sha2
import import
../utils/time,
../waku_core ../waku_core

View File

@ -7,7 +7,6 @@ import
std/options, std/options,
stew/results stew/results
import import
../utils/time,
../waku_core, ../waku_core,
./common ./common

View File

@ -8,7 +8,6 @@ import
nimcrypto/sha2 nimcrypto/sha2
import import
../../../waku_core, ../../../waku_core,
../../../utils/time,
../../common ../../common

View File

@ -10,7 +10,6 @@ import
chronicles chronicles
import import
../../../waku_core, ../../../waku_core,
../../../utils/time,
../../common, ../../common,
../../driver, ../../driver,
./index ./index

View File

@ -6,7 +6,6 @@ else:
import import
../../../waku_core, ../../../waku_core,
../../../utils/time,
../../common ../../common
type DbCursor* = (Timestamp, seq[byte], PubsubTopic) type DbCursor* = (Timestamp, seq[byte], PubsubTopic)

View File

@ -11,7 +11,6 @@ import
import import
../../../../common/sqlite, ../../../../common/sqlite,
../../../waku_core, ../../../waku_core,
../../../utils/time,
./cursor ./cursor

View File

@ -12,7 +12,6 @@ import
import import
../../../../common/sqlite, ../../../../common/sqlite,
../../../waku_core, ../../../waku_core,
../../../utils/time,
../../common, ../../common,
../../driver, ../../driver,
./cursor, ./cursor,

View File

@ -9,7 +9,7 @@ import
chronicles, chronicles,
chronos chronos
import import
../../utils/time, ../../waku_core,
../driver, ../driver,
../retention_policy ../retention_policy

View File

@ -1,7 +1,9 @@
import import
./waku_core/topics, ./waku_core/topics,
./waku_core/time,
./waku_core/message ./waku_core/message
export export
topics, topics,
time,
message message

View File

@ -10,8 +10,8 @@ else:
import import
../../../common/protobuf, ../../../common/protobuf,
../../utils/time,
../topics, ../topics,
../time,
./message ./message

View File

@ -10,8 +10,8 @@ else:
import import
../../utils/time, ../topics,
../topics ../time
const const
MaxMetaAttrLength* = 64 # 64 bytes MaxMetaAttrLength* = 64 # 64 bytes

View File

@ -1,4 +1,3 @@
## Contains types and utilities for timestamps.
when (NimMajor, NimMinor) < (1, 4): when (NimMajor, NimMinor) < (1, 4):
{.push raises: [Defect].} {.push raises: [Defect].}
else: else:

View File

@ -10,8 +10,8 @@ import
../protocol_types, ../protocol_types,
../protocol_metrics ../protocol_metrics
import import
../../waku_keystore, ../../waku_core,
../../utils/time ../../waku_keystore
logScope: logScope:
topics = "waku rln_relay ffi" topics = "waku rln_relay ffi"

View File

@ -22,7 +22,7 @@ import
./protocol_types, ./protocol_types,
./protocol_metrics ./protocol_metrics
import import
../utils/time, ../waku_core,
../waku_keystore ../waku_keystore
logScope: logScope:

View File

@ -9,7 +9,6 @@ import
stew/byteutils, stew/byteutils,
nimcrypto/sha2 nimcrypto/sha2
import import
../utils/time,
../waku_core ../waku_core

View File

@ -18,8 +18,8 @@ import
libp2p/stream/connection, libp2p/stream/connection,
metrics metrics
import import
../waku_core,
../node/peer_manager, ../node/peer_manager,
../utils/time,
./common, ./common,
./rpc, ./rpc,
./rpc_codec, ./rpc_codec,

View File

@ -7,7 +7,6 @@ import
std/[options, sequtils], std/[options, sequtils],
stew/results stew/results
import import
../utils/time,
../waku_core, ../waku_core,
./common ./common