Merge pull request #190 from blockworks-foundation/use_counting_semaphore_to_poll_blocks
Use counting semaphore to poll blocks
This commit is contained in:
commit
88cef0edf6
|
@ -179,6 +179,11 @@ pub fn poll_block(
|
|||
.await
|
||||
.context("Slot notification channel close")?;
|
||||
let last_processed_slot = current_slot.load(std::sync::atomic::Ordering::Relaxed);
|
||||
let last_processed_slot = if last_processed_slot == 0 {
|
||||
last_processed_slot.saturating_sub(1)
|
||||
} else {
|
||||
last_processed_slot
|
||||
};
|
||||
if processed_slot > last_processed_slot {
|
||||
current_slot.store(processed_slot, std::sync::atomic::Ordering::Relaxed);
|
||||
|
||||
|
|
|
@ -84,13 +84,14 @@ pub fn poll_slots(
|
|||
// this is because it may be a slot block
|
||||
if estimated_slot < current_slot + 32 {
|
||||
estimated_slot += 1;
|
||||
|
||||
sender
|
||||
.send(SlotNotification {
|
||||
processed_slot: current_slot,
|
||||
estimated_processed_slot: estimated_slot,
|
||||
})
|
||||
.context("Connot send slot notification")?;
|
||||
}
|
||||
sender
|
||||
.send(SlotNotification {
|
||||
processed_slot: current_slot,
|
||||
estimated_processed_slot: estimated_slot,
|
||||
})
|
||||
.context("Connot send slot notification")?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue