node: Cache node inventory

For large seeds with many repos, it's expensive to traverse the
inventory everytime the node connects to a new peer, for example.

To improve the situation, we cache the inventory per `Storage` instance,
and add a `refresh` method to refresh the inventory.

This method is called when the node is told to synchronize its
inventory.
This commit is contained in:
cloudhead
2024-03-21 12:40:58 +01:00
parent f15afa84be
commit 0e880e12e6
8 changed files with 64 additions and 10 deletions
+4
View File
@@ -20,6 +20,7 @@ use radicle::node::address::Store as _;
use radicle::node::notifications;
use radicle::node::Handle as _;
use radicle::profile::Home;
use radicle::storage;
use radicle::Storage;
use radicle::{cob, git};
@@ -48,6 +49,9 @@ pub enum Error {
/// A node database error.
#[error("node database error: {0}")]
Database(#[from] node::db::Error),
/// A storage error.
#[error("storage error: {0}")]
Storage(#[from] storage::Error),
/// A policies database error.
#[error("policies database error: {0}")]
Policy(#[from] policy::Error),