From fb02ce5925b2484caa59a4efeb97cc30ba890004 Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Mon, 18 Oct 2021 11:48:40 -0300 Subject: [PATCH] Add docs to storage and mempool gossip mods (#2884) * add some docs to storage and mempool gossip mods * fix grammar Co-authored-by: Conrado Gouvea Co-authored-by: Conrado Gouvea --- zebrad/src/components/mempool/gossip.rs | 7 +++++-- zebrad/src/components/mempool/storage.rs | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/zebrad/src/components/mempool/gossip.rs b/zebrad/src/components/mempool/gossip.rs index 5e43eca0..6b8c4cac 100644 --- a/zebrad/src/components/mempool/gossip.rs +++ b/zebrad/src/components/mempool/gossip.rs @@ -1,4 +1,7 @@ -//! A task that gossips [`transaction::UnminedTxId`] that enter the mempool to peers. +//! A task that gossips any [`zebra_chain::transaction::UnminedTxId`] that enters the mempool to peers. +//! +//! This module is just a function [`gossip_mempool_transaction_id`] that waits for mempool +//! insertion events received in a channel and broadcasts the transactions to peers. use tower::{timeout::Timeout, Service, ServiceExt}; @@ -13,7 +16,7 @@ use crate::BoxError; use crate::components::sync::TIPS_RESPONSE_TIMEOUT; -/// Run continuously, gossiping new [`transaction::UnminedTxId`] to peers. +/// Run continuously, gossiping new [`zebra_chain::transaction::UnminedTxId`] to peers. /// /// Broadcast any [`transaction::UnminedTxId`] that gets stored in the mempool to all ready peers. pub async fn gossip_mempool_transaction_id( diff --git a/zebrad/src/components/mempool/storage.rs b/zebrad/src/components/mempool/storage.rs index 8c959ab1..d9a97af4 100644 --- a/zebrad/src/components/mempool/storage.rs +++ b/zebrad/src/components/mempool/storage.rs @@ -1,3 +1,12 @@ +//! Mempool transaction storage. +//! +//! The main struct [`Storage`] holds verified and rejected transactions. +//! [`Storage`] is effectively the data structure of the mempool. Convenient methods to +//! manage it are included. +//! +//! [`Storage`] does not expose a service so it can only be used by other code directly. +//! Only code inside the [`crate::components::mempool`] module has access to it. + use std::collections::{HashMap, HashSet}; use thiserror::Error; @@ -90,6 +99,7 @@ pub enum RejectionError { SameEffectsChain(#[from] SameEffectsChainRejectionError), } +/// Hold mempool verified and rejected mempool transactions. #[derive(Default)] pub struct Storage { /// The set of verified transactions in the mempool. This is a