oracle: add coingecko demo and pro tier support#10
oracle: add coingecko demo and pro tier support#10martonp merged 2 commits intobisoncraft:masterfrom
Conversation
martonp
left a comment
There was a problem hiding this comment.
Some untested suggestions: 57fd504
There is a free demo tier with an API key. I think we should prefer this one over a public API key version. This gives us confidence that we get 10k requests per month. The key endpoint is disabled on the demo tier, so we can track the usage locally, saving to a file to persist usage across restarts. I hardcoded 9500 (it's actually 10k, 9500 for safety) for the monthly quota, but maybe this should be configured rather than hardcoded.
The way you have it currently, combining the unlimited tier with the tracked tier, with two different minimum periods, will not allow the deterministic fetch ordering to work properly. The deterministic ordering requires the minimum period to be the same for all nodes on the network. Also, unlimited nodes will basically never be selected to fetch first if anyone is on a pro tier.
4591a1a to
4ae30ab
Compare
4ae30ab to
d51095d
Compare
|
Good catch, made the suggested changes and covered with more tests. The monthly limit is configurable now and defaults to 9800 (bumped it up from 9500). |
5937f46 to
0286abf
Compare
… tracking Implement unified CoinGecko provider supporting demo (file-based quota) and pro (API-based quota) tiers. Demo tier persists 9,800 monthly credits in local JSON with automatic monthly reset. Pro tier tracks quota via /api/v3/key endpoint. Both tiers use MinPeriod=30s for consistent fetch ordering. New FileTrackedSource utility manages file-based quota state with thread-safe credit consumption. Includes comprehensive unit and integration tests for both tiers.
- move AtomicWriteFile to oracle/sources/utils/file.go for shared use - update saveQuotaToFile to use AtomicWriteFile instead of os.WriteFile
74cc0a1 to
d0313d4
Compare
This implements unified CoinGecko provider supporting demo (file-based quota) and pro (API-based quota) tiers. Demo tier persists 9,800 monthly credits in local JSON with automatic monthly reset. Pro tier tracks quota via /api/v3/key endpoint. Both tiers use MinPeriod=30s for consistent fetch ordering. New FileTrackedSource utility manages file-based quota state with thread-safe credit consumption. Includes comprehensive unit and integration tests for both tiers.