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 <conradoplg@gmail.com>

Co-authored-by: Conrado Gouvea <conradoplg@gmail.com>
This commit is contained in:
Alfredo Garcia 2021-10-18 11:48:40 -03:00 committed by GitHub
parent 2d129414e0
commit fb02ce5925
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -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<ZN>(

View File

@ -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