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

query methods #244

Open lastmjs opened 11 months ago

lastmjs commented 11 months ago

Can we add some query methods to this? Seems like payment should only be required to get the latest response...but couldn't old responses be cached and available once the current response has been received?

I'm sure this has been discussed, just wondering if I can bring this up.

THLO commented 11 months ago

Yes, this has been discussed. There is a small LRU cache of previously requested rates. Since the cache is small, you won't be able to retrieve many old responses. On the contrary, you may only get recent rates, obviously just for pairs that were previously requested.

However, it doesn't cost much to increase the cache size and making a quick query call to check if there is a rate doesn't cost much, either. It may even be possible to increase the probability of success by asking for a rate in a certain time window (in the past).

Would it be useful to have a query endpoint that won't give you the most recent rate (as you said, payment should probably be required for this rate) and will only give you old rates in the recent past (that can be retrieved from the cache)? If yes, do you think the cached rates should be certified?

liucanhui-eng commented 5 months ago

No matter what time I give, it returns (# ForexInvalidTimestamp) What should I do?