提交 88cf4352 编写于 作者: N Nathan Hourt

Progress #5: Hash IDs for generated transactions

As discussed on #5, use hashes as the generated_transaction_id_type
instead of serial numbers.
上级 935c7016
......@@ -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());
......
......@@ -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
......
......@@ -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));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册