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 2, 2023
1 parent 2d4638e commit a059b70
Showing 1 changed file with 5 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 @@ -183,10 +183,14 @@ async function batchResponse ({ blocks, context, logger }) {
}

try {
logger.info({ key: context.canceled }, 'batch response')
let message = new Message()
for (let i = 0; i < blocks.length; i++) {
const block = blocks[i]
console.log('block key', block.key)
const canceledItem = context.canceled.get(block.key)
logger.info({ key: block.key }, 'check')
logger.info({ canceled: canceledItem }, 'check')
if (!canceledItem || canceledItem !== block.type) {
const size = messageSize[block.type](block)

Expand All @@ -203,6 +207,7 @@ async function batchResponse ({ blocks, context, logger }) {
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)
}
}
Expand Down

0 comments on commit a059b70

Please sign in to comment.