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

fix(sync): inject a state object instead of using a global state #172

Merged
merged 1 commit into from
Mar 4, 2022

Conversation

kkovaacs
Copy link
Contributor

@kkovaacs kkovaacs commented Mar 4, 2022

RPC and sync code now gets an explicit state object that is used to store
and query sync state.

This avoids issues with tests, too: previously running
rpc::tests::syncing::{syncing,not_syncing} in parallel would lead to
test failures.

@kkovaacs kkovaacs force-pushed the krisztian/fix-sync-state-test branch from d831541 to 95d67d5 Compare March 4, 2022 11:00
Copy link
Contributor

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

LGTM. Nice :D Just the new -> default, otherwise good to go.

Don't think this exists, but would be nice to restrict RPC to some read-only primitive somehow. Like a RdWrLock but one that splits into a single RdWrLock and a cloneable RdLock variant (like a channel).

use web3::{transports::Http, Web3};

use crate::rpc::types::reply::Syncing as SyncStatus;

lazy_static::lazy_static!(
// TODO: consider using a broadcast channel instead for easier testing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Heh I see I did somewhat think about this.

crates/pathfinder/src/state/sync.rs Outdated Show resolved Hide resolved
RPC and sync code now gets an explicit state object that is used to store
and query sync state.

This avoids issues with tests, too: previously running
`rpc::tests::syncing::{syncing,not_syncing}` in parallel would lead to
test failures.
@kkovaacs kkovaacs force-pushed the krisztian/fix-sync-state-test branch from 95d67d5 to caf9d95 Compare March 4, 2022 11:43
@kkovaacs kkovaacs merged commit 9c0c399 into main Mar 4, 2022
@kkovaacs kkovaacs deleted the krisztian/fix-sync-state-test branch March 4, 2022 12:49
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