diff --git a/package.json b/package.json index 449b31b..33f881d 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,8 @@ "test:integration:local": "RESTURL=http://localhost:3000/v4/ mocha --timeout 30000 test/integration", "test:integration:local:bchn": "RESTURL=http://localhost:3000/v4/ bash test/integration/test-bchn-integration.sh", "test:integration:local:testnet": "RESTURL=http://localhost:4000/v4/ mocha --timeout 30000 test/integration/testnet", - "test:temp": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 -g '#validateTxid2' test/integration/", - "test:temp2": "mocha --timeout 30000 -g 'tokenUtxoDetails' test/unit/", + "test:temp": "export RESTURL=http://localhost:3000/v4/ && mocha --timeout 30000 -g '#tokenUtxoDetails' test/integration/", + "test:temp2": "mocha --timeout 30000 -g '#tokenUtxoDetails' test/unit/", "coverage": "nyc report --reporter=text-lcov | coveralls", "coverage:report": "nyc --reporter=html mocha --timeout 25000 test/unit/", "docs": "./node_modules/.bin/apidoc -i src/ -o docs" diff --git a/src/slp/utils.js b/src/slp/utils.js index 6cb36d3..2db1cb4 100644 --- a/src/slp/utils.js +++ b/src/slp/utils.js @@ -453,9 +453,9 @@ class Utils { }, _this.axiosOptions ) - console.log( - `validateTxid response.data: ${JSON.stringify(response.data, null, 2)}` - ) + // console.log( + // `validateTxid response.data: ${JSON.stringify(response.data, null, 2)}` + // ) const validatedTxids = response.data @@ -1058,7 +1058,7 @@ class Utils { // utxo list may have duplicate tx_hash, varying tx_pos // only need to call decodeOpReturn once for those const decodeOpReturnCache = {} - // const cachedTxValidation = {} + const cachedTxValidation = {} // Throw error if input is not an array. if (!Array.isArray(utxos)) throw new Error("Input must be an array.") @@ -1297,8 +1297,9 @@ class Utils { // CT 12/13/2020: Disabling the cache until I get processing of tokens // to be more stable. // If the value has been cached, use the cached version first. - // let isValid = cachedTxValidation[utxo.txid] - let isValid = null + let isValid = cachedTxValidation[utxo.txid] + if (!isValid) isValid = null + // let isValid = null // There are two possible responses from SLPDB. If SLPDB is functioning // correctly, then validateTxid() will return this: @@ -1404,6 +1405,9 @@ class Utils { // console.log(`isValid: ${JSON.stringify(isValid, null, 2)}`) outAry[i].isValid = isValid + + // Save the txid to the local cache to reduce API calls. + cachedTxValidation[utxo.txid] = isValid } }