updateMappingLocked updates the mapping for another peer linked to this one by a tunnel. This method is NOT threadsafe and must be called while holding the core lock.
(id uuid.UUID, n *proto.Node, k proto.CoordinateResponse_PeerUpdate_Kind, reason string)
| 29 | // updateMappingLocked updates the mapping for another peer linked to this one by a tunnel. This method |
| 30 | // is NOT threadsafe and must be called while holding the core lock. |
| 31 | func (p *peer) updateMappingLocked(id uuid.UUID, n *proto.Node, k proto.CoordinateResponse_PeerUpdate_Kind, reason string) error { |
| 32 | logger := p.logger.With(slog.F("from_id", id), slog.F("kind", k), slog.F("reason", reason)) |
| 33 | update, err := p.storeMappingLocked(id, n, k, reason) |
| 34 | if xerrors.Is(err, errNoResp) { |
| 35 | logger.Debug(context.Background(), "skipping update") |
| 36 | return nil |
| 37 | } |
| 38 | if err != nil { |
| 39 | return err |
| 40 | } |
| 41 | |
| 42 | req := &proto.CoordinateResponse{PeerUpdates: []*proto.CoordinateResponse_PeerUpdate{update}} |
| 43 | select { |
| 44 | case p.resps <- req: |
| 45 | p.lastWrite = time.Now() |
| 46 | logger.Debug(context.Background(), "wrote peer update") |
| 47 | return nil |
| 48 | default: |
| 49 | return ErrWouldBlock |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // batchUpdateMapping updates the mappings for a list of peers linked to this one by a tunnel. This |
| 54 | // method is NOT threadsafe and must be called while holding the core lock. |
no test coverage detected