File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -426,6 +426,10 @@ impl<T: Config> Pallet<T> {
426426 pub fn can_commit ( netuid : u16 , who : & T :: AccountId ) -> bool {
427427 if let Some ( ( _hash, commit_block) ) = WeightCommits :: < T > :: get ( netuid, who) {
428428 let interval: u64 = Self :: get_weight_commit_interval ( ) ;
429+ if interval == 0 {
430+ return true ; //prevent division by 0
431+ }
432+
429433 let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
430434 let interval_start: u64 = current_block - ( current_block % interval) ;
431435 let last_commit_interval_start: u64 = commit_block - ( commit_block % interval) ;
@@ -445,6 +449,10 @@ impl<T: Config> Pallet<T> {
445449
446450 pub fn is_reveal_block_range ( commit_block : u64 ) -> bool {
447451 let interval: u64 = Self :: get_weight_commit_interval ( ) ;
452+ if interval == 0 {
453+ return true ; //prevent division by 0
454+ }
455+
448456 let commit_interval_start: u64 = commit_block - ( commit_block % interval) ; // Find the start of the interval in which the commit occurred
449457 let reveal_interval_start: u64 = commit_interval_start + interval; // Start of the next interval after the commit interval
450458 let current_block: u64 = Self :: get_current_block_as_u64 ( ) ;
You can’t perform that action at this time.
0 commit comments