mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 08:08:15 -05:00
feat(chain-state): notify about new safe/finalized only if modified (#11383)
This commit is contained in:
@@ -112,15 +112,25 @@ impl ChainInfoTracker {
|
||||
|
||||
/// Sets the safe header of the chain.
|
||||
pub fn set_safe(&self, header: SealedHeader) {
|
||||
self.inner.safe_block.send_modify(|h| {
|
||||
let _ = h.replace(header);
|
||||
self.inner.safe_block.send_if_modified(|current_header| {
|
||||
if current_header.as_ref().map(SealedHeader::hash) != Some(header.hash()) {
|
||||
let _ = current_header.replace(header);
|
||||
return true
|
||||
}
|
||||
|
||||
false
|
||||
});
|
||||
}
|
||||
|
||||
/// Sets the finalized header of the chain.
|
||||
pub fn set_finalized(&self, header: SealedHeader) {
|
||||
self.inner.finalized_block.send_modify(|h| {
|
||||
let _ = h.replace(header);
|
||||
self.inner.finalized_block.send_if_modified(|current_header| {
|
||||
if current_header.as_ref().map(SealedHeader::hash) != Some(header.hash()) {
|
||||
let _ = current_header.replace(header);
|
||||
return true
|
||||
}
|
||||
|
||||
false
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user