mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-12 14:40:37 +08:00
node: Handle announcement commands
Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
@@ -86,7 +86,9 @@ pub enum Message {
|
||||
announcement: NodeAnnouncement,
|
||||
},
|
||||
/// Get a peer's inventory.
|
||||
GetInventory { ids: Vec<ProjId> },
|
||||
GetInventory {
|
||||
ids: Vec<ProjId>,
|
||||
},
|
||||
/// Send our inventory to a peer. Sent in response to [`Message::GetInventory`].
|
||||
/// Nb. This should be the whole inventory, not a partial update.
|
||||
Inventory {
|
||||
@@ -96,6 +98,9 @@ pub enum Message {
|
||||
/// are the originator, only when relaying.
|
||||
origin: Option<NodeId>,
|
||||
},
|
||||
InventoryUpdate {
|
||||
inv: Vec<ProjId>,
|
||||
},
|
||||
}
|
||||
|
||||
impl Message {
|
||||
@@ -119,7 +124,7 @@ impl Message {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inventory<S, T, G>(ctx: &mut Context<S, T, G>) -> Result<Self, storage::Error>
|
||||
pub fn inventory<S, T, G>(ctx: &Context<S, T, G>) -> Result<Self, storage::Error>
|
||||
where
|
||||
T: storage::ReadStorage,
|
||||
{
|
||||
|
||||
@@ -194,6 +194,10 @@ impl Peer {
|
||||
}));
|
||||
}
|
||||
}
|
||||
(PeerState::Negotiated { id, git, .. }, Message::InventoryUpdate { inv }) => {
|
||||
// TODO: Buffer/throttle fetches.
|
||||
ctx.process_inventory_update(&inv, *id, git);
|
||||
}
|
||||
(
|
||||
PeerState::Negotiated { .. },
|
||||
Message::Node {
|
||||
|
||||
Reference in New Issue
Block a user