https://libro.blockdeep.dev/critical/Avoid_Unbounded_Iteration.html
The example here isn't that great:
const MAX_ITEMS: usize = 20;
#[pallet::storage]
pub type UnboundedData<T: Config> = StorageValue<_, Vec<u32>;
let big_data = UnboundedData::<T>::get();
for item in big_data.iter().take(MAX_ITEMS) {
// Process a limited number of items safely
}
In this example, you are reading an unbounded storage item which itself is bad practice.
The better example here would perhaps be an imput to the extrinsic from the user, which is a Vec, and ensuring the length of the vec is within some limit.
https://libro.blockdeep.dev/critical/Avoid_Unbounded_Iteration.html
The example here isn't that great:
In this example, you are reading an unbounded storage item which itself is bad practice.
The better example here would perhaps be an imput to the extrinsic from the user, which is a Vec, and ensuring the length of the vec is within some limit.