mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-11 05:15:24 +00:00
prune
This commit is contained in:
parent
a10ed59201
commit
d7d8b3509e
3 changed files with 20 additions and 10 deletions
|
@ -4,6 +4,7 @@ use std::task::{Context, Poll};
|
|||
|
||||
use anyhow::Error;
|
||||
use cuprate_consensus::BlockChainContextService;
|
||||
use cuprate_pruning::PruningSeed;
|
||||
use futures::future::BoxFuture;
|
||||
use monero_serai::block::Block;
|
||||
use tower::Service;
|
||||
|
@ -70,6 +71,9 @@ pub enum BlockchainManagerResponse {
|
|||
/// Response to [`BlockchainManagerRequest::PopBlocks`]
|
||||
PopBlocks { new_height: usize },
|
||||
|
||||
/// Response to [`BlockchainManagerRequest::Prune`]
|
||||
Prune(PruningSeed),
|
||||
|
||||
/// Response to [`BlockchainManagerRequest::Pruned`]
|
||||
Pruned(bool),
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ use std::{
|
|||
|
||||
use anyhow::{anyhow, Error};
|
||||
use cuprate_p2p_core::{client::handshaker::builder::DummyAddressBook, ClearNet};
|
||||
use cuprate_types::HardFork;
|
||||
use monero_serai::block::Block;
|
||||
use tower::{Service, ServiceExt};
|
||||
|
||||
|
@ -44,15 +43,14 @@ use cuprate_rpc_types::{
|
|||
misc::{BlockHeader, ChainInfo, GetBan, HardforkEntry, HistogramEntry, Status, TxBacklogEntry},
|
||||
CORE_RPC_VERSION,
|
||||
};
|
||||
use cuprate_types::HardFork;
|
||||
|
||||
use crate::rpc::{
|
||||
helper,
|
||||
request::{address_book, blockchain, blockchain_context, blockchain_manager},
|
||||
request::{address_book, blockchain, blockchain_context, blockchain_manager, txpool},
|
||||
CupratedRpcHandler,
|
||||
};
|
||||
|
||||
use super::request::txpool;
|
||||
|
||||
/// Map a [`JsonRpcRequest`] to the function that will lead to a [`JsonRpcResponse`].
|
||||
pub(super) async fn map_request(
|
||||
state: CupratedRpcHandler,
|
||||
|
@ -719,13 +717,18 @@ async fn get_miner_data(
|
|||
|
||||
/// <https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server.cpp#L3453-L3476>
|
||||
async fn prune_blockchain(
|
||||
state: CupratedRpcHandler,
|
||||
mut state: CupratedRpcHandler,
|
||||
request: PruneBlockchainRequest,
|
||||
) -> Result<PruneBlockchainResponse, Error> {
|
||||
let pruned = blockchain_manager::pruned(&mut state.blockchain_manager).await?;
|
||||
let pruning_seed = blockchain_manager::prune(&mut state.blockchain_manager)
|
||||
.await?
|
||||
.compress();
|
||||
|
||||
Ok(PruneBlockchainResponse {
|
||||
base: ResponseBase::OK,
|
||||
pruned: todo!(),
|
||||
pruning_seed: todo!(),
|
||||
pruned,
|
||||
pruning_seed,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ use monero_serai::block::Block;
|
|||
use tower::{Service, ServiceExt};
|
||||
|
||||
use cuprate_helper::cast::{u64_to_usize, usize_to_u64};
|
||||
use cuprate_pruning::PruningSeed;
|
||||
|
||||
use crate::rpc::handler::{
|
||||
BlockchainManagerHandle, BlockchainManagerRequest, BlockchainManagerResponse,
|
||||
|
@ -30,8 +31,10 @@ pub(crate) async fn pop_blocks(
|
|||
}
|
||||
|
||||
/// [`BlockchainManagerRequest::Prune`]
|
||||
pub(crate) async fn prune(blockchain_manager: &mut BlockchainManagerHandle) -> Result<(), Error> {
|
||||
let BlockchainManagerResponse::Ok = blockchain_manager
|
||||
pub(crate) async fn prune(
|
||||
blockchain_manager: &mut BlockchainManagerHandle,
|
||||
) -> Result<PruningSeed, Error> {
|
||||
let BlockchainManagerResponse::Prune(seed) = blockchain_manager
|
||||
.ready()
|
||||
.await?
|
||||
.call(BlockchainManagerRequest::Prune)
|
||||
|
@ -40,7 +43,7 @@ pub(crate) async fn prune(blockchain_manager: &mut BlockchainManagerHandle) -> R
|
|||
unreachable!();
|
||||
};
|
||||
|
||||
Ok(())
|
||||
Ok(seed)
|
||||
}
|
||||
|
||||
/// [`BlockchainManagerRequest::Pruned`]
|
||||
|
|
Loading…
Reference in a new issue