use parking_lot::Mutex; use types::SignedBeaconBlockHeader; #[derive(Debug, Default)] pub struct BlockQueue { blocks: Mutex>, } impl BlockQueue { pub fn queue(&self, block_header: SignedBeaconBlockHeader) { self.blocks.lock().push(block_header) } pub fn dequeue(&self) -> Vec { let mut blocks = self.blocks.lock(); std::mem::replace(&mut *blocks, vec![]) } pub fn len(&self) -> usize { self.blocks.lock().len() } pub fn is_empty(&self) -> bool { self.len() == 0 } }