Cleanup redundant AsFixedBytes and FixedLength traits (#3131)
* no need for AsFixedBytes we can just use AsRef<[u8]> * cleanup FixedLength trait * revert this change for now * fix store tests * cleanup and fix tests after rebase * fix tests * update based on PR review less hard-coded values now * cleanup
This commit is contained in:
@@ -179,7 +179,6 @@ impl Chain {
|
||||
"header",
|
||||
"header_head",
|
||||
false,
|
||||
true,
|
||||
ProtocolVersion(1),
|
||||
None,
|
||||
)?;
|
||||
@@ -188,7 +187,6 @@ impl Chain {
|
||||
"header",
|
||||
"sync_head",
|
||||
false,
|
||||
true,
|
||||
ProtocolVersion(1),
|
||||
None,
|
||||
)?;
|
||||
|
||||
@@ -20,7 +20,7 @@ use croaring::Bitmap;
|
||||
|
||||
use crate::core::core::hash::{DefaultHashable, Hash};
|
||||
use crate::core::core::pmmr::{self, ReadonlyPMMR, VecBackend, PMMR};
|
||||
use crate::core::ser::{self, FixedLength, PMMRable, Readable, Reader, Writeable, Writer};
|
||||
use crate::core::ser::{self, PMMRable, Readable, Reader, Writeable, Writer};
|
||||
use crate::error::{Error, ErrorKind};
|
||||
|
||||
/// The "bitmap accumulator" allows us to commit to a specific bitmap by splitting it into
|
||||
@@ -215,10 +215,10 @@ impl PMMRable for BitmapChunk {
|
||||
fn as_elmt(&self) -> Self::E {
|
||||
self.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl FixedLength for BitmapChunk {
|
||||
const LEN: usize = Self::LEN_BYTES;
|
||||
fn elmt_size() -> Option<u16> {
|
||||
Some(Self::LEN_BYTES as u16)
|
||||
}
|
||||
}
|
||||
|
||||
impl DefaultHashable for BitmapChunk {}
|
||||
|
||||
@@ -60,7 +60,6 @@ impl<T: PMMRable> PMMRHandle<T> {
|
||||
sub_dir: &str,
|
||||
file_name: &str,
|
||||
prunable: bool,
|
||||
fixed_size: bool,
|
||||
version: ProtocolVersion,
|
||||
header: Option<&BlockHeader>,
|
||||
) -> Result<PMMRHandle<T>, Error> {
|
||||
@@ -69,8 +68,7 @@ impl<T: PMMRable> PMMRHandle<T> {
|
||||
let path_str = path.to_str().ok_or(Error::from(ErrorKind::Other(
|
||||
"invalid file path".to_owned(),
|
||||
)))?;
|
||||
let backend =
|
||||
PMMRBackend::new(path_str.to_string(), prunable, fixed_size, version, header)?;
|
||||
let backend = PMMRBackend::new(path_str.to_string(), prunable, version, header)?;
|
||||
let last_pos = backend.unpruned_size();
|
||||
Ok(PMMRHandle { backend, last_pos })
|
||||
}
|
||||
@@ -136,7 +134,6 @@ impl TxHashSet {
|
||||
TXHASHSET_SUBDIR,
|
||||
OUTPUT_SUBDIR,
|
||||
true,
|
||||
true,
|
||||
ProtocolVersion(1),
|
||||
header,
|
||||
)?;
|
||||
@@ -146,7 +143,6 @@ impl TxHashSet {
|
||||
TXHASHSET_SUBDIR,
|
||||
RANGE_PROOF_SUBDIR,
|
||||
true,
|
||||
true,
|
||||
ProtocolVersion(1),
|
||||
header,
|
||||
)?;
|
||||
@@ -162,7 +158,6 @@ impl TxHashSet {
|
||||
TXHASHSET_SUBDIR,
|
||||
KERNEL_SUBDIR,
|
||||
false, // not prunable
|
||||
false, // variable size kernel data file
|
||||
version,
|
||||
None,
|
||||
)?;
|
||||
|
||||
Reference in New Issue
Block a user