Skip to content

Commit

Permalink
chore: resolve discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
kstdl committed Jun 5, 2024
1 parent 50de1d9 commit 145f545
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions libraries/core_libs/consensus/src/final_chain/final_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,7 @@ class FinalChainImpl final : public FinalChain {
if (!system_transactions.empty()) {
db_->addPeriodSystemTransactions(batch, system_transactions, new_blk.pbft_blk->getPeriod());
auto position = new_blk.transactions.size() + 1;
std::cout << "system trx size: " << system_transactions.size() << std::endl;
for (const auto& trx : system_transactions) {
std::cout << "saving " << trx->getHash() << std::endl;
db_->addSystemTransactionToBatch(batch, trx);
db_->addTransactionLocationToBatch(batch, trx->getHash(), new_blk.pbft_blk->getPeriod(), position,
true /*system_trx*/);
Expand Down Expand Up @@ -338,29 +336,29 @@ class FinalChainImpl final : public FinalChain {
blk_header.extra_data = extra_data;
dev::BytesMap trxs_trie, receipts_trie;
dev::RLPStream rlp_strm;
auto receipt_idx = 0;
for (; receipt_idx < transactions.size(); ++receipt_idx) {
const auto& trx = transactions[receipt_idx];
auto i_rlp = util::rlp_enc(rlp_strm, receipt_idx);
auto trx_idx = 0;
for (; trx_idx < transactions.size(); ++trx_idx) {
const auto& trx = transactions[trx_idx];
auto i_rlp = util::rlp_enc(rlp_strm, trx_idx);
trxs_trie[i_rlp] = trx->rlp();

const auto& receipt = receipts[receipt_idx];
const auto& receipt = receipts[trx_idx];
receipts_trie[i_rlp] = util::rlp_enc(rlp_strm, receipt);
db_->insert(batch, DB::Columns::final_chain_receipt_by_trx_hash, trx->getHash(), rlp_strm.out());

blk_header.log_bloom |= receipt.bloom();
}
if (system_transactions.size() && receipts.size() == (transactions.size() + system_transactions.size())) {
if (system_transactions.size()) {
for (const auto& sys_trx : system_transactions) {
auto i_rlp = util::rlp_enc(rlp_strm, receipt_idx);
auto i_rlp = util::rlp_enc(rlp_strm, trx_idx);
trxs_trie[i_rlp] = sys_trx->rlp();

const auto& receipt = receipts[receipt_idx];
const auto& receipt = receipts[trx_idx];
receipts_trie[i_rlp] = util::rlp_enc(rlp_strm, receipt);
db_->insert(batch, DB::Columns::final_chain_receipt_by_trx_hash, sys_trx->getHash(), rlp_strm.out());

blk_header.log_bloom |= receipt.bloom();
receipt_idx++;
trx_idx++;
}
}
blk_header.transactions_root = hash256(trxs_trie);
Expand Down

0 comments on commit 145f545

Please sign in to comment.