Skip to content

Commit 544eaa9

Browse files
committed
fix: prevent GET routing loops via skip lists
1 parent 337a160 commit 544eaa9

File tree

1 file changed

+11
-0
lines changed
  • crates/core/src/operations

1 file changed

+11
-0
lines changed

crates/core/src/operations/get.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ pub(crate) async fn request_get(
8282
get_op: GetOp,
8383
skip_list: HashSet<PeerId>,
8484
) -> Result<(), OpError> {
85+
let mut skip_list = skip_list;
86+
// Always avoid bouncing straight back to ourselves.
87+
skip_list.insert(
88+
op_manager
89+
.ring
90+
.connection_manager
91+
.own_location()
92+
.peer
93+
.clone(),
94+
);
8595
let (mut candidates, id, key_val, _fetch_contract) = if let Some(GetState::PrepareRequest {
8696
key,
8797
id,
@@ -1271,6 +1281,7 @@ async fn try_forward_or_return(
12711281

12721282
let mut new_skip_list = skip_list.clone();
12731283
new_skip_list.insert(this_peer.peer.clone());
1284+
new_skip_list.insert(sender.peer.clone());
12741285

12751286
let new_htl = htl.saturating_sub(1);
12761287

0 commit comments

Comments
 (0)