mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-05 23:43:07 +00:00
chore(common): move sqlite module to common module
This commit is contained in:
parent
ee86d190d6
commit
0de5a122ef
@ -18,13 +18,14 @@ import
|
|||||||
libp2p/transports/[transport, wstransport],
|
libp2p/transports/[transport, wstransport],
|
||||||
libp2p/nameresolving/dnsresolver
|
libp2p/nameresolving/dnsresolver
|
||||||
import
|
import
|
||||||
|
../../waku/common/sqlite,
|
||||||
|
../../waku/common/utils/nat,
|
||||||
../../waku/v2/protocol/waku_store,
|
../../waku/v2/protocol/waku_store,
|
||||||
../../waku/v2/protocol/waku_filter,
|
../../waku/v2/protocol/waku_filter,
|
||||||
../../waku/v2/protocol/waku_peer_exchange,
|
../../waku/v2/protocol/waku_peer_exchange,
|
||||||
../../waku/v2/node/peer_manager/peer_manager,
|
../../waku/v2/node/peer_manager/peer_manager,
|
||||||
../../waku/v2/node/dnsdisc/waku_dnsdisc,
|
../../waku/v2/node/dnsdisc/waku_dnsdisc,
|
||||||
../../waku/v2/node/discv5/waku_discv5,
|
../../waku/v2/node/discv5/waku_discv5,
|
||||||
../../waku/v2/node/storage/sqlite,
|
|
||||||
../../waku/v2/node/storage/migration,
|
../../waku/v2/node/storage/migration,
|
||||||
../../waku/v2/node/storage/peer/waku_peer_storage,
|
../../waku/v2/node/storage/peer/waku_peer_storage,
|
||||||
../../waku/v2/node/storage/message/waku_store_queue,
|
../../waku/v2/node/storage/message/waku_store_queue,
|
||||||
@ -37,7 +38,6 @@ import
|
|||||||
../../waku/v2/node/waku_metrics,
|
../../waku/v2/node/waku_metrics,
|
||||||
../../waku/v2/utils/peers,
|
../../waku/v2/utils/peers,
|
||||||
../../waku/v2/utils/wakuenr,
|
../../waku/v2/utils/wakuenr,
|
||||||
../../waku/common/utils/nat,
|
|
||||||
./wakunode2_setup_rest,
|
./wakunode2_setup_rest,
|
||||||
./wakunode2_setup_rpc,
|
./wakunode2_setup_rpc,
|
||||||
./config
|
./config
|
||||||
|
|||||||
@ -1,15 +1,14 @@
|
|||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[unittest, options, tables, sets, times, strutils, sequtils, os],
|
std/[unittest, options, sequtils],
|
||||||
stew/byteutils,
|
stew/byteutils,
|
||||||
chronos,
|
chronos
|
||||||
chronicles
|
|
||||||
import
|
import
|
||||||
|
../../waku/common/sqlite,
|
||||||
../../waku/v2/node/storage/message/sqlite_store,
|
../../waku/v2/node/storage/message/sqlite_store,
|
||||||
../../waku/v2/node/storage/message/message_retention_policy,
|
../../waku/v2/node/storage/message/message_retention_policy,
|
||||||
../../waku/v2/node/storage/message/message_retention_policy_capacity,
|
../../waku/v2/node/storage/message/message_retention_policy_capacity,
|
||||||
../../waku/v2/node/storage/sqlite,
|
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/v2/protocol/waku_message,
|
||||||
../../waku/v2/protocol/waku_store/pagination,
|
../../waku/v2/protocol/waku_store/pagination,
|
||||||
../../waku/v2/utils/time,
|
../../waku/v2/utils/time,
|
||||||
|
|||||||
@ -1,16 +1,14 @@
|
|||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[options, tables, sets, strutils, sequtils, algorithm],
|
std/[options, sequtils, algorithm],
|
||||||
unittest2,
|
unittest2,
|
||||||
chronos,
|
chronos
|
||||||
chronicles
|
|
||||||
import
|
import
|
||||||
|
../../waku/common/sqlite,
|
||||||
../../waku/v2/node/storage/message/sqlite_store,
|
../../waku/v2/node/storage/message/sqlite_store,
|
||||||
../../waku/v2/node/storage/sqlite,
|
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/v2/protocol/waku_message,
|
||||||
../../waku/v2/protocol/waku_store/pagination,
|
../../waku/v2/protocol/waku_store/pagination,
|
||||||
../../waku/v2/utils/time,
|
|
||||||
./utils,
|
./utils,
|
||||||
./testlib/common
|
./testlib/common
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,13 @@
|
|||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[options, sets, tables, sequtils],
|
std/[options, tables, sequtils],
|
||||||
|
stew/shims/net as stewNet,
|
||||||
chronicles,
|
chronicles,
|
||||||
testutils/unittests, stew/shims/net as stewNet,
|
testutils/unittests,
|
||||||
json_rpc/[rpcserver, rpcclient],
|
json_rpc/[rpcserver, rpcclient],
|
||||||
eth/[keys, rlp], eth/common/eth_types,
|
eth/keys,
|
||||||
|
eth/common/eth_types,
|
||||||
libp2p/[builders, switch, multiaddress],
|
libp2p/[builders, switch, multiaddress],
|
||||||
libp2p/protobuf/minprotobuf,
|
libp2p/protobuf/minprotobuf,
|
||||||
libp2p/stream/[bufferstream, connection],
|
libp2p/stream/[bufferstream, connection],
|
||||||
@ -13,14 +15,15 @@ import
|
|||||||
libp2p/protocols/pubsub/pubsub,
|
libp2p/protocols/pubsub/pubsub,
|
||||||
libp2p/protocols/pubsub/rpc/message
|
libp2p/protocols/pubsub/rpc/message
|
||||||
import
|
import
|
||||||
|
../../waku/common/sqlite,
|
||||||
|
../../waku/v2/node/peer_manager/peer_manager,
|
||||||
|
../../waku/v2/node/storage/peer/waku_peer_storage,
|
||||||
|
../../waku/v2/node/waku_node,
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/v2/protocol/waku_message,
|
||||||
../../waku/v2/protocol/waku_relay,
|
../../waku/v2/protocol/waku_relay,
|
||||||
../../waku/v2/protocol/waku_store,
|
../../waku/v2/protocol/waku_store,
|
||||||
../../waku/v2/protocol/waku_filter,
|
../../waku/v2/protocol/waku_filter,
|
||||||
../../waku/v2/protocol/waku_swap/waku_swap,
|
../../waku/v2/protocol/waku_swap/waku_swap,
|
||||||
../../waku/v2/node/peer_manager/peer_manager,
|
|
||||||
../../waku/v2/node/storage/peer/waku_peer_storage,
|
|
||||||
../../waku/v2/node/waku_node,
|
|
||||||
../test_helpers
|
../test_helpers
|
||||||
|
|
||||||
procSuite "Peer Manager":
|
procSuite "Peer Manager":
|
||||||
@ -172,7 +175,7 @@ procSuite "Peer Manager":
|
|||||||
|
|
||||||
asyncTest "Peer manager can use persistent storage and survive restarts":
|
asyncTest "Peer manager can use persistent storage and survive restarts":
|
||||||
let
|
let
|
||||||
database = SqliteDatabase.init("1", inMemory = true)[]
|
database = SqliteDatabase.new(":memory:")[]
|
||||||
storage = WakuPeerStorage.new(database)[]
|
storage = WakuPeerStorage.new(database)[]
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
@ -220,7 +223,7 @@ procSuite "Peer Manager":
|
|||||||
|
|
||||||
asyncTest "Peer manager support multiple protocol IDs when reconnecting to peers":
|
asyncTest "Peer manager support multiple protocol IDs when reconnecting to peers":
|
||||||
let
|
let
|
||||||
database = SqliteDatabase.init("2", inMemory = true)[]
|
database = SqliteDatabase.new(":memory:")[]
|
||||||
storage = WakuPeerStorage.new(database)[]
|
storage = WakuPeerStorage.new(database)[]
|
||||||
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
nodeKey1 = crypto.PrivateKey.random(Secp256k1, rng[])[]
|
||||||
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
node1 = WakuNode.new(nodeKey1, ValidIpAddress.init("0.0.0.0"),
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import
|
|||||||
std/[unittest, sets],
|
std/[unittest, sets],
|
||||||
libp2p/crypto/crypto
|
libp2p/crypto/crypto
|
||||||
import
|
import
|
||||||
|
../../waku/common/sqlite,
|
||||||
../../waku/v2/node/peer_manager/peer_manager,
|
../../waku/v2/node/peer_manager/peer_manager,
|
||||||
../../waku/v2/node/storage/peer/waku_peer_storage,
|
../../waku/v2/node/storage/peer/waku_peer_storage,
|
||||||
../test_helpers
|
../test_helpers
|
||||||
|
|||||||
@ -8,20 +8,20 @@ import
|
|||||||
chronicles,
|
chronicles,
|
||||||
libp2p/crypto/crypto
|
libp2p/crypto/crypto
|
||||||
import
|
import
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/common/sqlite,
|
||||||
../../waku/v2/protocol/waku_store,
|
|
||||||
../../waku/v2/protocol/waku_store/client,
|
|
||||||
../../waku/v2/node/storage/sqlite,
|
|
||||||
../../waku/v2/node/storage/message/waku_store_queue,
|
../../waku/v2/node/storage/message/waku_store_queue,
|
||||||
../../waku/v2/node/storage/message/sqlite_store,
|
../../waku/v2/node/storage/message/sqlite_store,
|
||||||
../../waku/v2/node/peer_manager/peer_manager,
|
../../waku/v2/node/peer_manager/peer_manager,
|
||||||
|
../../waku/v2/protocol/waku_message,
|
||||||
|
../../waku/v2/protocol/waku_store,
|
||||||
|
../../waku/v2/protocol/waku_store/client,
|
||||||
../../waku/v2/utils/time,
|
../../waku/v2/utils/time,
|
||||||
./testlib/common,
|
./testlib/common,
|
||||||
./testlib/switch
|
./testlib/switch
|
||||||
|
|
||||||
|
|
||||||
proc newTestDatabase(): SqliteDatabase =
|
proc newTestDatabase(): SqliteDatabase =
|
||||||
SqliteDatabase.init("", inMemory = true).tryGet()
|
SqliteDatabase.new(":memory:").tryGet()
|
||||||
|
|
||||||
proc newTestMessageStore(): MessageStore =
|
proc newTestMessageStore(): MessageStore =
|
||||||
let database = newTestDatabase()
|
let database = newTestDatabase()
|
||||||
|
|||||||
@ -1,25 +1,25 @@
|
|||||||
{.used.}
|
{.used.}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[options, tables, sets],
|
std/[options, tables],
|
||||||
testutils/unittests,
|
testutils/unittests,
|
||||||
chronos,
|
chronos,
|
||||||
chronicles,
|
chronicles,
|
||||||
libp2p/crypto/crypto
|
libp2p/crypto/crypto
|
||||||
import
|
import
|
||||||
|
../../waku/common/sqlite,
|
||||||
|
../../waku/v2/node/storage/message/sqlite_store,
|
||||||
|
../../waku/v2/node/peer_manager/peer_manager,
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/v2/protocol/waku_message,
|
||||||
../../waku/v2/protocol/waku_store,
|
../../waku/v2/protocol/waku_store,
|
||||||
../../waku/v2/protocol/waku_store/client,
|
../../waku/v2/protocol/waku_store/client,
|
||||||
../../waku/v2/protocol/waku_store/protocol_metrics,
|
../../waku/v2/protocol/waku_store/protocol_metrics,
|
||||||
../../waku/v2/node/storage/sqlite,
|
|
||||||
../../waku/v2/node/storage/message/sqlite_store,
|
|
||||||
../../waku/v2/node/peer_manager/peer_manager,
|
|
||||||
./testlib/common,
|
./testlib/common,
|
||||||
./testlib/switch
|
./testlib/switch
|
||||||
|
|
||||||
|
|
||||||
proc newTestDatabase(): SqliteDatabase =
|
proc newTestDatabase(): SqliteDatabase =
|
||||||
SqliteDatabase.init("", inMemory = true).tryGet()
|
SqliteDatabase.new(":memory:").tryGet()
|
||||||
|
|
||||||
proc newTestStore(): MessageStore =
|
proc newTestStore(): MessageStore =
|
||||||
let database = newTestDatabase()
|
let database = newTestDatabase()
|
||||||
|
|||||||
@ -7,17 +7,17 @@ import
|
|||||||
chronicles,
|
chronicles,
|
||||||
libp2p/crypto/crypto
|
libp2p/crypto/crypto
|
||||||
import
|
import
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/common/sqlite,
|
||||||
../../waku/v2/protocol/waku_store,
|
|
||||||
../../waku/v2/node/storage/sqlite,
|
|
||||||
../../waku/v2/node/storage/message/sqlite_store,
|
../../waku/v2/node/storage/message/sqlite_store,
|
||||||
../../waku/v2/node/peer_manager/peer_manager,
|
../../waku/v2/node/peer_manager/peer_manager,
|
||||||
|
../../waku/v2/protocol/waku_message,
|
||||||
|
../../waku/v2/protocol/waku_store,
|
||||||
./testlib/common,
|
./testlib/common,
|
||||||
./testlib/switch
|
./testlib/switch
|
||||||
|
|
||||||
|
|
||||||
proc newTestDatabase(): SqliteDatabase =
|
proc newTestDatabase(): SqliteDatabase =
|
||||||
SqliteDatabase.init("", inMemory = true).tryGet()
|
SqliteDatabase.new("memory:").tryGet()
|
||||||
|
|
||||||
proc newTestMessageStore(): MessageStore =
|
proc newTestMessageStore(): MessageStore =
|
||||||
let database = newTestDatabase()
|
let database = newTestDatabase()
|
||||||
|
|||||||
@ -14,7 +14,7 @@ import
|
|||||||
libp2p/protocols/pubsub/pubsub,
|
libp2p/protocols/pubsub/pubsub,
|
||||||
libp2p/protocols/pubsub/gossipsub
|
libp2p/protocols/pubsub/gossipsub
|
||||||
import
|
import
|
||||||
../../waku/v2/node/storage/sqlite,
|
../../waku/common/sqlite,
|
||||||
../../waku/v2/node/storage/message/sqlite_store,
|
../../waku/v2/node/storage/message/sqlite_store,
|
||||||
../../waku/v2/node/storage/message/waku_store_queue,
|
../../waku/v2/node/storage/message/waku_store_queue,
|
||||||
../../waku/v2/protocol/waku_message,
|
../../waku/v2/protocol/waku_message,
|
||||||
|
|||||||
@ -118,16 +118,6 @@ proc new*(T: type SqliteDatabase, path: string, readOnly=false): DatabaseResult[
|
|||||||
|
|
||||||
ok(SqliteDatabase(env: env.release))
|
ok(SqliteDatabase(env: env.release))
|
||||||
|
|
||||||
proc init*(
|
|
||||||
T: type SqliteDatabase,
|
|
||||||
basePath: string,
|
|
||||||
name: string = "store",
|
|
||||||
readOnly = false,
|
|
||||||
inMemory = false): DatabaseResult[T] {.deprecated: "use `SqliteDatabase.new()` instead".} =
|
|
||||||
let path = if inMemory: ":memory:"
|
|
||||||
else: basePath / name & ".sqlite3"
|
|
||||||
SqliteDatabase.new(path, readOnly)
|
|
||||||
|
|
||||||
|
|
||||||
template prepare*(env: Sqlite, q: string, cleanup: untyped): ptr sqlite3_stmt =
|
template prepare*(env: Sqlite, q: string, cleanup: untyped): ptr sqlite3_stmt =
|
||||||
var s: ptr sqlite3_stmt
|
var s: ptr sqlite3_stmt
|
||||||
@ -5,7 +5,7 @@ import
|
|||||||
stew/[results, byteutils],
|
stew/[results, byteutils],
|
||||||
sqlite3_abi
|
sqlite3_abi
|
||||||
import
|
import
|
||||||
../../sqlite,
|
../../../../../common/sqlite,
|
||||||
../../../../protocol/waku_message,
|
../../../../protocol/waku_message,
|
||||||
../../../../utils/time
|
../../../../utils/time
|
||||||
|
|
||||||
|
|||||||
@ -3,15 +3,15 @@
|
|||||||
{.push raises: [Defect].}
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
import
|
import
|
||||||
std/[options, tables, sequtils, algorithm, times],
|
std/[options, tables],
|
||||||
stew/[byteutils, results],
|
stew/[byteutils, results],
|
||||||
chronicles
|
chronicles
|
||||||
import
|
import
|
||||||
|
../../../../../common/sqlite,
|
||||||
../../../../protocol/waku_message,
|
../../../../protocol/waku_message,
|
||||||
../../../../protocol/waku_store/pagination,
|
../../../../protocol/waku_store/pagination,
|
||||||
../../../../protocol/waku_store/message_store,
|
../../../../protocol/waku_store/message_store,
|
||||||
../../../../utils/time,
|
../../../../utils/time,
|
||||||
../../sqlite,
|
|
||||||
./queries
|
./queries
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import
|
|||||||
stew/results,
|
stew/results,
|
||||||
chronicles
|
chronicles
|
||||||
import
|
import
|
||||||
./sqlite,
|
../../../common/sqlite,
|
||||||
./migration/migration_types,
|
./migration/migration_types,
|
||||||
./migration/migration_utils
|
./migration/migration_utils
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,13 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
std/sets,
|
std/sets,
|
||||||
sqlite3_abi,
|
|
||||||
libp2p/protobuf/minprotobuf,
|
|
||||||
stew/results,
|
stew/results,
|
||||||
./peer_storage,
|
sqlite3_abi,
|
||||||
../sqlite,
|
libp2p/protobuf/minprotobuf
|
||||||
../../peer_manager/waku_peer_store
|
import
|
||||||
|
../../../../common/sqlite,
|
||||||
|
../../peer_manager/waku_peer_store,
|
||||||
|
./peer_storage
|
||||||
|
|
||||||
export sqlite
|
export sqlite
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user