Skip to content

Commit

Permalink
chore: add comment on cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Mar 3, 2023
1 parent 0a1f3aa commit 5367dc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,20 @@ async function batchResponse ({ blocks, context, logger }) {

try {
let message = new Message()
logger.info({ keyList: context.canceled.keyList }, 'check keyList')
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i]
const canceledItem = context.canceled.get(block.key)

logger.info({ key: block.key, type: block.type, wantType: block.wantType }, 'check')
logger.info({ canceled: canceledItem }, 'canceled')

if (canceledItem === block.wantType) {
const size = messageSize[block.type](block)
telemetry.increaseLabelCount('bitswap-block-success-cancel', [block.type])
telemetry.increaseLabelCount('bitswap-cancel-size', [block.type], size)

logger.info({ key: block.key }, 'delete')
context.canceled.delete(block.key)
} else {
const size = messageSize[block.type](block)
Expand Down
5 changes: 5 additions & 0 deletions src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ async function startService ({ peerId, port, peerAnnounceAddr, awsClient, connec
}
})

const cancelsPerPeer = new Map()
const handlerOptions = {
maxInboundStreams: connectionConfig.handler.maxInboundStreams,
maxOutboundStreams: connectionConfig.handler.maxOutboundStreams
Expand Down Expand Up @@ -180,6 +181,10 @@ async function startService ({ peerId, port, peerAnnounceAddr, awsClient, connec
cancelsPerPeer.delete(
connection.detail.remotePeer.toString()
)
<<<<<<< Updated upstream
=======

>>>>>>> Stashed changes
try {
telemetry.decreaseGauge('bitswap-active-connections')
} catch (err) {
Expand Down

0 comments on commit 5367dc5

Please sign in to comment.