Skip to content

Commit

Permalink
Merge pull request #139 from rustaceanrob/spam-09-17
Browse files Browse the repository at this point in the history
fix(chain): prevent block request spam
  • Loading branch information
rustaceanrob authored Sep 18, 2024
2 parents 6a0422a + f91041f commit 02f5fb7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/chain/block_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::VecDeque;
use bitcoin::BlockHash;
use tokio::time::Instant;

const SPAM_LIMIT: u64 = 2;
const SPAM_LIMIT: u64 = 5;

#[derive(Debug)]
pub(crate) struct BlockQueue {
Expand Down Expand Up @@ -37,6 +37,7 @@ impl BlockQueue {
if Instant::now().duration_since(self.last_req).as_secs() < SPAM_LIMIT {
None
} else {
self.last_req = Instant::now();
Some(block)
}
}
Expand Down

0 comments on commit 02f5fb7

Please sign in to comment.