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

Preferring variable ownership over locks in beacon bridge #873

Open
carver opened this issue Aug 26, 2023 · 1 comment
Open

Preferring variable ownership over locks in beacon bridge #873

carver opened this issue Aug 26, 2023 · 1 comment
Assignees
Labels
shelf-stable Will not be closed by stale-bot

Comments

@carver
Copy link
Collaborator

carver commented Aug 26, 2023

I have some intuition that some refactors in the beacon bridge, portal-bridge/src/beacon_bridge.rs, can help us strip away some Mutexes, like this one:

let finalized_block_root = Arc::new(Mutex::new(String::new()));

Roughly, the approach would be to move the block root into the spawned async service task, and then return it from that task to re-assign the variable in the outer scope from the returned task value.

I can't do it in my head quite well enough to explain on a PR review, so I'll just code it myself locally to try it out, and show an example.

@carver carver self-assigned this Aug 26, 2023
@carver
Copy link
Collaborator Author

carver commented Aug 26, 2023

I linked an example. There might be more places, so we can leave the issue open until all similar cases are handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
shelf-stable Will not be closed by stale-bot
Projects
None yet
Development

No branches or pull requests

2 participants