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

Commit

Permalink
Progress #5: Hash IDs for generated transactions
Browse files Browse the repository at this point in the history
As discussed on #5, use hashes as the generated_transaction_id_type
instead of serial numbers.
  • Loading branch information
nathanielhourt committed Apr 12, 2017
1 parent 935c701 commit 88cf435
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 2 additions & 0 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ namespace detail {
for (const auto& cycle : blk_msg.block.cycles)
for (const auto& thread : cycle)
for (const auto& transaction : thread.input_transactions)
// In theory, we can ignore generated transactions here, since they don't ever go bare over the
// network. Is this true?...
if (transaction.which() == decay_t<decltype(transaction)>::tag<signed_transaction>::value) {
eos::net::trx_message transaction_message(transaction.get<signed_transaction>());
contained_transaction_message_ids.push_back(eos::net::message(transaction_message).id());
Expand Down
3 changes: 1 addition & 2 deletions libraries/chain/include/eos/chain/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ namespace eos { namespace chain {
using account_id_type = chainbase::oid<account_object>;
using producer_id_type = chainbase::oid<producer_object>;

using generated_transaction_id_type = uint32_t;
using block_id_type = fc::ripemd160;
using checksum_type = fc::ripemd160;
using transaction_id_type = fc::ripemd160;
using digest_type = fc::sha256;
using generated_transaction_id_type = fc::sha256;
using signature_type = fc::ecc::compact_signature;
using share_type = safe<int64_t>;
using weight_type = uint16_t;

struct public_key_type
Expand Down
13 changes: 10 additions & 3 deletions libraries/chain/protocol/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,16 @@ namespace eos { namespace chain {
vector<digest_type> ids;
std::transform(input_transactions.begin(), input_transactions.end(), std::back_inserter(ids),
[](const input_transaction& trx) {
if (trx.which() == input_transaction::tag<signed_transaction>::value)
return trx.get<signed_transaction>().merkle_digest();
#warning How do I get the digest from a generated_transaction_id_type?...
struct {
using result_type = digest_type;
result_type operator() (const signed_transaction& t) {
return t.merkle_digest();
}
result_type operator() (const generated_transaction_id_type& id) {
return id;
}
} digester;
return trx.visit(digester);
});
std::transform(output_transactions.begin(), output_transactions.end(), std::back_inserter(ids),
std::bind(&generated_transaction::merkle_digest, std::placeholders::_1));
Expand Down

0 comments on commit 88cf435

Please sign in to comment.