From 26f72bd21b56a5d6fa6b1c44d256836778fab0a9 Mon Sep 17 00:00:00 2001 From: greg7mdp Date: Fri, 22 Mar 2024 10:57:52 -0400 Subject: [PATCH] Encapsulate use of `action_digests_t` better. --- libraries/chain/apply_context.cpp | 5 +---- .../chain/include/eosio/chain/transaction_context.hpp | 7 +++++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libraries/chain/apply_context.cpp b/libraries/chain/apply_context.cpp index c323a7fbf9..cc7f44f9f0 100644 --- a/libraries/chain/apply_context.cpp +++ b/libraries/chain/apply_context.cpp @@ -186,10 +186,7 @@ void apply_context::exec_one() finalize_trace( trace, start ); - if (trx_context.executed_action_receipts.digests_l) - trx_context.executed_action_receipts.digests_l->emplace_back( trace.digest_legacy() ); - if (trx_context.executed_action_receipts.digests_s) - trx_context.executed_action_receipts.digests_s->emplace_back( trace.digest_savanna() ); + trx_context.executed_action_receipts.compute_and_append_digests_from(trace); if ( control.contracts_console() ) { print_debug(receiver, trace); diff --git a/libraries/chain/include/eosio/chain/transaction_context.hpp b/libraries/chain/include/eosio/chain/transaction_context.hpp index 81a9855017..525794e929 100644 --- a/libraries/chain/include/eosio/chain/transaction_context.hpp +++ b/libraries/chain/include/eosio/chain/transaction_context.hpp @@ -53,6 +53,13 @@ namespace eosio { namespace chain { fc::move_append(*digests_s, std::move(*o.digests_s)); } + void compute_and_append_digests_from(action_trace& trace) { + if (digests_l) + digests_l->emplace_back(trace.digest_legacy()); + if (digests_s) + digests_s->emplace_back(trace.digest_savanna()); + } + store_which_t store_which() const { if (digests_l && digests_s) return store_which_t::both;