Skip to content

feat: snapshot events through ws#466

Merged
lgalabru merged 2 commits intomainfrom
feat/snapshot-events
Jan 12, 2026
Merged

feat: snapshot events through ws#466
lgalabru merged 2 commits intomainfrom
feat/snapshot-events

Conversation

@lgalabru
Copy link
Collaborator

@lgalabru lgalabru commented Jan 8, 2026

No description provided.

Copy link
Collaborator

@MicaiahReid MicaiahReid left a comment

Choose a reason for hiding this comment

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

I think a little more context would help me understand some of the whys! Plus one or two hygiene comments

let snapshot_id = format!("snapshot_{}", chrono::Utc::now().timestamp_nanos_opt().unwrap_or(0));

// Send initial notification that snapshot import has started
let start_notification = crate::surfnet::SnapshotImportNotification {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, it seems fishy that we're sending this hear as well as in the actual subscribe_for_snapshot_import_updates function - it should just be in the one in the svm file, right?


// TODO: The actual loading should be done via the load_snapshot method
// For now, we simulate the process and send completion
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the load_snapshot fn should now exist! And I believe it's synchronous so that's nice.

async fn fetch_snapshot_from_url(
snapshot_url: &str,
) -> Result<std::collections::BTreeMap<String, Option<surfpool_types::AccountSnapshot>>, Box<dyn std::error::Error + Send + Sync>> {
// For now, we'll use reqwest to fetch the snapshot data
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future what will this be?

subscribe,
name = "snapshotSubscribe"
)]
fn snapshot_subscribe(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like a weird name, cause it's not just subscribing to notifications about a snapshot being imported, it's actually initiating the import.

Also, why are we having surfpool fetch snapshots instead of just receiving them via some RPC method?

@lgalabru lgalabru merged commit e0e756e into main Jan 12, 2026
4 checks passed
@lgalabru lgalabru deleted the feat/snapshot-events branch January 20, 2026 18:14
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.

2 participants