@bancor/carbon-sdk
Advanced tools
Comparing version 0.0.64-DEV to 0.0.65-DEV
@@ -5,3 +5,3 @@ { | ||
"source": "src/index.ts", | ||
"version": "0.0.64-DEV", | ||
"version": "0.0.65-DEV", | ||
"description": "The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfill trades", | ||
@@ -8,0 +8,0 @@ "main": "dist/sdk.umd.js", |
@@ -27,2 +27,4 @@ import { | ||
import EventEmitter from 'events'; | ||
import { Logger } from '../logger'; | ||
const logger = new Logger('ChainCache.ts'); | ||
@@ -137,3 +139,5 @@ const schemeVersion = 1; // bump this when the serialization format changes | ||
logger.debug('Cache miss for pair', token0, token1); | ||
await this._handleCacheMiss(token0, token1); | ||
logger.debug('Cache miss for pair', token0, token1, 'resolved'); | ||
} | ||
@@ -235,2 +239,3 @@ | ||
): void { | ||
logger.debug('Adding pair to cache', token0, token1); | ||
const key = toPairKey(token0, token1); | ||
@@ -245,3 +250,6 @@ if (this._strategiesByPair.has(key)) { | ||
}); | ||
if (!noPairAddedEvent) this.emit('onPairAddedToCache', fromPairKey(key)); | ||
if (!noPairAddedEvent) { | ||
logger.debug('Emitting onPairAddedToCache', token0, token1); | ||
this.emit('onPairAddedToCache', fromPairKey(key)); | ||
} | ||
} | ||
@@ -273,2 +281,9 @@ | ||
): void { | ||
logger.debug('Applying batched updates to cache', { | ||
latestBlockNumber, | ||
latestTrades, | ||
createdStrategies, | ||
updatedStrategies, | ||
deletedStrategies, | ||
}); | ||
const affectedPairs = new Set<string>(); | ||
@@ -293,3 +308,4 @@ latestTrades.forEach((trade) => { | ||
if (affectedPairs.size > 0) | ||
if (affectedPairs.size > 0) { | ||
logger.debug('Emitting onPairDataChanged', affectedPairs); | ||
this.emit( | ||
@@ -299,2 +315,3 @@ 'onPairDataChanged', | ||
); | ||
} | ||
} | ||
@@ -368,3 +385,6 @@ | ||
if (this._strategiesById.has(strategy.id.toString())) { | ||
throw new Error(`Strategy ${strategy.id} already cached`); | ||
logger.debug( | ||
`Strategy ${strategy.id} already cached, under the pair ${key} - skipping` | ||
); | ||
return; | ||
} | ||
@@ -371,0 +391,0 @@ const strategies = this._strategiesByPair.get(key) || []; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2553973
39292