Skip to content

Commit

Permalink
Ping candidates every minute
Browse files Browse the repository at this point in the history
  • Loading branch information
lavrov committed Sep 15, 2024
1 parent f03d4d5 commit 8fff212
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions dht/src/main/scala/com/github/torrentdam/bittorrent/dht/Node.scala
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,17 @@ object Node {
case Left(_) => IO.unit
}
}

private def pingCandidates(nodes: Queue[IO, NodeInfo], client: Client, routingTable: RoutingTable[IO])(using Logger[IO]) =
nodes.take.flatMap(pingCandidate(_, client, routingTable).attempt.void).foreverM
nodes
.tryTakeN(none)
.flatMap(candidates =>
candidates
.distinct
.traverse_(pingCandidate(_, client, routingTable).attempt.void)
)
.productR(IO.sleep(1.minute))
.foreverM


private def reportingQueryHandler(queue: Queue[IO, NodeInfo], next: QueryHandler[IO]): QueryHandler[IO] = (address, query) =>
Expand Down

0 comments on commit 8fff212

Please sign in to comment.