dfinity / exchange-rate-canister

The exchange rate canister (XRC) makes use of the HTTP requests feature to provide exchange rates as a service to the IC.
Apache License 2.0
37 stars 10 forks source link

feat: Add the ability to mark requests as pending #152

Closed dfinity-ryancroote closed 1 year ago

dfinity-ryancroote commented 1 year ago

This PR adds the ability to track pending requests. A request is determined as pending when one of the assets is currently in process of being retrieved from the exchanges.

For example, the XRC receives a request X for ICP/BTC at timestamp 100. While the XRC starts processing request X, another request (Y) for BTC/USDT at timestamp 100 is received. The XRC canister adds the following symbol-timestamp pairs to the tracking set from request X: ("ICP", 100) and ("BTC", 100).

While waiting for request X's results, the XRC begins to process request Y. As request Y contains the symbol-timestamp pair ("BTC", 100), request Y is determined to be pending and the Pending error is returned to the user.