1
#pragma once
2

            
3
#include "source/common/protobuf/protobuf.h"
4

            
5
#if defined(ENVOY_ENABLE_FULL_PROTOS)
6
namespace Envoy {
7
namespace DeterministicProtoHash {
8

            
9
// Note: this ignores unknown fields and unrecognized types in Any fields.
10
// An alternative approach might treat such fields as "raw data" and include
11
// them in the hash, which would risk breaking the deterministic behavior,
12
// versus this way risks ignoring significant data.
13
//
14
// Ignoring unknown fields was chosen as the implementation because the
15
// TextFormat-based hashing this replaces was explicitly ignoring unknown
16
// fields.
17
//
18
// If this is used as part of making a hash table, it may result in
19
// collisions if unknown fields are present and are not ignored by the
20
// corresponding comparator. A `MessageDifferencer` can be configured to
21
// ignore unknown fields, or not to.
22
uint64_t hash(const Protobuf::Message& message);
23

            
24
} // namespace DeterministicProtoHash
25
} // namespace Envoy
26
#endif