Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/have new msg types #211

Merged
merged 14 commits into from
Apr 7, 2020
Merged

Feat/have new msg types #211

merged 14 commits into from
Apr 7, 2020

Conversation

dirkmc
Copy link
Contributor

@dirkmc dirkmc commented Jan 6, 2020

Support responses to want-block and want-have message types in decision engine

See #204 for more detail

@dirkmc dirkmc changed the base branch from master to feat/haves January 6, 2020 22:48
@dirkmc dirkmc marked this pull request as ready for review January 10, 2020 14:31
@dirkmc dirkmc force-pushed the feat/have-new-msg-types branch from 15bb89b to a100ecf Compare January 10, 2020 14:40
@dirkmc dirkmc mentioned this pull request Jan 29, 2020
16 tasks
@dirkmc
Copy link
Contributor Author

dirkmc commented Feb 13, 2020

ping @alanshaw @jacobheun @achingbrain

Would love to get some eyes on this 🙏

src/decision-engine/index.js Show resolved Hide resolved
src/decision-engine/index.js Outdated Show resolved Hide resolved
src/decision-engine/index.js Show resolved Hide resolved
src/decision-engine/index.js Show resolved Hide resolved
src/decision-engine/index.js Show resolved Hide resolved
// the new block size
if (!existingData.haveBlock && taskData.haveBlock) {
existingData.haveBlock = taskData.haveBlock
existingData.blockSize = taskData.blockSize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about updating existingData.size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do that at the bottom, so as to do it one place (we also need to do it when replacing want-have with want-block)

src/decision-engine/task-merger.js Show resolved Hide resolved

// If the task is a want-block, make sure the entry size is equal
// to the block size (because we will send the whole block)
if (existingData.isWantBlock && existingData.haveBlock) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be taskData instead of existingData?:

Suggested change
if (existingData.isWantBlock && existingData.haveBlock) {
if (existingData.isWantBlock && taskData.haveBlock) {

If not then this feels like something that shouldn't be done here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to cover any changes that have happened in either case above.

Either

  • a DONT_HAVE was replaced with a want-have / want-block
  • a want-have was replaced with a want-block

In either case we need to make sure that if it's now a want-block that the entry size (the size of the response on the wire) is equal to the block size


// If we now have block size information, update the task with
// the new block size
if (!existingData.haveBlock && taskData.haveBlock) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haveBlock => isHave? and then isWantBlock => isHaveAndBlock

...because want-block is basically a "I have this and here it is" where as want-have is just "I have this", right? Neither of these are actually wanting things so the naming want-have and want-block is super confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little confusing: This is the request queue, so these requests are want-have or want-block. When we pop stuff off the request queue we turn them into HAVE / block

src/index.js Outdated
// Notify listeners that we have received the new blocks
for (const block of newBlocks) {
self.notifications.hasBlock(block)
self.engine.receivedBlocks([block])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to self anymore, but why did this get pulled out here? If it stays, could you pass newBlocks to self.engine.receivedBlocks(newBlocks) and not have to call it multiple times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little deceptive: the async iterator passed to putMany() yields blocks that should be put (it doesn't yield blocks that have already been put). So we actually need to perform post-put actions after the whole putMany() call has completed.

You're right about the receivedBlocks() call, it's more efficient to pass all blocks at once, I've fixed 👍

src/decision-engine/index.js Show resolved Hide resolved
src/decision-engine/index.js Outdated Show resolved Hide resolved
src/decision-engine/index.js Show resolved Hide resolved
src/decision-engine/task-merger.js Outdated Show resolved Hide resolved
src/types/message/index.js Outdated Show resolved Hide resolved
@dirkmc
Copy link
Contributor Author

dirkmc commented Mar 10, 2020

ping @alanshaw @jacobheun

Copy link
Contributor

@jacobheun jacobheun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me! Aside from merging this and rebasing #204 is there anything left to do aside from interop testing with go?

@dirkmc
Copy link
Contributor Author

dirkmc commented Mar 11, 2020

Thanks @jacobheun 🎂

As far as I know we just need to do interop testing

@dirkmc dirkmc merged commit 7a642d7 into feat/haves Apr 7, 2020
@dirkmc dirkmc deleted the feat/have-new-msg-types branch April 7, 2020 17:52
dirkmc added a commit that referenced this pull request Apr 7, 2020
* feat: SortedMap

* refactor: make SortedMap more efficient

* feat: add request queue

* feat: support want-have & want-block in engine

* fix: block presences deserialization

* fix: ensure blocks are in blockstore before adding them to engine request queue

* fix: reduce engine queue contention

* feat: listen on bitswap/1.2.0 (#212)

* fix: several engine fixes

* refactor: rename some things

* docs: add some docs to task merger

* refactor: more efficient block receive

* docs: add message comments

* refactor: better var names in merger
dirkmc added a commit that referenced this pull request Apr 9, 2020
* feat: update message protobuf to support new message types

* fix: case of protobuf fields

* feat: include pending bytes in response message (#205)

* Feat/have new msg types (#211)

* feat: SortedMap

* refactor: make SortedMap more efficient

* feat: add request queue

* feat: support want-have & want-block in engine

* fix: block presences deserialization

* fix: ensure blocks are in blockstore before adding them to engine request queue

* fix: reduce engine queue contention

* feat: listen on bitswap/1.2.0 (#212)

* fix: several engine fixes

* refactor: rename some things

* docs: add some docs to task merger

* refactor: more efficient block receive

* docs: add message comments

* refactor: better var names in merger

* fix: merge with master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants