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(controller): load contracts asynchronously #544

Merged

Conversation

shadow578
Copy link
Contributor

Scope

this PR adds a small change so that locally saved contracts (in ./contracts/) don't block the server start.
the server will start immediately, and continue to load contracts in the background.

Test Plan

connecting to the server should work quickly, even with a lot of contracts in the local folder.

Checklist

  • I have run Prettier to reformat any changed files
  • I have verified my changes work

@AnthonyFuller AnthonyFuller changed the title Make contracts load asynchronously feat(controller): load contracts asynchronously Dec 23, 2024
Copy link
Contributor

@AnthonyFuller AnthonyFuller left a comment

Choose a reason for hiding this comment

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

Ah, this is the slowdown from putting all the FCs in the contracts folder.

I assume you noticed this after loading the entire contracts repo for your "offline" (aka piracy) branch.

@AnthonyFuller AnthonyFuller merged commit 801c12d into thepeacockproject:master Dec 23, 2024
5 checks passed
Copy link
Member

@RDIL RDIL left a comment

Choose a reason for hiding this comment

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

Thanks for this! Some feedback

@@ -857,6 +861,8 @@ export class Controller {
log(LogLevel.DEBUG, e, "contracts")
}
}

log(LogLevel.INFO, "Contracts loading completed", "contracts")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe it would be best to do this as a .then on the Promise that index returns so that it's more accurate?

Copy link
Contributor

@AnthonyFuller AnthonyFuller Dec 23, 2024

Choose a reason for hiding this comment

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

Didn't notice that, good point. I'll edit it now.

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 shouldn't matter, no? In both cases, the log is called after all promises are awaited

Copy link
Member

@RDIL RDIL Dec 23, 2024

Choose a reason for hiding this comment

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

The other promises are blocked on their awaits, but just because they are guaranteed to be done before the first one doesn't mean the first one will be.

@shadow578 shadow578 deleted the update/contracts-load-async branch December 23, 2024 14:54
@shadow578
Copy link
Contributor Author

I assume you noticed this after loading the entire contracts repo for your "offline" (aka piracy) branch.

Well, wanting to play offline doesn't mean I'm doing anything nefarious. Assuming such things imo isn't a great way to start a conversation.

But if you really think it could be used for such a purpose, I'd be ok to remove the branch.

@AnthonyFuller
Copy link
Contributor

AnthonyFuller commented Dec 23, 2024

What do you mean? You return a list of all entitlements no matter what the user owns. That is textbook piracy.

EDIT: I understand the motivation, but this is not the way to do this.

@shadow578
Copy link
Contributor Author

shadow578 commented Dec 23, 2024

You return a list of all entitlements no matter what the user owns.

Or a hardcoded list of entitlements I own. Tbh it's a quick hack and not a proper way of doing things. But I see where you're coming from.

EDIT: I understand the motivation, but this is not the way to do this.

I've taken the branch down now

@AnthonyFuller
Copy link
Contributor

It's much appreciated, the proper way to do it would be making the user connect online first to grab their entitlements. Then using the stored versions in userdata when offline.

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