Skip to content

Commit 3a48796

Browse files
committed
refactor block_cache emplace
1 parent befa36d commit 3a48796

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

cmd/monad/runloop_monad.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,27 +183,25 @@ Result<BlockExecOutput> propose_block(
183183
return TransactionError::MissingSender;
184184
}
185185
}
186-
ankerl::unordered_dense::segmented_set<Address> senders_and_authorities;
186+
187+
auto [entry, success] = block_cache.emplace(
188+
block_id,
189+
BlockCacheEntry{
190+
.block_number = block.header.number,
191+
.parent_id = consensus_header.parent_id(),
192+
.senders_and_authorities = {}});
193+
MONAD_ASSERT(success, "should never be processing duplicate block");
187194
for (Address const &sender : senders) {
188-
senders_and_authorities.insert(sender);
195+
entry->second.senders_and_authorities.insert(sender);
189196
}
190197
for (std::vector<std::optional<Address>> const &authorities :
191198
recovered_authorities) {
192199
for (std::optional<Address> const &authority : authorities) {
193200
if (authority.has_value()) {
194-
senders_and_authorities.insert(authority.value());
201+
entry->second.senders_and_authorities.insert(authority.value());
195202
}
196203
}
197204
}
198-
MONAD_ASSERT(block_cache
199-
.emplace(
200-
block_id,
201-
BlockCacheEntry{
202-
.block_number = block.header.number,
203-
.parent_id = consensus_header.parent_id(),
204-
.senders_and_authorities =
205-
std::move(senders_and_authorities)})
206-
.second);
207205
BOOST_OUTCOME_TRY(static_validate_monad_senders<traits>(senders));
208206

209207
// Create call frames vectors for tracers

0 commit comments

Comments
 (0)