Skip to content

Commit 3b7bc95

Browse files
committed
add error when processing non-paged exposures
1 parent 1a39de4 commit 3b7bc95

File tree

1 file changed

+4
-4
lines changed
  • substrate/frame/staking/src

1 file changed

+4
-4
lines changed

substrate/frame/staking/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -758,10 +758,10 @@ impl<
758758
> PagedExposure<AccountId, Balance, MaxExposurePageSize>
759759
{
760760
/// Create a new instance of `PagedExposure` from legacy clipped exposures (now removed).
761-
pub fn from_clipped(exposure: Exposure<AccountId, Balance>) -> Result<Self, ()> {
762-
let old_exposures = exposure.others.len();
763-
let others = WeakBoundedVec::try_from(exposure.others).unwrap_or_default();
764-
defensive_assert!(old_exposures == others.len(), "Too many exposures for a page");
761+
pub fn from_clipped(exposure: Exposure<AccountId, Balance>) -> Result<Self, &'static str> {
762+
let Ok(others) = WeakBoundedVec::try_from(exposure.others) else {
763+
return Err("Too many exposures for a page");
764+
};
765765
Ok(Self {
766766
exposure_metadata: PagedExposureMetadata {
767767
total: exposure.total,

0 commit comments

Comments
 (0)