This repository has been archived by the owner on Feb 1, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goals
If Bitswap receives a block that isn't in it's wantlist, is should ignore it, and not add it to the block store
Implementation
Blocks get received in bitswap one of two ways. They're either added by the user (HasBlock) -- and in this case it seems like they should always get added to the blockstore. Or, they come in through the network -- through the ReceiveMessage function. It seems to me, and it's possible I'm missing something, this is the place to ignore an unwanted block. This perhaps naive implementation simply checks blocks received from the network against the global wantlist and ignores them if they aren't in the wantlist.
For Discussion
There are interesting questions about what exactly we want to do and not do with an unwanted block. This approach counts the block in statistics but doesn't provide it, add it to the block store, send it to sessions, or anything else.
The reason for counting in statistics is information was transferred and received, and duplicate blocks likely have been removed from the wantlist but were requested at some point, making them worth recording as duplicate blocks.
But it might merit further examination to figure out if this is the exact right set of things to "not do" if we get a block that's not in the want list.
fix #21 fix #22