Skip to content
This repository was archived by the owner on Sep 30, 2023. It is now read-only.

Resolve sync only after heads have been added #38

Merged
merged 4 commits into from
Feb 11, 2020

Conversation

tyleryasaka
Copy link
Contributor

@tyleryasaka tyleryasaka commented Nov 29, 2018

This is required for a tentative solution to orbitdb/orbitdb#509:

orbitdb/orbitdb#514

See this commit message for a more detailed explanation.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
This first checks if anything is in the queue or buffer to be processed. If so, then it waits for a `replicate.progress` event (where the progress is complete) and then waits for the `replicated` event.

The downside to this is that if other things are being added to the queue rapidly, then this may hang indefinitely. That said, currently as this is used in orbit-db, this would not block anything other than the new event I have proposed adding, so it should be fine?

Ideally, what should really happen is that we should have a way of knowing when the items derived from the given heads have been replicated. Currently, however, the queue is a black hole and there's no way to track the graph that branches out from the heads. The queue would likely need to be refactored for this approach.
chmanie pushed a commit to JoinColony/colonyDapp that referenced this pull request May 31, 2019
chmanie pushed a commit to JoinColony/colonyDapp that referenced this pull request Jun 10, 2019
@aphelionz
Copy link
Contributor

@chmanie Thank you for the clarification. Can you and @tyleryasaka work to get the event listeners cleaned up?

const saved = await mapSeries(heads, saveToIpfs)
await this._replicator.load(saved.filter(e => e !== null))

return new Promise(resolve => {
Copy link

Choose a reason for hiding this comment

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

I feel like this also needs a timeout to be rejected at some point

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I follow, why would you want to do that?

Copy link

Choose a reason for hiding this comment

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

resolve is wrapped in conditionals both of the times. Are we sure one of those is always going to happen?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure yes. If not something with the replication logic would be broken

@oed
Copy link
Contributor

oed commented Jul 21, 2019

So basically just removing the event listeners before resolving the promise? @chmanie

@aphelionz
Copy link
Contributor

Friendly ping on this thread @chmanie @oed

@chmanie
Copy link

chmanie commented Jul 31, 2019

So basically just removing the event listeners before resolving the promise

Yeah, that should do.

@aphelionz
Copy link
Contributor

@tyleryasaka Would you be able to remove those event listeners? If so then we can merge this and the commensurate PR in orbit-db

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants