mirror of
https://github.com/hinto-janai/cuprate.git
synced 2024-11-16 15:58:14 +00:00
add DB fn signatures
This commit is contained in:
parent
cf3095446e
commit
02a99f3bb9
6 changed files with 98 additions and 10 deletions
|
@ -327,7 +327,7 @@ impl<D: Database + Clone + Send + 'static> ContextTask<D> {
|
|||
}
|
||||
BlockChainContextRequest::HardForkInfo(_)
|
||||
| BlockChainContextRequest::FeeEstimate { .. } => {
|
||||
todo!()
|
||||
todo!("finish https://github.com/Cuprate/cuprate/pull/297")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -415,7 +415,7 @@ impl<Z: BorshNetworkZone> Service<AddressBookRequest<Z>> for AddressBook<Z> {
|
|||
| AddressBookRequest::ConnectionCount
|
||||
| AddressBookRequest::SetBan(_)
|
||||
| AddressBookRequest::GetBan(_)
|
||||
| AddressBookRequest::GetBans => todo!(),
|
||||
| AddressBookRequest::GetBans => todo!("finish https://github.com/Cuprate/cuprate/pull/297"),
|
||||
};
|
||||
|
||||
ready(response)
|
||||
|
|
|
@ -132,7 +132,7 @@ impl<N: NetworkZone> Service<AddressBookRequest<N>> for DummyAddressBook {
|
|||
| AddressBookRequest::ConnectionCount
|
||||
| AddressBookRequest::SetBan(_)
|
||||
| AddressBookRequest::GetBan(_)
|
||||
| AddressBookRequest::GetBans => todo!(),
|
||||
| AddressBookRequest::GetBans => todo!("finish https://github.com/Cuprate/cuprate/pull/297"),
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
//! Database reader thread-pool definitions and logic.
|
||||
|
||||
#![expect(
|
||||
unreachable_code,
|
||||
unused_variables,
|
||||
clippy::unnecessary_wraps,
|
||||
reason = "TODO: finish implementing the signatures from <https://github.com/Cuprate/cuprate/pull/297>"
|
||||
)]
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Import
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
|
@ -107,12 +114,14 @@ fn map_request(
|
|||
R::CompactChainHistory => compact_chain_history(env),
|
||||
R::FindFirstUnknown(block_ids) => find_first_unknown(env, &block_ids),
|
||||
R::AltBlocksInChain(chain_id) => alt_blocks_in_chain(env, chain_id),
|
||||
R::TotalTxCount
|
||||
| R::DatabaseSize
|
||||
| R::Difficulty(_)
|
||||
| R::OutputHistogram
|
||||
| R::CoinbaseTxSum
|
||||
| R::MinerData => todo!(),
|
||||
R::Block(height) => block(env, height),
|
||||
R::BlockByHash(hash) => block_by_hash(env, hash),
|
||||
R::TotalTxCount => total_tx_count(env),
|
||||
R::DatabaseSize => database_size(env),
|
||||
R::Difficulty(height) => difficulty(env, height),
|
||||
R::OutputHistogram => output_histogram(env),
|
||||
R::CoinbaseTxSum => coinbase_tx_sum(env),
|
||||
R::MinerData => miner_data(env),
|
||||
}
|
||||
|
||||
/* SOMEDAY: post-request handling, run some code for each request? */
|
||||
|
@ -607,3 +616,46 @@ fn alt_blocks_in_chain(env: &ConcreteEnv, chain_id: ChainId) -> ResponseResult {
|
|||
|
||||
Ok(BlockchainResponse::AltBlocksInChain(blocks))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::Block`]
|
||||
fn block(env: &ConcreteEnv, block_height: BlockHeight) -> ResponseResult {
|
||||
Ok(BlockchainResponse::Block(todo!()))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::BlockByHash`]
|
||||
fn block_by_hash(env: &ConcreteEnv, block_hash: BlockHash) -> ResponseResult {
|
||||
Ok(BlockchainResponse::Block(todo!()))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::TotalTxCount`]
|
||||
fn total_tx_count(env: &ConcreteEnv) -> ResponseResult {
|
||||
Ok(BlockchainResponse::TotalTxCount(todo!()))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::DatabaseSize`]
|
||||
fn database_size(env: &ConcreteEnv) -> ResponseResult {
|
||||
Ok(BlockchainResponse::DatabaseSize {
|
||||
database_size: todo!(),
|
||||
free_space: todo!(),
|
||||
})
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::Difficulty()`]
|
||||
fn difficulty(env: &ConcreteEnv, block_height: BlockHeight) -> ResponseResult {
|
||||
Ok(BlockchainResponse::Difficulty(todo!()))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::OutputHistogram`]
|
||||
fn output_histogram(env: &ConcreteEnv) -> ResponseResult {
|
||||
Ok(BlockchainResponse::OutputHistogram(todo!()))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::CoinbaseTxSum`]
|
||||
fn coinbase_tx_sum(env: &ConcreteEnv) -> ResponseResult {
|
||||
Ok(BlockchainResponse::CoinbaseTxSum(todo!()))
|
||||
}
|
||||
|
||||
/// [`BlockchainReadRequest::MinerData`]
|
||||
fn miner_data(env: &ConcreteEnv) -> ResponseResult {
|
||||
Ok(BlockchainResponse::MinerData(todo!()))
|
||||
}
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
#![expect(
|
||||
unreachable_code,
|
||||
unused_variables,
|
||||
clippy::unnecessary_wraps,
|
||||
reason = "TODO: finish implementing the signatures from <https://github.com/Cuprate/cuprate/pull/297>"
|
||||
)]
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use rayon::ThreadPool;
|
||||
|
@ -58,7 +65,8 @@ fn map_request(
|
|||
match request {
|
||||
TxpoolReadRequest::TxBlob(tx_hash) => tx_blob(env, &tx_hash),
|
||||
TxpoolReadRequest::TxVerificationData(tx_hash) => tx_verification_data(env, &tx_hash),
|
||||
TxpoolReadRequest::Backlog | TxpoolReadRequest::Size => todo!(),
|
||||
TxpoolReadRequest::Backlog => backlog(env),
|
||||
TxpoolReadRequest::Size => size(env),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,3 +110,15 @@ fn tx_verification_data(env: &ConcreteEnv, tx_hash: &TransactionHash) -> ReadRes
|
|||
|
||||
get_transaction_verification_data(tx_hash, &tables).map(TxpoolReadResponse::TxVerificationData)
|
||||
}
|
||||
|
||||
/// [`TxpoolReadRequest::Backlog`].
|
||||
#[inline]
|
||||
fn backlog(env: &ConcreteEnv) -> ReadResponseResult {
|
||||
Ok(TxpoolReadResponse::Backlog(todo!()))
|
||||
}
|
||||
|
||||
/// [`TxpoolReadRequest::Size`].
|
||||
#[inline]
|
||||
fn size(env: &ConcreteEnv) -> ReadResponseResult {
|
||||
Ok(TxpoolReadResponse::Size(todo!()))
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ use std::{
|
|||
ops::Range,
|
||||
};
|
||||
|
||||
use monero_serai::block::Block;
|
||||
|
||||
use crate::{
|
||||
types::{Chain, ExtendedBlockHeader, OutputOnChain, VerifiedBlockInformation},
|
||||
AltBlockInformation, ChainId,
|
||||
|
@ -104,6 +106,12 @@ pub enum BlockchainReadRequest {
|
|||
/// A request for all alt blocks in the chain with the given [`ChainId`].
|
||||
AltBlocksInChain(ChainId),
|
||||
|
||||
/// TODO
|
||||
Block(usize),
|
||||
|
||||
/// TODO
|
||||
BlockByHash([u8; 32]),
|
||||
|
||||
/// TODO
|
||||
TotalTxCount,
|
||||
|
||||
|
@ -165,6 +173,7 @@ pub enum BlockchainWriteRequest {
|
|||
/// This pairs with [`BlockchainReadRequest`] and [`BlockchainWriteRequest`],
|
||||
/// see those two for more info.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[expect(clippy::large_enum_variant)]
|
||||
pub enum BlockchainResponse {
|
||||
//------------------------------------------------------ Reads
|
||||
/// Response to [`BlockchainReadRequest::BlockExtendedHeader`].
|
||||
|
@ -245,6 +254,13 @@ pub enum BlockchainResponse {
|
|||
/// Contains all the alt blocks in the alt-chain in chronological order.
|
||||
AltBlocksInChain(Vec<AltBlockInformation>),
|
||||
|
||||
/// The response for:
|
||||
/// - [`BlockchainReadRequest::Block`].
|
||||
/// - [`BlockchainReadRequest::BlockByHash`].
|
||||
///
|
||||
/// TODO
|
||||
Block(Block),
|
||||
|
||||
/// The response for [`BlockchainReadRequest::TotalTxCount`].
|
||||
///
|
||||
/// TODO
|
||||
|
|
Loading…
Reference in a new issue