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

Make DHT protocol Resource Manager aware. #806

Open
2 tasks
ajnavarro opened this issue Jan 24, 2023 · 0 comments
Open
2 tasks

Make DHT protocol Resource Manager aware. #806

ajnavarro opened this issue Jan 24, 2023 · 0 comments

Comments

@ajnavarro
Copy link
Member

We have to make DHT protocol RM aware to make good use of resources and retry or error when an RM error is returned from any call to libp2p.

  • Check errors to see if they are RM ones and retry if needed.
  • Do not fire and forget. Examples:

go func(p peer.ID) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
defer wg.Done()
routing.PublishQueryEvent(ctx, &routing.QueryEvent{
Type: routing.Value,
ID: p,
})
err := dht.protoMessenger.PutValue(ctx, p, rec)
if err != nil {
logger.Debugf("failed putting value to peer: %s", err)
}
}(p)

go func(p peer.ID) {
// TODO: Is this possible?
if p == dht.self {
err := dht.putLocal(ctx, key, fixupRec)
if err != nil {
logger.Error("Error correcting local dht entry:", err)
}
return
}
ctx, cancel := context.WithTimeout(ctx, time.Second*30)
defer cancel()
err := dht.protoMessenger.PutValue(ctx, p, fixupRec)
if err != nil {
logger.Debug("Error correcting DHT entry: ", err)
}
}(p)

if err := dht.Validator.Validate(key, val); err != nil {
// make sure record is valid
logger.Debugw("received invalid record (discarded)", "error", err)
return peers, nil
}

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

No branches or pull requests

1 participant