change(state): Restrict access to types for database writes (#7440)

* Restrict access to types for database writes

* Don't re-export `DiskWriteBatch`
This commit is contained in:
Marek 2023-09-05 21:07:23 +02:00 committed by GitHub
parent cc2dbe32da
commit a1cf61a6ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 7 deletions

View File

@ -66,7 +66,7 @@ pub use response::GetBlockTemplateChainInfo;
pub use service::{
arbitrary::{populated_state, CHAIN_TIP_UPDATE_WAIT_LIMIT},
chain_tip::{ChainTipBlock, ChainTipSender},
finalized_state::{DiskWriteBatch, WriteDisk, MAX_ON_DISK_HEIGHT},
finalized_state::MAX_ON_DISK_HEIGHT,
init_test, init_test_services, ReadStateService,
};

View File

@ -42,10 +42,7 @@ pub use disk_format::{OutputIndex, OutputLocation, TransactionLocation, MAX_ON_D
pub(super) use zebra_db::ZebraDb;
#[cfg(not(any(test, feature = "proptest-impl")))]
pub(super) use disk_db::DiskWriteBatch;
#[cfg(any(test, feature = "proptest-impl"))]
pub use disk_db::{DiskWriteBatch, WriteDisk};
use disk_db::DiskWriteBatch;
/// The finalized part of the chain state, stored in the db.
///

View File

@ -95,7 +95,7 @@ pub struct DiskDb {
// and make them accessible via read-only methods
#[must_use = "batches must be written to the database"]
#[derive(Default)]
pub struct DiskWriteBatch {
pub(crate) struct DiskWriteBatch {
/// The inner RocksDB write batch.
batch: rocksdb::WriteBatch,
}
@ -605,7 +605,7 @@ impl DiskDb {
// Low-level write methods are located in the WriteDisk trait
/// Writes `batch` to the database.
pub fn write(&self, batch: DiskWriteBatch) -> Result<(), rocksdb::Error> {
pub(crate) fn write(&self, batch: DiskWriteBatch) -> Result<(), rocksdb::Error> {
self.db.write(batch.batch)
}