mirror of
				https://github.com/0glabs/0g-storage-node.git
				synced 2025-11-04 00:27:39 +00:00 
			
		
		
		
	Use iterator to return padding data. (#197)
* Use iterator to return padding data. * Fix order.
This commit is contained in:
		
							parent
							
								
									a4dd88f2b8
								
							
						
					
					
						commit
						5c81abb79f
					
				@ -989,16 +989,16 @@ impl LogManager {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // FIXME(zz): Implement padding.
 | 
					    // FIXME(zz): Implement padding.
 | 
				
			||||||
    pub fn padding(len: usize) -> Vec<Vec<u8>> {
 | 
					    pub fn padding(len: usize) -> Box<dyn Iterator<Item = Vec<u8>>> {
 | 
				
			||||||
        let remainder = len % PAD_MAX_SIZE;
 | 
					        let remainder = len % PAD_MAX_SIZE;
 | 
				
			||||||
        let n = len / PAD_MAX_SIZE;
 | 
					        let n = len / PAD_MAX_SIZE;
 | 
				
			||||||
        let mut pad_data = vec![Self::padding_raw(PAD_MAX_SIZE); n];
 | 
					        let iter = (0..n).map(|_| Self::padding_raw(PAD_MAX_SIZE));
 | 
				
			||||||
        if remainder == 0 {
 | 
					        if remainder == 0 {
 | 
				
			||||||
            pad_data
 | 
					            Box::new(iter)
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            // insert the remainder to the front, so the rest are processed with alignment.
 | 
					            // insert the remainder to the front, so the rest are processed with alignment.
 | 
				
			||||||
            pad_data.insert(0, Self::padding_raw(remainder));
 | 
					            let new_iter = vec![Self::padding_raw(remainder)].into_iter().chain(iter);
 | 
				
			||||||
            pad_data
 | 
					            Box::new(new_iter)
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user