Merge pull request #250 from blockworks-foundation/fixing_network_issues
Resubscribing grpc block subsciption on failure, get vote accounts ev…
This commit is contained in:
commit
8760021e7f
|
@ -253,6 +253,8 @@ pub fn create_block_processing_task(
|
||||||
block_sx: Sender<ProducedBlock>,
|
block_sx: Sender<ProducedBlock>,
|
||||||
commitment_level: CommitmentLevel,
|
commitment_level: CommitmentLevel,
|
||||||
) -> AnyhowJoinHandle {
|
) -> AnyhowJoinHandle {
|
||||||
|
tokio::spawn(async move {
|
||||||
|
loop {
|
||||||
let mut blocks_subs = HashMap::new();
|
let mut blocks_subs = HashMap::new();
|
||||||
blocks_subs.insert(
|
blocks_subs.insert(
|
||||||
"client".to_string(),
|
"client".to_string(),
|
||||||
|
@ -270,9 +272,9 @@ pub fn create_block_processing_task(
|
||||||
CommitmentLevel::Processed => CommitmentConfig::processed(),
|
CommitmentLevel::Processed => CommitmentConfig::processed(),
|
||||||
};
|
};
|
||||||
|
|
||||||
tokio::spawn(async move {
|
|
||||||
// connect to grpc
|
// connect to grpc
|
||||||
let mut client = GeyserGrpcClient::connect(grpc_addr, grpc_x_token, None)?;
|
let mut client =
|
||||||
|
GeyserGrpcClient::connect(grpc_addr.clone(), grpc_x_token.clone(), None)?;
|
||||||
let mut stream = client
|
let mut stream = client
|
||||||
.subscribe_once(
|
.subscribe_once(
|
||||||
HashMap::new(),
|
HashMap::new(),
|
||||||
|
@ -304,12 +306,14 @@ pub fn create_block_processing_task(
|
||||||
UpdateOneof::Ping(_) => {
|
UpdateOneof::Ping(_) => {
|
||||||
log::trace!("GRPC Ping");
|
log::trace!("GRPC Ping");
|
||||||
}
|
}
|
||||||
u => {
|
_ => {
|
||||||
bail!("Unexpected update: {u:?}");
|
log::trace!("unknown GRPC notification");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
bail!("geyser slot stream ended");
|
log::error!("Grpc block subscription broken (resubscribing)");
|
||||||
|
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,6 +328,11 @@ pub fn create_grpc_subscription(
|
||||||
let (cluster_info_sx, cluster_info_notifier) = tokio::sync::broadcast::channel(10);
|
let (cluster_info_sx, cluster_info_notifier) = tokio::sync::broadcast::channel(10);
|
||||||
let (va_sx, vote_account_notifier) = tokio::sync::broadcast::channel(10);
|
let (va_sx, vote_account_notifier) = tokio::sync::broadcast::channel(10);
|
||||||
|
|
||||||
|
let slot_task: AnyhowJoinHandle = {
|
||||||
|
let grpc_x_token = grpc_x_token.clone();
|
||||||
|
let grpc_addr = grpc_addr.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
loop {
|
||||||
let mut slots = HashMap::new();
|
let mut slots = HashMap::new();
|
||||||
slots.insert(
|
slots.insert(
|
||||||
"client".to_string(),
|
"client".to_string(),
|
||||||
|
@ -331,13 +340,9 @@ pub fn create_grpc_subscription(
|
||||||
filter_by_commitment: Some(true),
|
filter_by_commitment: Some(true),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let slot_task: AnyhowJoinHandle = {
|
|
||||||
let grpc_x_token = grpc_x_token.clone();
|
|
||||||
let grpc_addr = grpc_addr.clone();
|
|
||||||
tokio::spawn(async move {
|
|
||||||
// connect to grpc
|
// connect to grpc
|
||||||
let mut client = GeyserGrpcClient::connect(grpc_addr, grpc_x_token.clone(), None)?;
|
let mut client =
|
||||||
|
GeyserGrpcClient::connect(grpc_addr.clone(), grpc_x_token.clone(), None)?;
|
||||||
|
|
||||||
let version = client.get_version().await?.version;
|
let version = client.get_version().await?.version;
|
||||||
if version != expected_grpc_version {
|
if version != expected_grpc_version {
|
||||||
|
@ -385,7 +390,9 @@ pub fn create_grpc_subscription(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
bail!("geyser slot stream ended");
|
log::error!("Grpc slot subscription broken (resubscribing)");
|
||||||
|
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||||
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ pub fn poll_vote_accounts_and_cluster_info(
|
||||||
.send(vote_accounts)
|
.send(vote_accounts)
|
||||||
.context("Should be able to send vote accounts")?;
|
.context("Should be able to send vote accounts")?;
|
||||||
}
|
}
|
||||||
tokio::time::sleep(Duration::from_secs(5)).await;
|
tokio::time::sleep(Duration::from_secs(600)).await;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue