-
Notifications
You must be signed in to change notification settings - Fork 254
Open
Description
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:
Lines 76 to 89 in 2b85cfc
| 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) |
Lines 253 to 268 in 2b85cfc
| 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) |
Lines 320 to 324 in 2b85cfc
| 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 | |
| } |
Metadata
Metadata
Assignees
Labels
No labels