Skip to content

Commit

Permalink
node: Pass requester addr in GetResource on handling GetInv
Browse files Browse the repository at this point in the history
  • Loading branch information
goshawk-3 committed May 16, 2024
1 parent e977c6b commit 447df74
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions node/src/databroker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ impl DataBrokerSrv {
.ok_or_else(|| anyhow::anyhow!("invalid metadata src_addr"))?;

debug!(event = "handle_request", ?msg);
let this_peer = *network.read().await.public_addr();

match &msg.payload {
// Handle GetCandidate requests
Expand All @@ -216,7 +217,7 @@ impl DataBrokerSrv {
// Handle GetInv requests
Payload::GetInv(m) => {
let msg =
Self::handle_inv(db, m, conf.max_inv_entries, recv_peer)
Self::handle_inv(db, m, conf.max_inv_entries, this_peer)
.await?;
Ok(Response::new_from_msg(msg, recv_peer))
}
Expand Down Expand Up @@ -356,7 +357,7 @@ impl DataBrokerSrv {
db: &Arc<RwLock<DB>>,
m: &node_data::message::payload::Inv,
max_entries: usize,
recv_addr: SocketAddr,
requester_addr: SocketAddr,
) -> Result<Message> {
let inv = db.read().await.view(|t| {
let mut inv = payload::Inv::default();
Expand Down Expand Up @@ -414,7 +415,7 @@ impl DataBrokerSrv {
// (GetBlocks/Mempool) so it should not be treated as flooding request
Ok(Message::new_get_resource(GetResource::new(
inv,
recv_addr,
requester_addr,
u64::MAX,
1,
)))
Expand Down

0 comments on commit 447df74

Please sign in to comment.