@exodus/market-history 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/market-history@3.0.1...@exodus/market-history@3.1.0) (2023-04-11)
7
+
8
+ ### Features
9
+
10
+ - don't call setCache when no changes ([#1166](https://github.com/ExodusMovement/exodus-hydra/issues/1166)) ([522ce5d](https://github.com/ExodusMovement/exodus-hydra/commit/522ce5d18b2b79c170f50a43d5020f55149b3c93))
11
+
6
12
  ## [3.0.1](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/market-history@3.0.0...@exodus/market-history@3.0.1) (2023-03-23)
7
13
 
8
14
  ### Bug Fixes
package/module/index.js CHANGED
@@ -93,16 +93,19 @@ class MarketHistoryMonitor extends ExodusModule {
93
93
  #started = false
94
94
 
95
95
  #setCache = async ({ currency, granularity, pricesByAssetName }) => {
96
+ let hasChanges = false
96
97
  const changes = Object.keys(pricesByAssetName).reduce((acc, assetName) => {
97
98
  const key = this.#getCacheKey({ currency, assetName, granularity })
98
99
  const values = pricesByAssetName[assetName]
99
100
  if (values.length > 0) {
101
+ hasChanges = true
100
102
  acc[key] = values
101
103
  this.#runtimeCache.set(key, values)
102
104
  }
103
105
  return acc
104
106
  }, {})
105
107
 
108
+ if (!hasChanges) return
106
109
  await this.storage.batchSet(changes)
107
110
  }
108
111
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/market-history",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "module to fetch historical prices for assets",
5
5
  "author": "Exodus Movement Inc",
6
6
  "license": "UNLICENSED",
@@ -33,5 +33,5 @@
33
33
  "peerDependencies": {
34
34
  "debug": ">= 3.0.0"
35
35
  },
36
- "gitHead": "889b464aa67ba78e6582b0b84daa7775c141d015"
36
+ "gitHead": "6504aa18e7865e9de64f138ed2c07ed8a55186b8"
37
37
  }
package/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- let assetFromTickerCache = {}
1
+ const assetFromTickerCache = {}
2
2
  export const getAssetFromTicker = (assets, ticker) => {
3
3
  if (assetFromTickerCache[ticker]) return assetFromTickerCache[ticker]
4
4
  return Object.values(assets).find((asset) => {