Skip to content

Commit e8dc72f

Browse files
apply cr
1 parent 10c96ed commit e8dc72f

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

fvm/src/blockstore/buffered.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,8 @@ pub enum FlushError {
7272
Io(#[from] std::io::Error),
7373
#[error("cid: {0}")]
7474
Cid(#[from] cid::Error),
75-
#[error("cbor input was not canonical (lval 24 with value < 24)")]
76-
HeaderLval24,
77-
#[error("cbor input was not canonical (lval 25 with value <= MaxUint8)")]
78-
HeaderLval25,
79-
#[error("cbor input was not canonical (lval 26 with value <= MaxUint16)")]
80-
HeaderLval26,
81-
#[error("cbor input was not canonical (lval 27 with value <= MaxUint32)")]
82-
HeaderLval27,
75+
#[error("cbor input was not canonical (lval {0} with value < {1})")]
76+
HeaderNotCanonical(usize, &'static str),
8377
#[error("invalid header cbor_read_header_buf")]
8478
HeaderInvalid,
8579
#[error("expected cbor type byte string in input")]
@@ -112,28 +106,28 @@ fn cbor_read_header_buf<B: Read>(
112106
} else if low == 24 {
113107
let val = br.read_u8()?;
114108
if val < 24 {
115-
return Err(FlushError::HeaderLval24);
109+
return Err(FlushError::HeaderNotCanonical(24, "24"));
116110
}
117111
Ok((maj, val as usize))
118112
} else if low == 25 {
119113
br.read_exact(&mut scratch[..2])?;
120114
let val = BigEndian::read_u16(&scratch[..2]);
121115
if val <= u8::MAX as u16 {
122-
return Err(FlushError::HeaderLval25);
116+
return Err(FlushError::HeaderNotCanonical(25, "MaxUint8"));
123117
}
124118
Ok((maj, val as usize))
125119
} else if low == 26 {
126120
br.read_exact(&mut scratch[..4])?;
127121
let val = BigEndian::read_u32(&scratch[..4]);
128122
if val <= u16::MAX as u32 {
129-
return Err(FlushError::HeaderLval26);
123+
return Err(FlushError::HeaderNotCanonical(26, "MaxUint16"));
130124
}
131125
Ok((maj, val as usize))
132126
} else if low == 27 {
133127
br.read_exact(&mut scratch[..8])?;
134128
let val = BigEndian::read_u64(&scratch[..8]);
135129
if val <= u32::MAX as u64 {
136-
return Err(FlushError::HeaderLval27);
130+
return Err(FlushError::HeaderNotCanonical(27, "MaxUint32"));
137131
}
138132
Ok((maj, val as usize))
139133
} else {

ipld/amt/src/amt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ where
254254
for i in sorted(iter) {
255255
let found = self.delete(i)?.is_none();
256256
if strict && found {
257-
return Err(Error::BatchDelteNotFound(i));
257+
return Err(Error::BatchDeleteNotFound(i));
258258
}
259259
modified |= found;
260260
}

ipld/amt/src/error.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub enum Error<E> {
2626
#[error("{0}")]
2727
CollapsedNode(#[from] CollapsedNodeError),
2828
#[error("no such index {0} in Amt for batch delete")]
29-
BatchDelteNotFound(u64),
29+
BatchDeleteNotFound(u64),
3030
#[error("blockstore {0}")]
3131
Blockstore(E),
3232
#[error("encoding error {0}")]
@@ -42,17 +42,19 @@ impl<E> From<CborStoreError<E>> for Error<E> {
4242
}
4343
}
4444

45+
/// This error wraps around around two different errors, either the native `Error` from `amt`, or
46+
/// a custom user error, returned from executing a user defined function.
4547
#[derive(Debug, Error)]
4648
pub enum EitherError<U, E> {
4749
#[error("user: {0}")]
4850
User(U),
49-
#[error("hamt: {0}")]
50-
Hamt(#[from] Error<E>),
51+
#[error("amt: {0}")]
52+
Amt(#[from] Error<E>),
5153
}
5254

5355
impl<U, E> From<CborStoreError<E>> for EitherError<U, E> {
5456
fn from(err: CborStoreError<E>) -> Self {
55-
EitherError::Hamt(err.into())
57+
EitherError::Amt(err.into())
5658
}
5759
}
5860

ipld/hamt/src/error.rs

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ impl<E> From<CborStoreError<E>> for Error<E> {
3030
}
3131
}
3232

33+
/// This error wraps around around two different errors, either the native `Error` from `hamt`, or
34+
/// a custom user error, returned from executing a user defined function.
3335
#[derive(Debug, Error)]
3436
pub enum EitherError<U, E> {
3537
#[error("user: {0}")]

0 commit comments

Comments
 (0)