Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function argument list tweak for runtime_state db functions #130

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions silkworm/node/db/access_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ std::optional<ByteView> read_runtime_states_bytes(ROTxn& txn, RuntimeState runti
return from_slice(data.value);
}

void write_runtime_states_bytes(RWTxn& txn, const Bytes value, RuntimeState runtime_state) {
void write_runtime_states_bytes(RWTxn& txn, RuntimeState runtime_state, const Bytes value) {
auto cursor = txn.rw_cursor(table::kRuntimeStates);
auto key{db::block_key(runtime_state)};
cursor->upsert(to_slice(key), db::to_slice(value));
Expand All @@ -1214,9 +1214,9 @@ std::optional<uint64_t> read_runtime_states_u64(ROTxn& txn, RuntimeState runtime
return num;
}

void write_runtime_states_u64(RWTxn& txn, uint64_t num, RuntimeState runtime_state) {
void write_runtime_states_u64(RWTxn& txn, RuntimeState runtime_state, uint64_t num) {
Bytes value{db::block_key(num)};
write_runtime_states_bytes(txn, value, runtime_state);
write_runtime_states_bytes(txn, runtime_state, value);
}

std::optional<eosevm::ConsensusParameters> read_consensus_parameters(ROTxn& txn, BlockNum index) {
Expand Down
4 changes: 2 additions & 2 deletions silkworm/node/db/access_layer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,13 @@ void write_last_finalized_block(RWTxn& txn, const evmc::bytes32& hash);
std::optional<ByteView> read_runtime_states_bytes(ROTxn& txn, RuntimeState runtime_state);

//! \brief Write runtime states by index
void write_runtime_states_bytes(RWTxn& txn, const Bytes value, RuntimeState runtime_state);
void write_runtime_states_bytes(RWTxn& txn, RuntimeState runtime_state, const Bytes value);

//! \brief Read runtime states by index as uint64_t
std::optional<uint64_t> read_runtime_states_u64(ROTxn& txn, RuntimeState runtime_state);

//! \brief Write uint64_t as runtime states by index
void write_runtime_states_u64(RWTxn& txn, uint64_t num, RuntimeState runtime_state);
void write_runtime_states_u64(RWTxn& txn, RuntimeState runtime_state, uint64_t num);

//! \brief Read ConsensusParameters indexed by blocknum that it is added.
std::optional<eosevm::ConsensusParameters> read_consensus_parameters(ROTxn& txn, BlockNum index);
Expand Down
12 changes: 6 additions & 6 deletions silkworm/node/db/access_layer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,14 +875,14 @@ TEST_CASE("RuntimeStates_u64") {

CHECK(read_runtime_states_u64(txn, kLibProcessed) == std::nullopt);

write_runtime_states_u64(txn, value1, index );
write_runtime_states_u64(txn, index, value1);
CHECK(read_runtime_states_u64(txn, index) == value1);

write_runtime_states_u64(txn, value1, RuntimeState(1) );
write_runtime_states_u64(txn, RuntimeState(1), value1);
CHECK(read_runtime_states_u64(txn, RuntimeState(1)) == value1);


write_runtime_states_u64(txn, value2, index );
write_runtime_states_u64(txn, index, value2);
CHECK(read_runtime_states_u64(txn, index) == value2);

CHECK(read_runtime_states_u64(txn, RuntimeState(1)) == value1);
Expand All @@ -901,14 +901,14 @@ TEST_CASE("RuntimeStates_bytes") {

CHECK(read_runtime_states_bytes(txn, kLibProcessed) == std::nullopt);

write_runtime_states_bytes(txn, value1, index );
write_runtime_states_bytes(txn, index, value1);
CHECK(read_runtime_states_bytes(txn, index) == value1);

write_runtime_states_bytes(txn, value1, RuntimeState(1) );
write_runtime_states_bytes(txn, RuntimeState(1), value1);
CHECK(read_runtime_states_bytes(txn, RuntimeState(1)) == value1);


write_runtime_states_bytes(txn, value2, index );
write_runtime_states_bytes(txn, index, value2);
CHECK(read_runtime_states_bytes(txn, index) == value2);

CHECK(read_runtime_states_bytes(txn, RuntimeState(1)) == value1);
Expand Down
Loading