mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 14:00:31 +08:00
radicle: Consolidate databases
Instead of having a routing database, and an addresses database, consolidate that in a single database called `node.db`. We also simplify database access, by providing a single type for opening the database, and use traits to access the various functions. We create a new `seed::Store` that has seed-related methods split out of the `address::Store`. Note that tracking is still in its own database currently, as it isn't ephemeral state. This makes it easy to delete the new `node.db` without risk of losing any important information. To avoid renaming all database methods, we create a `Stores` wrapper that allows us to access routing, addresses, seeds etc. without type ambiguity. This is a breaking change and requires `addresses.db` and `routing.db` to be deleted.
This commit is contained in:
@@ -22,7 +22,7 @@ use netservices::{NetConnection, NetProtocol, NetReader, NetWriter};
|
||||
use reactor::Timestamp;
|
||||
|
||||
use radicle::collections::RandomMap;
|
||||
use radicle::node::{address, routing, NodeId};
|
||||
use radicle::node::NodeId;
|
||||
use radicle::storage::WriteStorage;
|
||||
|
||||
use crate::crypto::Signer;
|
||||
@@ -316,9 +316,9 @@ impl Peers {
|
||||
}
|
||||
|
||||
/// Wire protocol implementation for a set of peers.
|
||||
pub struct Wire<R, S, W, G: Signer + Ecdh> {
|
||||
pub struct Wire<D, S, G: Signer + Ecdh> {
|
||||
/// Backing service instance.
|
||||
service: Service<R, S, W, G>,
|
||||
service: Service<D, S, G>,
|
||||
/// Worker pool interface.
|
||||
worker: chan::Sender<Task>,
|
||||
/// Used for authentication.
|
||||
@@ -331,15 +331,14 @@ pub struct Wire<R, S, W, G: Signer + Ecdh> {
|
||||
proxy: net::SocketAddr,
|
||||
}
|
||||
|
||||
impl<R, S, W, G> Wire<R, S, W, G>
|
||||
impl<D, S, G> Wire<D, S, G>
|
||||
where
|
||||
R: routing::Store,
|
||||
S: address::Store,
|
||||
W: WriteStorage + 'static,
|
||||
D: service::Store,
|
||||
S: WriteStorage + 'static,
|
||||
G: Signer + Ecdh<Pk = NodeId>,
|
||||
{
|
||||
pub fn new(
|
||||
mut service: Service<R, S, W, G>,
|
||||
mut service: Service<D, S, G>,
|
||||
worker: chan::Sender<Task>,
|
||||
signer: G,
|
||||
proxy: net::SocketAddr,
|
||||
@@ -450,11 +449,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<R, S, W, G> reactor::Handler for Wire<R, S, W, G>
|
||||
impl<D, S, G> reactor::Handler for Wire<D, S, G>
|
||||
where
|
||||
R: routing::Store + Send,
|
||||
S: address::Store + Send,
|
||||
W: WriteStorage + Send + 'static,
|
||||
D: service::Store + Send,
|
||||
S: WriteStorage + Send + 'static,
|
||||
G: Signer + Ecdh<Pk = NodeId> + Clone + Send,
|
||||
{
|
||||
type Listener = NetAccept<WireSession<G>>;
|
||||
@@ -742,11 +740,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<R, S, W, G> Iterator for Wire<R, S, W, G>
|
||||
impl<D, S, G> Iterator for Wire<D, S, G>
|
||||
where
|
||||
R: routing::Store,
|
||||
S: address::Store,
|
||||
W: WriteStorage + 'static,
|
||||
D: service::Store,
|
||||
S: WriteStorage + 'static,
|
||||
G: Signer + Ecdh<Pk = NodeId>,
|
||||
{
|
||||
type Item = Action<G>;
|
||||
|
||||
Reference in New Issue
Block a user