-
Notifications
You must be signed in to change notification settings - Fork 135
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(portal-bridge): re-initialize census if no peers are available #1481
Conversation
00d0f0b
to
cffbfd1
Compare
166d327
to
aea1b93
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
portal-bridge/src/census.rs
Outdated
@@ -52,11 +59,15 @@ impl Census { | |||
} | |||
|
|||
impl Census { | |||
pub async fn init(&mut self) { | |||
pub async fn init(&mut self) -> anyhow::Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should this also be Result<(), CensusError>
?
portal-bridge/src/main.rs
Outdated
@@ -56,7 +56,9 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
let (census_tx, census_rx) = mpsc::unbounded_channel(); | |||
let mut census = Census::new(portal_client.clone(), census_rx); | |||
// initialize the census to acquire critical threshold view of network before gossiping | |||
census.init().await; | |||
if census.init().await.is_err() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: In my opinion, main can just return anyhow::Result<()>
and you can use anyhow!(..)
here. Or just use census.init().await?;
and propagate error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aea1b93
to
ac09230
Compare
What was wrong?
One of the state bridges is stuck, and only displays a large amount of
No known peers in state census, unable to offer.
errors in the logs.How was it fixed?
I had trouble re-producing this locally, but I think these changes will help. There are 2 cases where we might want to re-initialize the census
To-Do