mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-10 12:54:44 +00:00
txpool docs/types
This commit is contained in:
parent
41f4b788b3
commit
cf331885b6
4 changed files with 33 additions and 12 deletions
|
@ -6,14 +6,17 @@ use anyhow::Error;
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
|
||||||
use cuprate_helper::cast::usize_to_u64;
|
use cuprate_helper::cast::usize_to_u64;
|
||||||
use cuprate_txpool::service::{
|
use cuprate_txpool::{
|
||||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
service::{
|
||||||
TxpoolReadHandle,
|
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||||
|
TxpoolReadHandle,
|
||||||
|
},
|
||||||
|
TxEntry,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// [`TxpoolReadRequest::Backlog`]
|
/// [`TxpoolReadRequest::Backlog`]
|
||||||
pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<Infallible>, Error> {
|
pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<TxEntry>, Error> {
|
||||||
let TxpoolReadResponse::Backlog(backlog) = txpool_read
|
let TxpoolReadResponse::Backlog(tx_entries) = txpool_read
|
||||||
.ready()
|
.ready()
|
||||||
.await
|
.await
|
||||||
.expect("TODO")
|
.expect("TODO")
|
||||||
|
@ -24,7 +27,7 @@ pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<In
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(backlog)
|
Ok(tx_entries)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// [`TxpoolReadRequest::Size`]
|
/// [`TxpoolReadRequest::Size`]
|
||||||
|
|
|
@ -10,10 +10,12 @@ pub mod ops;
|
||||||
#[cfg(feature = "service")]
|
#[cfg(feature = "service")]
|
||||||
pub mod service;
|
pub mod service;
|
||||||
pub mod tables;
|
pub mod tables;
|
||||||
|
mod tx;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|
||||||
pub use config::Config;
|
pub use config::Config;
|
||||||
pub use free::open;
|
pub use free::open;
|
||||||
|
pub use tx::TxEntry;
|
||||||
|
|
||||||
//re-exports
|
//re-exports
|
||||||
pub use cuprate_database;
|
pub use cuprate_database;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use cuprate_types::TransactionVerificationData;
|
use cuprate_types::TransactionVerificationData;
|
||||||
|
|
||||||
use crate::types::TransactionHash;
|
use crate::{tx::TxEntry, types::TransactionHash};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- TxpoolReadRequest
|
//---------------------------------------------------------------------------------------------------- TxpoolReadRequest
|
||||||
/// The transaction pool [`tower::Service`] read request type.
|
/// The transaction pool [`tower::Service`] read request type.
|
||||||
|
@ -16,10 +16,10 @@ pub enum TxpoolReadRequest {
|
||||||
/// A request for the [`TransactionVerificationData`] of a transaction in the tx pool.
|
/// A request for the [`TransactionVerificationData`] of a transaction in the tx pool.
|
||||||
TxVerificationData(TransactionHash),
|
TxVerificationData(TransactionHash),
|
||||||
|
|
||||||
/// TODO
|
/// Get information on all transactions in the pool.
|
||||||
Backlog,
|
Backlog,
|
||||||
|
|
||||||
/// TODO
|
/// Get the number of transactions in the pool.
|
||||||
Size,
|
Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,12 +38,14 @@ pub enum TxpoolReadResponse {
|
||||||
|
|
||||||
/// Response to [`TxpoolReadRequest::Backlog`].
|
/// Response to [`TxpoolReadRequest::Backlog`].
|
||||||
///
|
///
|
||||||
/// TODO
|
/// The inner `Vec` contains information on all
|
||||||
Backlog(Vec<std::convert::Infallible>),
|
/// the transactions currently in the pool.
|
||||||
|
Backlog(Vec<TxEntry>),
|
||||||
|
|
||||||
/// Response to [`TxpoolReadRequest::Size`].
|
/// Response to [`TxpoolReadRequest::Size`].
|
||||||
///
|
///
|
||||||
/// TODO
|
/// The inner value is the amount of
|
||||||
|
/// transactions currently in the pool.
|
||||||
Size(usize),
|
Size(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
storage/txpool/src/tx.rs
Normal file
14
storage/txpool/src/tx.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
//! Transaction metadata.
|
||||||
|
|
||||||
|
/// Data about a transaction in the pool.
|
||||||
|
///
|
||||||
|
/// Used in [`TxpoolReadResponse::Backlog`](crate::service::interface::TxpoolReadResponse::Backlog).
|
||||||
|
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq, Hash)]
|
||||||
|
pub struct TxEntry {
|
||||||
|
/// The transaction's weight.
|
||||||
|
pub weight: u64,
|
||||||
|
/// The transaction's fee.
|
||||||
|
pub fee: u64,
|
||||||
|
/// How long the transaction has been in the pool.
|
||||||
|
pub time_in_pool: std::time::Duration,
|
||||||
|
}
|
Loading…
Reference in a new issue