Skip to content

Commit 8093d91

Browse files
Copilotmaxtropetsachamayou
authored
Handle incomplete network identity fetching consistently (#7703)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: maxtropets <16566519+maxtropets@users.noreply.github.com> Co-authored-by: Amaury Chamayou <amchamay@microsoft.com>
1 parent 8aa4e8f commit 8093d91

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

include/ccf/network_identity_interface.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ namespace ccf
5050
[[nodiscard]] virtual FetchStatus endorsements_fetching_status() const = 0;
5151

5252
/// Returns the COSE endorsements chain for the given sequence number,
53-
/// or std::nullopt if endorsement fetching has not completed or the
54-
/// chain is not available for the given sequence number.
53+
/// or std::nullopt if the chain is not available for the given sequence
54+
/// number.
55+
///
56+
/// @throws std::logic_error if endorsement fetching has not completed.
5557
[[nodiscard]] virtual std::optional<CoseEndorsementsChain>
5658
get_cose_endorsements_chain(ccf::SeqNo seqno) const = 0;
5759

src/node/rpc/network_identity_subsystem.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,12 @@ namespace ccf
142142
[[nodiscard]] std::optional<CoseEndorsementsChain>
143143
get_cose_endorsements_chain(ccf::SeqNo seqno) const override
144144
{
145-
// All other cases must be handled after recovery has been completed and
146-
// identities have been successfully fetched.
147145
if (fetch_status.load() != FetchStatus::Done)
148146
{
149-
return std::nullopt;
147+
throw std::logic_error(fmt::format(
148+
"COSE endorsements chain requested for seqno {} but endorsement "
149+
"fetching has not been completed yet",
150+
seqno));
150151
}
151152

152153
if (!current_service_from.has_value())

0 commit comments

Comments
 (0)