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

Retry provider announcements until success or timeout #1854

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions p2p/node/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,19 @@ func (p *P2PNode) Subscribe(location common.Location, datatype interface{}) erro
}

go func() {
err := p.peerManager.Provide(p.ctx, location, datatype)
if err != nil {
log.Global.Errorf("error providing topic %s in %s: %s", reflect.TypeOf(datatype), location.Name(), err.Error())
ticker := time.NewTicker(time.Second)
timeout := time.NewTicker(60 * time.Second)
for {
select {
case <-ticker.C:
if err := p.peerManager.Provide(p.ctx, location, datatype); err == nil {
log.Global.Infof("providing topic %s in %s", reflect.TypeOf(datatype), location.Name())
return
}
case <-timeout.C:
Djadih marked this conversation as resolved.
Show resolved Hide resolved
log.Global.Errorf("unable to provide topic %s in %s", reflect.TypeOf(datatype), location.Name())
return
}
}
}()
return nil
Expand Down
Loading