Skip to content

Commit ea101e7

Browse files
committed
CR fixes
1 parent d3238c6 commit ea101e7

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

core/blockchain/production/impl/block_producer_impl.cpp

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace fc::blockchain::production {
4040
epoch_{std::move(epoch_clock)},
4141
chain_weight_calculator_{std::move(weight_calculator)},
4242
bls_provider_{std::move(crypto_provider)},
43-
vm_interpreter_{interpreter} {}
43+
vm_interpreter_{std::move(interpreter)} {}
4444

4545
outcome::result<BlockProducer::Block> BlockProducerImpl::generate(
4646
primitives::address::Address miner_address,
@@ -56,7 +56,7 @@ namespace fc::blockchain::production {
5656
chain_weight_calculator_->calculateWeight(parent_tipset));
5757
std::vector<SignedMessage> messages =
5858
message_storage_->getTopScored(config::kBlockMaxMessagesCount);
59-
MsgMeta msg_meta = getMessagesMeta(messages);
59+
OUTCOME_TRY(msg_meta, getMessagesMeta(messages));
6060
std::vector<UnsignedMessage> bls_messages;
6161
std::vector<SignedMessage> secp_messages;
6262
std::vector<crypto::bls::Signature> bls_signatures;
@@ -107,35 +107,32 @@ namespace fc::blockchain::production {
107107
if (tipset.has_error()) {
108108
return BlockProducerError::PARENT_TIPSET_INVALID_CONTENT;
109109
}
110-
return std::move(tipset.value());
110+
return tipset.value();
111111
}
112112

113-
BlockProducerImpl::MsgMeta BlockProducerImpl::getMessagesMeta(
114-
const std::vector<SignedMessage> &messages) const {
113+
outcome::result<BlockProducerImpl::MsgMeta>
114+
BlockProducerImpl::getMessagesMeta(
115+
const std::vector<SignedMessage> &messages) {
115116
auto bls_backend = std::make_shared<InMemoryDatastore>();
116117
auto secp_backend = std::make_shared<InMemoryDatastore>();
117118
Amt bls_messages_amt{bls_backend};
118119
Amt secp_messages_amt{secp_backend};
119120
for (size_t index = 0; index < messages.size(); ++index) {
120121
const SignedMessage &msg = messages.at(index);
121-
visit_in_place(
122+
BOOST_OUTCOME_TRY_INVOKE_TRY1(visit_in_place(
122123
msg.signature,
123124
[index, &msg, &bls_messages_amt](const BlsSignature &signature) {
124-
auto result = bls_messages_amt.setCbor(index, msg);
125-
BOOST_ASSERT_MSG(!result.has_error(),
126-
"BlockGenerator: failed to create messages AMT");
125+
return bls_messages_amt.setCbor(index, msg);
127126
},
128127
[index, &msg, &secp_messages_amt](
129128
const Secp256k1Signature &signature) {
130-
auto result = secp_messages_amt.setCbor(index, msg);
131-
BOOST_ASSERT_MSG(!result.has_error(),
132-
"BlockGenerator: failed to create messages AMT");
133-
});
129+
return secp_messages_amt.setCbor(index, msg);
130+
}));
134131
}
135-
Root bls_root =
136-
bls_backend->getCbor<Root>(bls_messages_amt.flush().value()).value();
137-
Root secp_root =
138-
secp_backend->getCbor<Root>(secp_messages_amt.flush().value()).value();
132+
OUTCOME_TRY(bls_root_cid, bls_messages_amt.flush());
133+
OUTCOME_TRY(bls_root, bls_backend->getCbor<Root>(bls_root_cid));
134+
OUTCOME_TRY(secp_root_cid, secp_messages_amt.flush());
135+
OUTCOME_TRY(secp_root, secp_backend->getCbor<Root>(secp_root_cid));
139136
MsgMeta msg_meta{};
140137
msg_meta.bls_messages = bls_root.getCID();
141138
msg_meta.secpk_messages = secp_root.getCID();

core/blockchain/production/impl/block_producer_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ namespace fc::blockchain::production {
7979
* @param messages - messages to include in the new Block
8080
* @return Generated meta-data
8181
*/
82-
MsgMeta getMessagesMeta(const std::vector<SignedMessage> &messages) const;
82+
static outcome::result<MsgMeta> getMessagesMeta(
83+
const std::vector<SignedMessage> &messages);
8384
};
8485
} // namespace fc::blockchain::production

core/storage/ipld/ipld_block.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ namespace fc::storage::ipld {
3838
* Children class must overload it to support structure serialization
3939
* @return Serialized value
4040
*/
41-
virtual common::Buffer serialize() const {
42-
return {};
43-
}
41+
virtual common::Buffer serialize() const = 0;
4442
};
4543
} // namespace fc::storage::ipld
4644

0 commit comments

Comments
 (0)