diff --git a/binaries/cuprated/src/rpc/blockchain.rs b/binaries/cuprated/src/rpc/blockchain.rs index 2c7ade4..f49065e 100644 --- a/binaries/cuprated/src/rpc/blockchain.rs +++ b/binaries/cuprated/src/rpc/blockchain.rs @@ -175,19 +175,15 @@ pub(super) async fn pop_blocks( state: &mut CupratedRpcHandlerState, nblocks: u64, ) -> Result { - // TODO: we need access to `BlockchainWriteHandle` - - // let BlockchainResponse::PopBlocks(height) = state - // .blockchain_write - // .ready() - // .await? - // .call(BlockchainWriteRequest::PopBlocks(nblocks)) - // .await? - // else { - // unreachable!(); - // }; - - let height = todo!(); + let BlockchainResponse::PopBlocks(height) = state + .blockchain_write + .ready() + .await? + .call(BlockchainWriteRequest::PopBlocks(nblocks)) + .await? + else { + unreachable!(); + }; Ok(usize_to_u64(height)) } diff --git a/binaries/cuprated/src/rpc/handler.rs b/binaries/cuprated/src/rpc/handler.rs index d505448..7c8c7eb 100644 --- a/binaries/cuprated/src/rpc/handler.rs +++ b/binaries/cuprated/src/rpc/handler.rs @@ -40,12 +40,14 @@ pub struct CupratedRpcHandlerState { /// Read handle to the blockchain database. pub blockchain_read: BlockchainReadHandle, - // /// Write handle to the blockchain database. - // pub blockchain_write: BlockchainWriteHandle, + /// Write handle to the blockchain database. + pub blockchain_write: BlockchainWriteHandle, + /// Read handle to the transaction pool database. pub txpool_read: TxpoolReadHandle, - // /// Write handle to the transaction pool database. - // pub txpool_write: TxpoolWriteHandle, + + /// Write handle to the transaction pool database. + pub txpool_write: TxpoolWriteHandle, } impl CupratedRpcHandler { diff --git a/storage/blockchain/src/service/mod.rs b/storage/blockchain/src/service/mod.rs index c774ee4..12357f3 100644 --- a/storage/blockchain/src/service/mod.rs +++ b/storage/blockchain/src/service/mod.rs @@ -21,10 +21,6 @@ //! //! The 2nd allows any caller to send [`WriteRequest`][req_w]s. //! -//! The `DatabaseReadHandle` can be shared as it is cheaply [`Clone`]able, however, -//! the `DatabaseWriteHandle` cannot be cloned. There is only 1 place in Cuprate that -//! writes, so it is passed there and used. -//! //! ## Initialization //! The database & thread-pool system can be initialized with [`init()`]. //! diff --git a/storage/service/src/service/write.rs b/storage/service/src/service/write.rs index f75d615..3914f22 100644 --- a/storage/service/src/service/write.rs +++ b/storage/service/src/service/write.rs @@ -21,7 +21,7 @@ const WRITER_THREAD_NAME: &str = concat!(module_path!(), "::DatabaseWriter"); /// Calling [`tower::Service::call`] with a [`DatabaseWriteHandle`] /// will return an `async`hronous channel that can be `.await`ed upon /// to receive the corresponding response. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct DatabaseWriteHandle { /// Sender channel to the database write thread-pool. /// diff --git a/storage/txpool/src/service/interface.rs b/storage/txpool/src/service/interface.rs index 93235c0..1708939 100644 --- a/storage/txpool/src/service/interface.rs +++ b/storage/txpool/src/service/interface.rs @@ -19,6 +19,7 @@ pub enum TxpoolReadRequest { //---------------------------------------------------------------------------------------------------- TxpoolReadResponse /// The transaction pool [`tower::Service`] read response type. #[allow(clippy::large_enum_variant)] +#[derive(Debug)] pub enum TxpoolReadResponse { /// A response containing the raw bytes of a transaction. // TODO: use bytes::Bytes. @@ -29,6 +30,7 @@ pub enum TxpoolReadResponse { //---------------------------------------------------------------------------------------------------- TxpoolWriteRequest /// The transaction pool [`tower::Service`] write request type. +#[derive(Debug, Clone)] pub enum TxpoolWriteRequest { /// Add a transaction to the pool. /// @@ -49,7 +51,7 @@ pub enum TxpoolWriteRequest { //---------------------------------------------------------------------------------------------------- TxpoolWriteResponse /// The transaction pool [`tower::Service`] write response type. -#[derive(Debug, Ord, PartialOrd, Eq, PartialEq)] +#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)] pub enum TxpoolWriteResponse { /// A [`TxpoolWriteRequest::AddTransaction`] response. ///