We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 191c335 commit 3e99307Copy full SHA for 3e99307
lightning-block-sync/src/gossip.rs
@@ -167,10 +167,18 @@ impl<S: FutureSpawner,
167
process_block!(block);
168
{
169
let mut recent_blocks = block_cache.lock().unwrap();
170
- if recent_blocks.len() >= BLOCK_CACHE_SIZE {
171
- recent_blocks.pop_front();
+ let mut insert = true;
+ for (height, _) in recent_blocks.iter() {
172
+ if *height == block_height {
173
+ insert = false;
174
+ }
175
176
+ if insert {
177
+ if recent_blocks.len() >= BLOCK_CACHE_SIZE {
178
+ recent_blocks.pop_front();
179
180
+ recent_blocks.push_back((block_height, block));
181
}
- recent_blocks.push_back((block_height, block));
182
183
break 'tx_found;
184
};
0 commit comments