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

[Colossus] Sync rework - #5014

Merged
merged 6 commits into from
Dec 28, 2023
Merged

Conversation

zeeshanakram3
Copy link
Contributor

@zeeshanakram3 zeeshanakram3 commented Dec 26, 2023

colses #5008

This PR:

  • removes api parameter from the performSync function & fetch the object hash from QN instead of fetching from the runtime.
  • directly download data objects from remote nodes instead of pre-checking their existence first.
  • The logging message in the superagent error handler - when the object does not exist in the remote node - won't be logged, since technically missing asset won't be categorized as an error, and logging this as an error may confuse the Operator/Lead

Copy link
Contributor

@mnaamani mnaamani left a comment

Choose a reason for hiding this comment

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

Looks great. Small code style change suggested.

// Create an array of operator URL indices to maintain a random URL choice
// cannot use the original array because we shouldn't modify the original data.
// And cloning it seems like a heavy operation.
const operatorUrlIndices: number[] = [...Array(this.operatorUrls.length).keys()]
Copy link
Contributor

Choose a reason for hiding this comment

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

I can suggest a slightly cleaner approach. Start with an array already containing random order of the indices using a combination of _.range() and _.shuffle(). You could then just shift or pop the array at the start of the loop. Or the while loop then can be a simply a for..each iteration over the array, without needing to modify it.

const operatorUrlIndices: number[] = _.shuffle(_.range(this.operatorUrls.length))

logger.debug(`Sync - random storage node URL was chosen ${chosenBaseUrl}`)

// Remove random url from the original list.
_.remove(operatorUrlIndices, (index) => index === randomUrlIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

removing the element is no longer necessary, even potentially problematic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah right. Missed that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 3c02240

@mnaamani mnaamani self-requested a review December 28, 2023 12:39
@mnaamani mnaamani merged commit 78f3e9a into Joystream:master Dec 28, 2023
23 checks passed
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.

None yet

2 participants