Skip to content

Commit

Permalink
Actually run exeucte update
Browse files Browse the repository at this point in the history
  • Loading branch information
lavrov committed Sep 15, 2024
1 parent 8fff212 commit b0f0d85
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait Connection {
def request(request: Message.Request): IO[ByteVector]
def choked: Signal[IO, Boolean]
def availability: Signal[IO, BitSet]
def disconnected: IO[Either[Throwable, Unit]]
def disconnected: IO[Unit]
def extensionApi: IO[ExtensionApi[IO]]
}

Expand Down Expand Up @@ -102,8 +102,7 @@ object Connection {
)
)
updateLastMessageTime = (l: Long) => stateRef.update(State.lastMessageAt.replace(l))
closed <- Resource.eval(IO.deferred[Either[Throwable, Unit]])
_ <-
closed <-
(
receiveLoop(
requestRegistry,
Expand All @@ -115,11 +114,7 @@ object Connection {
),
sendLoop(sendQueue, socket),
keepAliveLoop(stateRef, sendQueue.offer)
).parTupled
.guarantee(
closed.complete(Right(())).void
)
.background
).parTupled.background
yield new Connection {
def info: PeerInfo = peerInfo
def extensionProtocol: Boolean = socket.handshake.extensionProtocol
Expand All @@ -142,7 +137,7 @@ object Connection {

def availability: Signal[IO, BitSet] = bitfieldRef

def disconnected: IO[Either[Throwable, Unit]] = closed.get
def disconnected: IO[Unit] = closed.void

def extensionApi: IO[ExtensionApi[IO]] = initExtension.init
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class PingRoutine(table: RoutingTable[IO], client: Client)(using logger: Logger[
val results = queries.parSequence.await
val (bad, good) = results.partitionMap(identity)
logger.info(s"Got ${good.size} good nodes and ${bad.size} bad nodes").await
table.updateGoodness(good.toSet, bad.toSet)
table.updateGoodness(good.toSet, bad.toSet).await

def runForever: IO[Unit] =
run
Expand Down

0 comments on commit b0f0d85

Please sign in to comment.