@@ -40,7 +40,7 @@ namespace fc::blockchain::production {
40
40
epoch_{std::move (epoch_clock)},
41
41
chain_weight_calculator_{std::move (weight_calculator)},
42
42
bls_provider_{std::move (crypto_provider)},
43
- vm_interpreter_{interpreter} {}
43
+ vm_interpreter_{std::move ( interpreter) } {}
44
44
45
45
outcome::result<BlockProducer::Block> BlockProducerImpl::generate (
46
46
primitives::address::Address miner_address,
@@ -56,7 +56,7 @@ namespace fc::blockchain::production {
56
56
chain_weight_calculator_->calculateWeight (parent_tipset));
57
57
std::vector<SignedMessage> messages =
58
58
message_storage_->getTopScored (config::kBlockMaxMessagesCount );
59
- MsgMeta msg_meta = getMessagesMeta (messages);
59
+ OUTCOME_TRY ( msg_meta, getMessagesMeta (messages) );
60
60
std::vector<UnsignedMessage> bls_messages;
61
61
std::vector<SignedMessage> secp_messages;
62
62
std::vector<crypto::bls::Signature> bls_signatures;
@@ -107,35 +107,32 @@ namespace fc::blockchain::production {
107
107
if (tipset.has_error ()) {
108
108
return BlockProducerError::PARENT_TIPSET_INVALID_CONTENT;
109
109
}
110
- return std::move ( tipset.value () );
110
+ return tipset.value ();
111
111
}
112
112
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) {
115
116
auto bls_backend = std::make_shared<InMemoryDatastore>();
116
117
auto secp_backend = std::make_shared<InMemoryDatastore>();
117
118
Amt bls_messages_amt{bls_backend};
118
119
Amt secp_messages_amt{secp_backend};
119
120
for (size_t index = 0 ; index < messages.size (); ++index) {
120
121
const SignedMessage &msg = messages.at (index);
121
- visit_in_place (
122
+ BOOST_OUTCOME_TRY_INVOKE_TRY1 ( visit_in_place (
122
123
msg.signature ,
123
124
[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);
127
126
},
128
127
[index, &msg, &secp_messages_amt](
129
128
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
+ }));
134
131
}
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) );
139
136
MsgMeta msg_meta{};
140
137
msg_meta.bls_messages = bls_root.getCID ();
141
138
msg_meta.secpk_messages = secp_root.getCID ();
0 commit comments