mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-10 12:54:47 +00:00
Boog900
75306babf8
* init D++ * init D++ router * working D++ router * add test * D++ tx pool * add more txpool docs * add a txpool builder * add tracing * add more docs * fix doc * reduce test epoch (windows CI fail) * generate first state in config Windows seems to not allows taking a big value from an instant * extend tests * clippy * review comments + more docs * Apply suggestions from code review Co-authored-by: hinto-janai <hinto.janai@protonmail.com> * update Cargo.lock * rename txpool.rs -> pool.rs * review comments * Update p2p/dandelion/src/tests/router.rs Co-authored-by: hinto-janai <hinto.janai@protonmail.com> * Update p2p/dandelion/src/router.rs Co-authored-by: hinto-janai <hinto.janai@protonmail.com> --------- Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
49 lines
1.9 KiB
Rust
49 lines
1.9 KiB
Rust
/// A request to diffuse a transaction to all connected peers.
|
|
///
|
|
/// This crate does not handle diffusion it is left to implementers.
|
|
pub struct DiffuseRequest<Tx>(pub Tx);
|
|
|
|
/// A request sent to a single peer to stem this transaction.
|
|
pub struct StemRequest<Tx>(pub Tx);
|
|
|
|
#[cfg(feature = "txpool")]
|
|
/// A request sent to the backing transaction pool storage.
|
|
pub enum TxStoreRequest<Tx, TxID> {
|
|
/// A request to store a transaction with the ID to store it under and the pool to store it in.
|
|
///
|
|
/// If the tx is already in the pool then do nothing, unless the tx is in the stem pool then move it
|
|
/// to the fluff pool, _if this request state is fluff_.
|
|
Store(Tx, TxID, crate::State),
|
|
/// A request to retrieve a `Tx` with the given ID from the pool, should not remove that tx from the pool.
|
|
///
|
|
/// Must return [`TxStoreResponse::Transaction`]
|
|
Get(TxID),
|
|
/// Promote a transaction from the stem pool to the public pool.
|
|
///
|
|
/// If the tx is already in the fluff pool do nothing.
|
|
///
|
|
/// This should not error if the tx isn't in the pool at all.
|
|
Promote(TxID),
|
|
/// A request to check if a translation is in the pool.
|
|
///
|
|
/// Must return [`TxStoreResponse::Contains`]
|
|
Contains(TxID),
|
|
/// Returns the IDs of all the transaction in the stem pool.
|
|
///
|
|
/// Must return [`TxStoreResponse::IDs`]
|
|
IDsInStemPool,
|
|
}
|
|
|
|
#[cfg(feature = "txpool")]
|
|
/// A response sent back from the backing transaction pool.
|
|
pub enum TxStoreResponse<Tx, TxID> {
|
|
/// A generic ok response.
|
|
Ok,
|
|
/// A response containing a [`Option`] for if the transaction is in the pool (Some) or not (None) and in which pool
|
|
/// the tx is in.
|
|
Contains(Option<crate::State>),
|
|
/// A response containing a requested transaction.
|
|
Transaction(Option<(Tx, crate::State)>),
|
|
/// A list of transaction IDs.
|
|
IDs(Vec<TxID>),
|
|
}
|