OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/cert/merkle_consistency_proof.h" | 5 #include "net/cert/merkle_consistency_proof.h" |
6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" |
| 8 |
7 namespace net { | 9 namespace net { |
8 | |
9 namespace ct { | 10 namespace ct { |
10 | 11 |
11 MerkleConsistencyProof::MerkleConsistencyProof() {} | 12 MerkleConsistencyProof::MerkleConsistencyProof() {} |
12 | 13 |
13 MerkleConsistencyProof::MerkleConsistencyProof( | 14 MerkleConsistencyProof::MerkleConsistencyProof( |
14 const std::string& log_id, | 15 const std::string& log_id, |
15 const std::vector<std::string>& proof_nodes, | 16 const std::vector<std::string>& proof_nodes, |
16 uint64_t old_size, | 17 uint64_t old_size, |
17 uint64_t new_size) | 18 uint64_t new_size) |
18 : log_id(log_id), | 19 : log_id(log_id), |
19 nodes(proof_nodes), | 20 nodes(proof_nodes), |
20 first_tree_size(old_size), | 21 first_tree_size(old_size), |
21 second_tree_size(new_size) {} | 22 second_tree_size(new_size) {} |
22 | 23 |
23 MerkleConsistencyProof::~MerkleConsistencyProof() {} | 24 MerkleConsistencyProof::~MerkleConsistencyProof() {} |
24 | 25 |
| 26 bool operator==(const MerkleConsistencyProof& proof1, |
| 27 const MerkleConsistencyProof& proof2) { |
| 28 return proof1.log_id == proof2.log_id && |
| 29 proof1.first_tree_size == proof2.first_tree_size && |
| 30 proof1.second_tree_size == proof2.second_tree_size && |
| 31 proof1.nodes == proof2.nodes; |
| 32 } |
| 33 |
| 34 std::ostream& operator<<(std::ostream& stream, |
| 35 const MerkleConsistencyProof& proof) { |
| 36 return stream << "{\n" |
| 37 << "\"tree_size_1\": " << proof.first_tree_size << ",\n" |
| 38 << "\"tree_size_2\": " << proof.second_tree_size << ",\n" |
| 39 << "\"log_id\": \"" |
| 40 << base::HexEncode(proof.log_id.data(), proof.log_id.size()) |
| 41 << "\",\n" |
| 42 << "}"; |
| 43 } |
| 44 |
25 } // namespace ct | 45 } // namespace ct |
26 | |
27 } // namespace net | 46 } // namespace net |
OLD | NEW |