mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-12-23 03:59:37 +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 cuprate_helper::cast::usize_to_u64;
|
||||
use cuprate_txpool::service::{
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||
TxpoolReadHandle,
|
||||
use cuprate_txpool::{
|
||||
service::{
|
||||
interface::{TxpoolReadRequest, TxpoolReadResponse},
|
||||
TxpoolReadHandle,
|
||||
},
|
||||
TxEntry,
|
||||
};
|
||||
|
||||
/// [`TxpoolReadRequest::Backlog`]
|
||||
pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<Infallible>, Error> {
|
||||
let TxpoolReadResponse::Backlog(backlog) = txpool_read
|
||||
pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<TxEntry>, Error> {
|
||||
let TxpoolReadResponse::Backlog(tx_entries) = txpool_read
|
||||
.ready()
|
||||
.await
|
||||
.expect("TODO")
|
||||
|
@ -24,7 +27,7 @@ pub(super) async fn backlog(txpool_read: &mut TxpoolReadHandle) -> Result<Vec<In
|
|||
unreachable!();
|
||||
};
|
||||
|
||||
Ok(backlog)
|
||||
Ok(tx_entries)
|
||||
}
|
||||
|
||||
/// [`TxpoolReadRequest::Size`]
|
||||
|
|
|
@ -10,10 +10,12 @@ pub mod ops;
|
|||
#[cfg(feature = "service")]
|
||||
pub mod service;
|
||||
pub mod tables;
|
||||
mod tx;
|
||||
pub mod types;
|
||||
|
||||
pub use config::Config;
|
||||
pub use free::open;
|
||||
pub use tx::TxEntry;
|
||||
|
||||
//re-exports
|
||||
pub use cuprate_database;
|
||||
|
|
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
|||
|
||||
use cuprate_types::TransactionVerificationData;
|
||||
|
||||
use crate::types::TransactionHash;
|
||||
use crate::{tx::TxEntry, types::TransactionHash};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- TxpoolReadRequest
|
||||
/// 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.
|
||||
TxVerificationData(TransactionHash),
|
||||
|
||||
/// TODO
|
||||
/// Get information on all transactions in the pool.
|
||||
Backlog,
|
||||
|
||||
/// TODO
|
||||
/// Get the number of transactions in the pool.
|
||||
Size,
|
||||
}
|
||||
|
||||
|
@ -38,12 +38,14 @@ pub enum TxpoolReadResponse {
|
|||
|
||||
/// Response to [`TxpoolReadRequest::Backlog`].
|
||||
///
|
||||
/// TODO
|
||||
Backlog(Vec<std::convert::Infallible>),
|
||||
/// The inner `Vec` contains information on all
|
||||
/// the transactions currently in the pool.
|
||||
Backlog(Vec<TxEntry>),
|
||||
|
||||
/// Response to [`TxpoolReadRequest::Size`].
|
||||
///
|
||||
/// TODO
|
||||
/// The inner value is the amount of
|
||||
/// transactions currently in the pool.
|
||||
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