MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / cache_proposal

Method cache_proposal

mlspp/src/state.cpp:1236–1267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1234}
1235
1236void
1237State::cache_proposal(AuthenticatedContent content_auth)
1238{
1239 auto ref = _suite.ref(content_auth);
1240 if (stdx::any_of(_pending_proposals,
1241 [&](const auto& cached) { return cached.ref == ref; })) {
1242 return;
1243 }
1244
1245 auto sender_location = std::optional<LeafIndex>();
1246 if (content_auth.content.sender.sender_type() == SenderType::member) {
1247 const auto& sender = content_auth.content.sender.sender;
1248 sender_location = var::get<MemberSender>(sender).sender;
1249 }
1250
1251 const auto& proposal = var::get<Proposal>(content_auth.content.content);
1252
1253 if (content_auth.content.sender.sender_type() == SenderType::external &&
1254 !valid_external_proposal_type(proposal.proposal_type())) {
1255 throw ProtocolError("Invalid external proposal");
1256 }
1257
1258 if (!valid(sender_location, proposal)) {
1259 throw ProtocolError("Invalid proposal");
1260 }
1261
1262 _pending_proposals.push_back({
1263 _suite.ref(content_auth),
1264 proposal,
1265 sender_location,
1266 });
1267}
1268
1269std::optional<State::CachedProposal>
1270State::resolve(const ProposalOrRef& id,

Callers

nothing calls this directly

Calls 6

any_ofFunction · 0.85
ProtocolErrorClass · 0.85
sender_typeMethod · 0.80
proposal_typeMethod · 0.80
push_backMethod · 0.80
refMethod · 0.45

Tested by

no test coverage detected