/// <remarks> /// Do we want to create reputation events if the response type doesn't match? /// https://github.com/catalyst-network/Catalyst.Node/issues/674 /// This might be OK if we can be sure that the person responding is actually /// the one with the PeerId mentioned in the response. Is the correlationId /// enough to ensure that? /// </remarks> protected static void ValidateResponseType(ProtocolMessage response, ICorrelatableMessage <ProtocolMessage> responseFromCache) { if (responseFromCache.Content.TypeUrl.GetResponseType() == response.TypeUrl) { return; } throw new InvalidDataException( $"{responseFromCache?.Content?.TypeUrl?.GetResponseType() ?? "invalid cache entry"} " + $"is not a valid match for {response.TypeUrl ?? "invalid response"}"); }
/// <summary> /// Stores a CorrelatableMessage in the cache so we can correlate incoming messages. /// </summary> /// <param name="correlatableMessage"></param> public virtual void AddPendingRequest(ICorrelatableMessage <ProtocolMessage> correlatableMessage) { PendingRequests.Set(correlatableMessage.Content.CorrelationId, correlatableMessage, _entryOptions()); }