Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Add additional required operator==
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Jan 4, 2021
1 parent 7f6a10f commit 5a74daa
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions libraries/chain/include/eosio/chain/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,6 @@ namespace eosio { namespace chain {
packed_transaction_v0( bytes&& packed_txn, vector<signature_type>&& sigs, vector<bytes>&& cfd, compression_type _compression );
packed_transaction_v0( transaction&& t, vector<signature_type>&& sigs, bytes&& packed_cfd, compression_type _compression );

friend bool operator==(const packed_transaction& lhs, const packed_transaction& rhs) {
return std::tie(lhs.signatures, lhs.compression, lhs.packed_context_free_data, lhs.packed_trx) ==
std::tie(rhs.signatures, rhs.compression, rhs.packed_context_free_data, rhs.packed_trx);
}
friend bool operator!=(const packed_transaction& lhs, const packed_transaction& rhs) { return !(lhs == rhs); }

uint32_t get_unprunable_size()const;
uint32_t get_prunable_size()const;

Expand Down Expand Up @@ -217,35 +211,67 @@ namespace eosio { namespace chain {

struct none {
digest_type digest;

digest_type prunable_digest() const;

friend bool operator==(const none& lhs, const none& rhs) {
return lhs.digest == rhs.digest;
}
friend bool operator!=(const none& lhs, const none& rhs) { return !(lhs == rhs); }
};

using segment_type = std::variant<digest_type, bytes>;

struct partial {
std::vector<signature_type> signatures;
std::vector<segment_type> context_free_segments;

digest_type prunable_digest() const;

friend bool operator==(const partial& lhs, const partial& rhs) {
return std::tie( lhs.signatures, lhs.context_free_segments ) ==
std::tie( rhs.signatures, rhs.context_free_segments );
}
friend bool operator!=(const partial& lhs, const partial& rhs) { return !(lhs == rhs); }
};

struct full {
std::vector<signature_type> signatures;
std::vector<bytes> context_free_segments;

digest_type prunable_digest() const;

friend bool operator==(const full& lhs, const full& rhs) {
return std::tie( lhs.signatures, lhs.context_free_segments ) ==
std::tie( rhs.signatures, rhs.context_free_segments );
}
friend bool operator!=(const full& lhs, const full& rhs) { return !(lhs == rhs); }
};

struct full_legacy {
std::vector<signature_type> signatures;
bytes packed_context_free_data;
vector<bytes> context_free_segments;

digest_type prunable_digest() const;

friend bool operator==(const full_legacy& lhs, const full_legacy& rhs) {
return std::tie( lhs.signatures, lhs.packed_context_free_data, lhs.context_free_segments ) ==
std::tie( rhs.signatures, rhs.packed_context_free_data, rhs.context_free_segments );
}
friend bool operator!=(const full_legacy& lhs, const full_legacy& rhs) { return !(lhs == rhs); }
};

using prunable_data_t = std::variant< full_legacy,
none,
partial,
full >;

friend bool operator==(const prunable_data_type& lhs, const prunable_data_type& rhs) {
return lhs.prunable_data == rhs.prunable_data;
}
friend bool operator!=(const prunable_data_type& lhs, const prunable_data_type& rhs) { return !(lhs == rhs); }

prunable_data_type prune_all() const;
digest_type digest() const;

Expand All @@ -271,6 +297,12 @@ namespace eosio { namespace chain {

packed_transaction_v0_ptr to_packed_transaction_v0() const;

friend bool operator==(const packed_transaction& lhs, const packed_transaction& rhs) {
return std::tie(lhs.compression, lhs.prunable_data, lhs.packed_trx) ==
std::tie(rhs.compression, rhs.prunable_data, rhs.packed_trx);
}
friend bool operator!=(const packed_transaction& lhs, const packed_transaction& rhs) { return !(lhs == rhs); }

uint32_t get_unprunable_size()const;
uint32_t get_prunable_size()const;
uint32_t get_estimated_size()const { return estimated_size; }
Expand Down

0 comments on commit 5a74daa

Please sign in to comment.