Skip to content

Commit

Permalink
feat: handling for "accepted" but not replied sync call
Browse files Browse the repository at this point in the history
  • Loading branch information
krpeacock committed Jul 23, 2024
1 parent 81ad181 commit 2264d3d
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/agent/src/actor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -541,12 +541,24 @@ function _createActorMethod(
blsVerify,
});
const path = [new TextEncoder().encode('request_status'), requestId];
reply = lookupResultToBuffer(certificate.lookup([...path, 'reply']));
} else {
// if (!response.ok || response.body /* IC-1462 */) {
// throw new UpdateCallRejectedError(cid, methodName, requestId, response);
// }

const status = new TextDecoder().decode(
lookupResultToBuffer(certificate.lookup([...path, 'status'])),
);

switch (status) {
case 'replied':
reply = lookupResultToBuffer(certificate.lookup([...path, 'reply']));
break;
case 'rejected':
throw new UpdateCallRejectedError(cid, methodName, requestId, response);
case 'accepted':
// The certificate is not yet ready, so we need to poll for the response
break;
case 'default':
throw new ActorCallError(cid, methodName, 'update', { requestId: toHex(requestId) });
}
}
if (reply === undefined) {
const pollStrategy = pollingStrategyFactory();
// Contains the certificate and the reply from the boundary node
const response = await pollForResponse(agent, ecid, requestId, pollStrategy, blsVerify);
Expand Down

0 comments on commit 2264d3d

Please sign in to comment.