Skip to content

Commit c813ffc

Browse files
committed
Improve clarity of nested callback flow by function name changes (PArSEC)
agent::impl do_start() --> do_start_function() handle_run() —> handle_run_result() evm_runner run_execute_transaction() —> start_execute_transaction() handle_lock_from_account() —> handle_lockfromacct_and_continue_exec() lock_ticket_number_key() —> lock_ticket_number_key_and_continue_exec() Signed-off-by: Alexander Jung <[email protected]>
1 parent 2948d17 commit c813ffc

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

src/parsec/agent/impl.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace cbdc::parsec::agent {
4949
m_result = std::nullopt;
5050
m_wounded = false;
5151
m_restarted = true;
52-
do_start();
52+
do_start_function();
5353
return true;
5454

5555
// Re-run commit
@@ -120,7 +120,7 @@ namespace cbdc::parsec::agent {
120120
std::visit(
121121
overloaded{[&](const ticket_machine::ticket_number_type& n) {
122122
m_ticket_number = n;
123-
do_start();
123+
do_start_function();
124124
},
125125
[&](const broker::interface::error_code& /* e */) {
126126
m_state = state::ticket_number_request_failed;
@@ -132,7 +132,7 @@ namespace cbdc::parsec::agent {
132132
res);
133133
}
134134

135-
void impl::do_start() {
135+
void impl::do_start_function() {
136136
std::unique_lock l(m_mut);
137137
assert(m_ticket_number.has_value());
138138
assert(m_state == state::ticket_number_request_sent
@@ -152,7 +152,7 @@ namespace cbdc::parsec::agent {
152152
// transaction as m_param and let the runner figure it out.
153153
handle_function(broker::value_type(get_function()));
154154
} else {
155-
m_log->trace("do_start ", get_function().to_hex());
155+
m_log->trace("do_start_function ", get_function().to_hex());
156156

157157
auto tl_success = m_broker->try_lock(
158158
m_ticket_number.value(),
@@ -329,7 +329,7 @@ namespace cbdc::parsec::agent {
329329
get_param(),
330330
m_is_readonly_run,
331331
[this](const runner::interface::run_return_type& run_res) {
332-
handle_run(run_res);
332+
handle_run_result(run_res);
333333
},
334334
[this](broker::key_type key,
335335
broker::lock_type locktype,
@@ -382,10 +382,12 @@ namespace cbdc::parsec::agent {
382382
}
383383
}
384384

385-
void impl::handle_run(const runner::interface::run_return_type& res) {
385+
void
386+
impl::handle_run_result(const runner::interface::run_return_type& res) {
386387
std::unique_lock l(m_mut);
387388
if(m_state != state::function_started) {
388-
m_log->warn("handle_run while not in function_started state");
389+
m_log->warn(
390+
"handle_run_result while not in function_started state");
389391
return;
390392
}
391393
std::visit(
@@ -418,7 +420,7 @@ namespace cbdc::parsec::agent {
418420
}},
419421
res);
420422
m_log->trace(this,
421-
"Agent handle_run complete for",
423+
"Agent handle_run_result complete for",
422424
m_ticket_number.value());
423425
}
424426

src/parsec/agent/impl.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ namespace cbdc::parsec::agent {
130130
void
131131
handle_function(const broker::interface::try_lock_return_type& res);
132132

133-
void handle_run(const runner::interface::run_return_type& res);
133+
void handle_run_result(const runner::interface::run_return_type& res);
134134

135135
void handle_commit(broker::interface::commit_return_type res);
136136

137-
void do_start();
137+
void do_start_function();
138138

139139
void do_result();
140140

src/parsec/agent/runners/evm/impl.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ namespace cbdc::parsec::agent::runner {
428428
return true;
429429
}
430430
auto from = maybe_from.value();
431-
return run_execute_transaction(from, false);
431+
return start_execute_transaction(from, false);
432432
}
433433

434434
auto evm_runner::run_execute_dryrun_transaction() -> bool {
@@ -441,7 +441,7 @@ namespace cbdc::parsec::agent::runner {
441441
auto& dryrun_tx = maybe_tx.value();
442442
m_tx = std::move(dryrun_tx.m_tx);
443443

444-
return run_execute_transaction(dryrun_tx.m_from, true);
444+
return start_execute_transaction(dryrun_tx.m_from, true);
445445
}
446446

447447
auto evm_runner::check_base_gas(const evm_tx& evmtx, bool is_readonly_run)
@@ -519,8 +519,8 @@ namespace cbdc::parsec::agent::runner {
519519
return tx_ctx;
520520
}
521521

522-
auto evm_runner::run_execute_transaction(const evmc::address& from,
523-
bool is_readonly_run) -> bool {
522+
auto evm_runner::start_execute_transaction(const evmc::address& from,
523+
bool is_readonly_run) -> bool {
524524
auto tx_ctx = make_tx_context(from, m_tx, is_readonly_run);
525525

526526
m_host = std::make_unique<evm_host>(m_log,
@@ -549,7 +549,7 @@ namespace cbdc::parsec::agent::runner {
549549
broker::lock_type::write,
550550
[this](const broker::interface::try_lock_return_type& res) {
551551
m_log->trace(m_ticket_number, "read from account");
552-
handle_lock_from_account(res);
552+
handle_lockfromaccount_and_continue_exec(res);
553553
});
554554
if(!r) {
555555
m_log->error(
@@ -620,7 +620,7 @@ namespace cbdc::parsec::agent::runner {
620620
}
621621
}
622622

623-
void evm_runner::handle_lock_from_account(
623+
void evm_runner::handle_lockfromaccount_and_continue_exec(
624624
const broker::interface::try_lock_return_type& res) {
625625
if(!std::holds_alternative<broker::value_type>(res)) {
626626
m_log->debug("Failed to read account from shards");
@@ -684,7 +684,7 @@ namespace cbdc::parsec::agent::runner {
684684
return;
685685
}
686686
m_log->trace(m_ticket_number, "locked TXID key");
687-
lock_ticket_number_key();
687+
lock_ticket_number_key_and_continue_exec();
688688
});
689689
if(!maybe_sent) {
690690
m_log->error("Failed to send try_lock request for TX receipt");
@@ -693,7 +693,7 @@ namespace cbdc::parsec::agent::runner {
693693
}
694694
}
695695

696-
void evm_runner::lock_ticket_number_key() {
696+
void evm_runner::lock_ticket_number_key_and_continue_exec() {
697697
auto maybe_sent = m_try_lock_callback(
698698
m_host->ticket_number_key(),
699699
broker::lock_type::write,

src/parsec/agent/runners/evm/impl.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ namespace cbdc::parsec::agent::runner {
8989
auto run_get_account_code() -> bool;
9090
auto run_get_transaction() -> bool;
9191
auto run_get_transaction_receipt() -> bool;
92-
auto run_execute_transaction(const evmc::address& from,
93-
bool is_readonly_run) -> bool;
92+
auto start_execute_transaction(const evmc::address& from,
93+
bool is_readonly_run) -> bool;
9494
auto run_get_account() -> bool;
9595
auto run_get_block() -> bool;
9696
auto run_get_logs() -> bool;
@@ -107,10 +107,10 @@ namespace cbdc::parsec::agent::runner {
107107
bool is_readonly_run)
108108
-> std::pair<evmc_message, bool>;
109109

110-
void handle_lock_from_account(
110+
void handle_lockfromaccount_and_continue_exec(
111111
const broker::interface::try_lock_return_type& res);
112112

113-
void lock_ticket_number_key();
113+
void lock_ticket_number_key_and_continue_exec();
114114
void lock_index_keys(const std::function<void()>& callback);
115115
void schedule_exec();
116116

0 commit comments

Comments
 (0)