Hash get_tx_tree_hash(const Block& b) { std::vector<Hash> txs_ids; Hash h = NULL_HASH; getObjectHash(b.baseTransaction, h); txs_ids.push_back(h); for (auto& th : b.transactionHashes) { txs_ids.push_back(th); } return get_tx_tree_hash(txs_ids); }
bool get_block_hashing_blob(const Block& b, blobdata& blob) { if (!t_serializable_object_to_blob(static_cast<const BlockHeader&>(b), blob)) { return false; } crypto::hash tree_root_hash = get_tx_tree_hash(b); blob.append(reinterpret_cast<const char*>(&tree_root_hash), sizeof(tree_root_hash)); blob.append(tools::get_varint_data(b.txHashes.size() + 1)); return true; }
bool get_block_hashing_blob(const Block& b, BinaryArray& ba) { if (!toBinaryArray(static_cast<const BlockHeader&>(b), ba)) { return false; } Hash treeRootHash = get_tx_tree_hash(b); ba.insert(ba.end(), treeRootHash.data, treeRootHash.data + 32); auto transactionCount = asBinaryArray(Tools::get_varint_data(b.transactionHashes.size() + 1)); ba.insert(ba.end(), transactionCount.begin(), transactionCount.end()); return true; }
crypto::hash get_tx_tree_hash(const Block& b) { std::vector<crypto::hash> txs_ids; crypto::hash h = null_hash; size_t bl_sz = 0; get_transaction_hash(b.minerTx, h, bl_sz); txs_ids.push_back(h); for (auto& th : b.txHashes) { txs_ids.push_back(th); } return get_tx_tree_hash(txs_ids); }
Hash get_tx_tree_hash(const std::vector<Hash>& tx_hashes) { Hash h = NULL_HASH; get_tx_tree_hash(tx_hashes, h); return h; }
crypto::hash get_tx_tree_hash(const std::vector<crypto::hash>& tx_hashes) { crypto::hash h = null_hash; get_tx_tree_hash(tx_hashes, h); return h; }