Edgecase for res list (#109)

* Super quick hotfix to token cli

* Account for edgecase in res list when you for some reason overwrite yourself

* Another fix, keeping track of population.
This commit is contained in:
Jordan Prince 2021-07-02 22:13:03 -05:00 committed by GitHub
parent ecb99be7c8
commit 42a8d1d309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -269,6 +269,14 @@ impl ReservationList for ReservationListV2 {
&& self.reservations[usize_offset].address == replaced.address;
if !allowable_edgecase {
return Err(MetadataError::TriedToReplaceAnExistingReservation.into());
} else {
// Since we will have incremented, decrease in advance so we dont blow the spot check.
// Super hacky but this code is to be deprecated.
self.set_current_reservation_spots(
self.current_reservation_spots
.checked_sub(replaced.total_spots)
.ok_or(MetadataError::NumericalOverflowError)?,
);
}
}
} else {