From 612023fab04edaf8cb02b336592796324b864ef2 Mon Sep 17 00:00:00 2001 From: Lorenzo Delgado Date: Wed, 28 Sep 2022 13:36:05 +0200 Subject: [PATCH] chore(store): collocate pagination and message store types --- tests/v2/test_jsonrpc_waku.nim | 1 - tests/v2/test_message_store_queue.nim | 4 +--- tests/v2/test_message_store_queue_pagination.nim | 3 +-- tests/v2/test_message_store_sqlite.nim | 2 +- tests/v2/test_message_store_sqlite_query.nim | 2 +- tests/v2/test_waku_store.nim | 2 -- tests/v2/test_waku_store_rpc_codec.nim | 1 - tests/v2/test_wakunode_store.nim | 2 -- waku/v2/node/jsonrpc/jsonrpc_types.nim | 2 +- waku/v2/node/jsonrpc/jsonrpc_utils.nim | 3 +-- waku/v2/node/jsonrpc/store_api.nim | 1 - waku/v2/node/storage/message/dual_message_store.nim | 4 ++-- waku/v2/node/storage/message/message_retention_policy.nim | 2 +- .../storage/message/message_retention_policy_capacity.nim | 2 +- .../storage/message/message_retention_policy_time.nim | 2 +- waku/v2/node/storage/message/queue_store/index.nim | 4 ++-- waku/v2/node/storage/message/queue_store/queue_store.nim | 4 ++-- waku/v2/node/storage/message/sqlite_store/queries.nim | 2 +- .../v2/node/storage/message/sqlite_store/sqlite_store.nim | 4 ++-- waku/v2/node/wakunode2.nim | 2 -- waku/v2/protocol/waku_store.nim | 8 ++++++-- .../message => protocol/waku_store}/message_store.nim | 6 +++--- waku/v2/{utils => protocol/waku_store}/pagination.nim | 4 ++-- waku/v2/protocol/waku_store/protocol.nim | 6 +++--- waku/v2/protocol/waku_store/rpc.nim | 4 ++-- waku/v2/protocol/waku_store/rpc_codec.nim | 4 ++-- 26 files changed, 36 insertions(+), 45 deletions(-) rename waku/v2/{node/storage/message => protocol/waku_store}/message_store.nim (93%) rename waku/v2/{utils => protocol/waku_store}/pagination.nim (97%) diff --git a/tests/v2/test_jsonrpc_waku.nim b/tests/v2/test_jsonrpc_waku.nim index 6fabcfd21..ce82c4590 100644 --- a/tests/v2/test_jsonrpc_waku.nim +++ b/tests/v2/test_jsonrpc_waku.nim @@ -14,7 +14,6 @@ import libp2p/protocols/pubsub/rpc/message import ../../waku/v1/node/rpc/hexstrings, - ../../waku/v2/node/storage/message/message_store, ../../waku/v2/node/storage/message/waku_store_queue, ../../waku/v2/node/wakunode2, ../../waku/v2/node/jsonrpc/[store_api, diff --git a/tests/v2/test_message_store_queue.nim b/tests/v2/test_message_store_queue.nim index 5cc851506..939273703 100644 --- a/tests/v2/test_message_store_queue.nim +++ b/tests/v2/test_message_store_queue.nim @@ -6,12 +6,10 @@ import testutils/unittests, nimcrypto/hash import - ../../waku/v2/node/storage/message/message_store, ../../waku/v2/node/storage/message/waku_store_queue, ../../waku/v2/protocol/waku_message, ../../waku/v2/protocol/waku_store, - ../../waku/v2/utils/time, - ../../waku/v2/utils/pagination + ../../waku/v2/utils/time # Helper functions diff --git a/tests/v2/test_message_store_queue_pagination.nim b/tests/v2/test_message_store_queue_pagination.nim index 5a56fd126..5dcd1331f 100644 --- a/tests/v2/test_message_store_queue_pagination.nim +++ b/tests/v2/test_message_store_queue_pagination.nim @@ -9,8 +9,7 @@ import ../../waku/v2/node/storage/message/waku_store_queue, ../../waku/v2/protocol/waku_store, ../../waku/v2/protocol/waku_message, - ../../waku/v2/utils/time, - ../../waku/v2/utils/pagination + ../../waku/v2/utils/time const diff --git a/tests/v2/test_message_store_sqlite.nim b/tests/v2/test_message_store_sqlite.nim index 0a3c4f7ed..1f4be9ba8 100644 --- a/tests/v2/test_message_store_sqlite.nim +++ b/tests/v2/test_message_store_sqlite.nim @@ -12,8 +12,8 @@ import ../../waku/v2/node/storage/message/message_retention_policy_capacity, ../../waku/v2/node/storage/sqlite, ../../waku/v2/protocol/waku_message, + ../../waku/v2/protocol/waku_store/pagination, ../../waku/v2/utils/time, - ../../waku/v2/utils/pagination, ./utils diff --git a/tests/v2/test_message_store_sqlite_query.nim b/tests/v2/test_message_store_sqlite_query.nim index d73319b57..3a7cede8c 100644 --- a/tests/v2/test_message_store_sqlite_query.nim +++ b/tests/v2/test_message_store_sqlite_query.nim @@ -9,8 +9,8 @@ import ../../waku/v2/node/storage/message/sqlite_store, ../../waku/v2/node/storage/sqlite, ../../waku/v2/protocol/waku_message, + ../../waku/v2/protocol/waku_store/pagination, ../../waku/v2/utils/time, - ../../waku/v2/utils/pagination, ./utils diff --git a/tests/v2/test_waku_store.nim b/tests/v2/test_waku_store.nim index 5563fd320..bb6e465e6 100644 --- a/tests/v2/test_waku_store.nim +++ b/tests/v2/test_waku_store.nim @@ -12,11 +12,9 @@ import ../../waku/v2/protocol/waku_message, ../../waku/v2/protocol/waku_store, ../../waku/v2/node/storage/sqlite, - ../../waku/v2/node/storage/message/message_store, ../../waku/v2/node/storage/message/waku_store_queue, ../../waku/v2/node/storage/message/sqlite_store, ../../waku/v2/node/peer_manager/peer_manager, - ../../waku/v2/utils/pagination, ../../waku/v2/utils/time, ../test_helpers diff --git a/tests/v2/test_waku_store_rpc_codec.nim b/tests/v2/test_waku_store_rpc_codec.nim index 2b52415fe..41e1a3efa 100644 --- a/tests/v2/test_waku_store_rpc_codec.nim +++ b/tests/v2/test_waku_store_rpc_codec.nim @@ -9,7 +9,6 @@ import import ../../waku/v2/protocol/waku_message, ../../waku/v2/protocol/waku_store, - ../../waku/v2/utils/pagination, ../../waku/v2/utils/time const diff --git a/tests/v2/test_wakunode_store.nim b/tests/v2/test_wakunode_store.nim index 7c46de61e..d75cae3ba 100644 --- a/tests/v2/test_wakunode_store.nim +++ b/tests/v2/test_wakunode_store.nim @@ -15,7 +15,6 @@ import libp2p/protocols/pubsub/gossipsub import ../../waku/v2/node/storage/sqlite, - ../../waku/v2/node/storage/message/message_store, ../../waku/v2/node/storage/message/sqlite_store, ../../waku/v2/node/storage/message/waku_store_queue, ../../waku/v2/protocol/waku_message, @@ -23,7 +22,6 @@ import ../../waku/v2/protocol/waku_filter, ../../waku/v2/node/peer_manager/peer_manager, ../../waku/v2/utils/peers, - ../../waku/v2/utils/pagination, ../../waku/v2/utils/time, ../../waku/v2/node/wakunode2 diff --git a/waku/v2/node/jsonrpc/jsonrpc_types.nim b/waku/v2/node/jsonrpc/jsonrpc_types.nim index 0f96f724e..296e84619 100644 --- a/waku/v2/node/jsonrpc/jsonrpc_types.nim +++ b/waku/v2/node/jsonrpc/jsonrpc_types.nim @@ -4,7 +4,7 @@ import std/[options,tables], eth/keys, ../../protocol/waku_message, - ../../utils/pagination, + ../../protocol/waku_store/pagination, ../../utils/time type diff --git a/waku/v2/node/jsonrpc/jsonrpc_utils.nim b/waku/v2/node/jsonrpc/jsonrpc_utils.nim index 9c1b968a0..7002619ec 100644 --- a/waku/v2/node/jsonrpc/jsonrpc_utils.nim +++ b/waku/v2/node/jsonrpc/jsonrpc_utils.nim @@ -4,10 +4,9 @@ import std/[options, json], eth/keys, ../../../v1/node/rpc/hexstrings, - ../../protocol/waku_store, ../../protocol/waku_message, + ../../protocol/waku_store, ../../utils/time, - ../../utils/pagination, ../waku_payload, ./jsonrpc_types diff --git a/waku/v2/node/jsonrpc/store_api.nim b/waku/v2/node/jsonrpc/store_api.nim index e7ecc8655..f4ad24b0a 100644 --- a/waku/v2/node/jsonrpc/store_api.nim +++ b/waku/v2/node/jsonrpc/store_api.nim @@ -8,7 +8,6 @@ import ../wakunode2, ../../protocol/waku_store, ../../utils/time, - ../../utils/pagination, ./jsonrpc_types, ./jsonrpc_utils diff --git a/waku/v2/node/storage/message/dual_message_store.nim b/waku/v2/node/storage/message/dual_message_store.nim index afab59d48..33c0c94d1 100644 --- a/waku/v2/node/storage/message/dual_message_store.nim +++ b/waku/v2/node/storage/message/dual_message_store.nim @@ -6,10 +6,10 @@ import chronicles import ../../../protocol/waku_message, - ../../../utils/pagination, + ../../../protocol/waku_store/pagination, + ../../../protocol/waku_store/message_store, ../../../utils/time, ../sqlite, - ./message_store, ./waku_store_queue, ./sqlite_store diff --git a/waku/v2/node/storage/message/message_retention_policy.nim b/waku/v2/node/storage/message/message_retention_policy.nim index 4465d4090..009a75dae 100644 --- a/waku/v2/node/storage/message/message_retention_policy.nim +++ b/waku/v2/node/storage/message/message_retention_policy.nim @@ -3,7 +3,7 @@ import stew/results import - ./message_store + ../../../protocol/waku_store/message_store type RetentionPolicyResult*[T] = Result[T, string] diff --git a/waku/v2/node/storage/message/message_retention_policy_capacity.nim b/waku/v2/node/storage/message/message_retention_policy_capacity.nim index c827e28d7..0e017040e 100644 --- a/waku/v2/node/storage/message/message_retention_policy_capacity.nim +++ b/waku/v2/node/storage/message/message_retention_policy_capacity.nim @@ -4,7 +4,7 @@ import stew/results, chronicles import - ./message_store, + ../../../protocol/waku_store/message_store, ./message_retention_policy logScope: diff --git a/waku/v2/node/storage/message/message_retention_policy_time.nim b/waku/v2/node/storage/message/message_retention_policy_time.nim index 1ef677ba6..d0743453e 100644 --- a/waku/v2/node/storage/message/message_retention_policy_time.nim +++ b/waku/v2/node/storage/message/message_retention_policy_time.nim @@ -6,8 +6,8 @@ import chronicles, chronos import + ../../../protocol/waku_store/message_store, ../../../utils/time, - ./message_store, ./message_retention_policy logScope: diff --git a/waku/v2/node/storage/message/queue_store/index.nim b/waku/v2/node/storage/message/queue_store/index.nim index 7da825f8e..e47ccbc0d 100644 --- a/waku/v2/node/storage/message/queue_store/index.nim +++ b/waku/v2/node/storage/message/queue_store/index.nim @@ -5,8 +5,8 @@ import nimcrypto/sha2 import ../../../../protocol/waku_message, - ../../../../utils/time, - ../../../../utils/pagination + ../../../../protocol/waku_store/pagination, + ../../../../utils/time type Index* = object diff --git a/waku/v2/node/storage/message/queue_store/queue_store.nim b/waku/v2/node/storage/message/queue_store/queue_store.nim index 90c9d5801..ecff359c4 100644 --- a/waku/v2/node/storage/message/queue_store/queue_store.nim +++ b/waku/v2/node/storage/message/queue_store/queue_store.nim @@ -7,9 +7,9 @@ import import ../../../../protocol/waku_message, ../../../../protocol/waku_store/rpc, - ../../../../utils/pagination, + ../../../../protocol/waku_store/pagination, + ../../../../protocol/waku_store/message_store, ../../../../utils/time, - ../message_store, ./index diff --git a/waku/v2/node/storage/message/sqlite_store/queries.nim b/waku/v2/node/storage/message/sqlite_store/queries.nim index 28ab95154..317def711 100644 --- a/waku/v2/node/storage/message/sqlite_store/queries.nim +++ b/waku/v2/node/storage/message/sqlite_store/queries.nim @@ -7,7 +7,7 @@ import import ../../sqlite, ../../../../protocol/waku_message, - ../../../../utils/pagination, + ../../../../protocol/waku_store/pagination, ../../../../utils/time diff --git a/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim b/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim index 032cf80fc..6d3817c4c 100644 --- a/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim +++ b/waku/v2/node/storage/message/sqlite_store/sqlite_store.nim @@ -8,10 +8,10 @@ import chronicles import ../../../../protocol/waku_message, - ../../../../utils/pagination, + ../../../../protocol/waku_store/pagination, + ../../../../protocol/waku_store/message_store, ../../../../utils/time, ../../sqlite, - ../message_store, ./queries logScope: diff --git a/waku/v2/node/wakunode2.nim b/waku/v2/node/wakunode2.nim index d58b4ee05..52b8dcdca 100644 --- a/waku/v2/node/wakunode2.nim +++ b/waku/v2/node/wakunode2.nim @@ -25,7 +25,6 @@ import ../utils/[peers, requests, wakuenr], ./peer_manager/peer_manager, ./storage/message/waku_store_queue, - ./storage/message/message_store, ./storage/message/message_retention_policy, ./storage/message/message_retention_policy_capacity, ./storage/message/message_retention_policy_time, @@ -819,7 +818,6 @@ when isMainModule: ./wakunode2_setup_rpc, ./wakunode2_setup_sql_migrations, ./storage/sqlite, - ./storage/message/message_store, ./storage/message/dual_message_store, ./storage/message/sqlite_store, ./storage/peer/waku_peer_storage diff --git a/waku/v2/protocol/waku_store.nim b/waku/v2/protocol/waku_store.nim index b34494b5f..2491e05a3 100644 --- a/waku/v2/protocol/waku_store.nim +++ b/waku/v2/protocol/waku_store.nim @@ -1,9 +1,13 @@ import ./waku_store/protocol, ./waku_store/rpc, - ./waku_store/rpc_codec + ./waku_store/rpc_codec, + ./waku_store/pagination, + ./waku_store/message_store export protocol, rpc, - rpc_codec \ No newline at end of file + rpc_codec, + pagination, + message_store \ No newline at end of file diff --git a/waku/v2/node/storage/message/message_store.nim b/waku/v2/protocol/waku_store/message_store.nim similarity index 93% rename from waku/v2/node/storage/message/message_store.nim rename to waku/v2/protocol/waku_store/message_store.nim index 50b284f0b..6ac956467 100644 --- a/waku/v2/node/storage/message/message_store.nim +++ b/waku/v2/protocol/waku_store/message_store.nim @@ -7,9 +7,9 @@ import std/[options, times], stew/results import - ../../../protocol/waku_message, - ../../../utils/time, - ../../../utils/pagination + ../waku_message, + ./pagination, + ../../utils/time type diff --git a/waku/v2/utils/pagination.nim b/waku/v2/protocol/waku_store/pagination.nim similarity index 97% rename from waku/v2/utils/pagination.nim rename to waku/v2/protocol/waku_store/pagination.nim index 16496fc9a..05c1442d9 100644 --- a/waku/v2/utils/pagination.nim +++ b/waku/v2/protocol/waku_store/pagination.nim @@ -5,8 +5,8 @@ import stew/byteutils, nimcrypto/sha2 import - ../protocol/waku_message, - ./time + ../waku_message, + ../../utils/time const MaxPageSize*: uint64 = 100 diff --git a/waku/v2/protocol/waku_store/protocol.nim b/waku/v2/protocol/waku_store/protocol.nim index 2b3a06760..7038fd263 100644 --- a/waku/v2/protocol/waku_store/protocol.nim +++ b/waku/v2/protocol/waku_store/protocol.nim @@ -15,17 +15,17 @@ import libp2p/stream/connection, metrics import - ../../node/storage/message/message_store, ../../node/storage/message/message_retention_policy, ../../node/storage/message/waku_store_queue, ../../node/peer_manager/peer_manager, ../../utils/time, - ../../utils/pagination, ../../utils/requests, ../waku_message, ../waku_swap/waku_swap, ./rpc, - ./rpc_codec + ./rpc_codec, + ./pagination, + ./message_store declarePublicGauge waku_store_messages, "number of historical messages", ["type"] diff --git a/waku/v2/protocol/waku_store/rpc.nim b/waku/v2/protocol/waku_store/rpc.nim index 2216bde1e..7dac64ff5 100644 --- a/waku/v2/protocol/waku_store/rpc.nim +++ b/waku/v2/protocol/waku_store/rpc.nim @@ -4,8 +4,8 @@ import nimcrypto/hash import ../waku_message, - ../../utils/pagination, - ../../utils/time + ../../utils/time, + ./pagination type diff --git a/waku/v2/protocol/waku_store/rpc_codec.nim b/waku/v2/protocol/waku_store/rpc_codec.nim index ad6b2961c..5b4452446 100644 --- a/waku/v2/protocol/waku_store/rpc_codec.nim +++ b/waku/v2/protocol/waku_store/rpc_codec.nim @@ -7,9 +7,9 @@ import import ../waku_message, ../../utils/protobuf, - ../../utils/pagination, ../../utils/time, - ./rpc + ./rpc, + ./pagination const MaxRpcSize* = MaxPageSize * MaxWakuMessageSize + 64*1024 # We add a 64kB safety buffer for protocol overhead