From f2b8ba5f36a6872ace2e2f7ea75b6fbdeb0e47fb Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Wed, 5 Dec 2018 11:19:51 +0200 Subject: [PATCH 1/6] chore(core-api): increase cache generation timeout for block and transaction endpoints (#1645) --- .circleci/config.yml | 9 +++++---- packages/core-api/CHANGELOG.md | 4 ++++ packages/core-api/lib/versions/1/methods/blocks.js | 4 ++-- packages/core-api/lib/versions/1/methods/transactions.js | 4 ++-- packages/core-api/lib/versions/2/methods/blocks.js | 8 ++++---- packages/core-api/lib/versions/2/methods/delegates.js | 2 +- packages/core-api/lib/versions/2/methods/transactions.js | 6 +++--- packages/core-api/lib/versions/2/methods/votes.js | 4 ++-- packages/core-api/lib/versions/2/methods/wallets.js | 8 ++++---- 9 files changed, 27 insertions(+), 22 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 26f18d7ca2..25bab42224 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -72,10 +72,11 @@ jobs: ./node_modules/.bin/cross-env ARK_ENV=test ./node_modules/.bin/jest ./packages/core-vote-report/ ./packages/core-transaction-pool/ ./packages/core-snapshots-cli/ ./packages/core-logger-winston/ - ./packages/core-http-utils/ ./packages/core-event-emitter/ + ./packages/core-api/ ./packages/core-event-emitter/ ./packages/core-elasticsearch/ ./packages/core-database-postgres/ - ./packages/core-config/ ./packages/core/ --detectOpenHandles - --runInBand --forceExit --ci --coverage | tee test_output.txt + ./packages/core-config/ ./packages/core-http-utils/ + --detectOpenHandles --runInBand --forceExit --ci --coverage | tee + test_output.txt - run: name: Last 1000 lines of test output when: on_fail @@ -157,7 +158,7 @@ jobs: ./packages/core-test-utils/ ./packages/core-p2p/ ./packages/core-json-rpc/ ./packages/core-forger/ ./packages/core-error-tracker-bugsnag/ ./packages/core-debugger-cli/ - ./packages/core-container/ ./packages/core-api/ --detectOpenHandles + ./packages/core-container/ ./packages/core/ --detectOpenHandles --runInBand --forceExit --ci --coverage | tee test_output.txt - run: name: Last 1000 lines of test output diff --git a/packages/core-api/CHANGELOG.md b/packages/core-api/CHANGELOG.md index 9083caa38a..974c5357d4 100644 --- a/packages/core-api/CHANGELOG.md +++ b/packages/core-api/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +### Changed + +- Increase cache generation timeout for block and transaction endpoints + ## 0.2.11 - 2018-12-05 ### Fixed diff --git a/packages/core-api/lib/versions/1/methods/blocks.js b/packages/core-api/lib/versions/1/methods/blocks.js index df3870b17f..accd19ffbf 100644 --- a/packages/core-api/lib/versions/1/methods/blocks.js +++ b/packages/core-api/lib/versions/1/methods/blocks.js @@ -37,7 +37,7 @@ module.exports = server => { server.method('v1.blocks.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -50,7 +50,7 @@ module.exports = server => { server.method('v1.blocks.show', show, { cache: { expiresIn: 600 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.query.id }), diff --git a/packages/core-api/lib/versions/1/methods/transactions.js b/packages/core-api/lib/versions/1/methods/transactions.js index e0998c3e05..f6d8c1640a 100644 --- a/packages/core-api/lib/versions/1/methods/transactions.js +++ b/packages/core-api/lib/versions/1/methods/transactions.js @@ -36,7 +36,7 @@ module.exports = server => { server.method('v1.transactions.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -49,7 +49,7 @@ module.exports = server => { server.method('v1.transactions.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.query.id }), diff --git a/packages/core-api/lib/versions/2/methods/blocks.js b/packages/core-api/lib/versions/2/methods/blocks.js index 2ae658908c..71ff2ee08b 100644 --- a/packages/core-api/lib/versions/2/methods/blocks.js +++ b/packages/core-api/lib/versions/2/methods/blocks.js @@ -54,7 +54,7 @@ module.exports = server => { server.method('v2.blocks.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -67,7 +67,7 @@ module.exports = server => { server.method('v2.blocks.show', show, { cache: { expiresIn: 600 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), @@ -76,7 +76,7 @@ module.exports = server => { server.method('v2.blocks.transactions', transactions, { cache: { expiresIn: 600 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -89,7 +89,7 @@ module.exports = server => { server.method('v2.blocks.search', search, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => diff --git a/packages/core-api/lib/versions/2/methods/delegates.js b/packages/core-api/lib/versions/2/methods/delegates.js index f11268cb5c..d4946f9fb6 100644 --- a/packages/core-api/lib/versions/2/methods/delegates.js +++ b/packages/core-api/lib/versions/2/methods/delegates.js @@ -125,7 +125,7 @@ module.exports = server => { server.method('v2.delegates.blocks', blocks, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => diff --git a/packages/core-api/lib/versions/2/methods/transactions.js b/packages/core-api/lib/versions/2/methods/transactions.js index a8532091ed..6ee438fcfe 100644 --- a/packages/core-api/lib/versions/2/methods/transactions.js +++ b/packages/core-api/lib/versions/2/methods/transactions.js @@ -38,7 +38,7 @@ module.exports = server => { server.method('v2.transactions.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -51,7 +51,7 @@ module.exports = server => { server.method('v2.transactions.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), @@ -60,7 +60,7 @@ module.exports = server => { server.method('v2.transactions.search', search, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => diff --git a/packages/core-api/lib/versions/2/methods/votes.js b/packages/core-api/lib/versions/2/methods/votes.js index 297766bd20..a2488820d0 100644 --- a/packages/core-api/lib/versions/2/methods/votes.js +++ b/packages/core-api/lib/versions/2/methods/votes.js @@ -35,7 +35,7 @@ module.exports = server => { server.method('v2.votes.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -48,7 +48,7 @@ module.exports = server => { server.method('v2.votes.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), diff --git a/packages/core-api/lib/versions/2/methods/wallets.js b/packages/core-api/lib/versions/2/methods/wallets.js index c06de18f69..5c7985916f 100644 --- a/packages/core-api/lib/versions/2/methods/wallets.js +++ b/packages/core-api/lib/versions/2/methods/wallets.js @@ -151,7 +151,7 @@ module.exports = server => { server.method('v2.wallets.transactions', transactions, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -165,7 +165,7 @@ module.exports = server => { server.method('v2.wallets.transactionsSent', transactionsSent, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -179,7 +179,7 @@ module.exports = server => { server.method('v2.wallets.transactionsReceived', transactionsReceived, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => @@ -193,7 +193,7 @@ module.exports = server => { server.method('v2.wallets.votes', votes, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout: 8000, getDecoratedValue: true, }, generateKey: request => From 75328312cfcb3047a3908122a82795634f0fcc79 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Wed, 5 Dec 2018 11:47:10 +0200 Subject: [PATCH 2/6] chore(core-api): make cache timeout configurable (#1646) --- packages/core-api/CHANGELOG.md | 2 +- packages/core-api/lib/defaults.js | 19 ++++++++++++++++-- .../lib/versions/1/methods/accounts.js | 12 +++++++---- .../core-api/lib/versions/1/methods/blocks.js | 8 ++++++-- .../lib/versions/1/methods/delegates.js | 14 ++++++++----- .../lib/versions/1/methods/transactions.js | 8 ++++++-- .../core-api/lib/versions/2/methods/blocks.js | 12 +++++++---- .../lib/versions/2/methods/delegates.js | 16 +++++++++------ .../lib/versions/2/methods/transactions.js | 10 +++++++--- .../core-api/lib/versions/2/methods/votes.js | 8 ++++++-- .../lib/versions/2/methods/wallets.js | 20 +++++++++++-------- 11 files changed, 90 insertions(+), 39 deletions(-) diff --git a/packages/core-api/CHANGELOG.md b/packages/core-api/CHANGELOG.md index 974c5357d4..5c6db728e6 100644 --- a/packages/core-api/CHANGELOG.md +++ b/packages/core-api/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed -- Increase cache generation timeout for block and transaction endpoints +- Increase cache generation timeout and make it configurable ## 0.2.11 - 2018-12-05 diff --git a/packages/core-api/lib/defaults.js b/packages/core-api/lib/defaults.js index bef35ca154..0e201f6d40 100644 --- a/packages/core-api/lib/defaults.js +++ b/packages/core-api/lib/defaults.js @@ -4,6 +4,21 @@ module.exports = { enabled: false, host: process.env.ARK_API_HOST || '0.0.0.0', port: process.env.ARK_API_PORT || 4003, + cache: { + /** + * How many seconds the server will try to complete the request and cache the result. + * + * Defaults to 8 seconds, set it to false if you do not care about the timeout. + * + * Setting it to false can result in requests never being completed, which is usually + * caused by low-spec servers that are unable to handle the heavy load that results + * out of SQL queries on the blocks and transactions tables. + * + * If you experience issues with the cache timeout, which is indicated by a 503 status codes, + * you should consider upgrading your hardware or tweak your PostgreSQL settings. + */ + generateTimeout: process.env.ARK_API_CACHE_TIMEOUT || 8000, + }, // @see https://hapijs.com/api#-serveroptionstls ssl: { enabled: process.env.ARK_API_SSL, @@ -23,9 +38,9 @@ module.exports = { rateLimit: { enabled: !process.env.ARK_API_RATE_LIMIT, pathLimit: false, - userLimit: 300, + userLimit: process.env.ARK_API_RATE_LIMIT_USER_LIMIT || 300, userCache: { - expiresIn: 60000, + expiresIn: process.env.ARK_API_RATE_LIMIT_USER_EXPIRES || 60000, }, ipWhitelist: ['127.0.0.1', '::ffff:127.0.0.1'], }, diff --git a/packages/core-api/lib/versions/1/methods/accounts.js b/packages/core-api/lib/versions/1/methods/accounts.js index 74aa8ea00b..fcd7d1f970 100644 --- a/packages/core-api/lib/versions/1/methods/accounts.js +++ b/packages/core-api/lib/versions/1/methods/accounts.js @@ -51,10 +51,14 @@ const publicKey = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v1.accounts.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -67,7 +71,7 @@ module.exports = server => { server.method('v1.accounts.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -77,7 +81,7 @@ module.exports = server => { server.method('v1.accounts.balance', balance, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -87,7 +91,7 @@ module.exports = server => { server.method('v1.accounts.publicKey', publicKey, { cache: { expiresIn: 600 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => diff --git a/packages/core-api/lib/versions/1/methods/blocks.js b/packages/core-api/lib/versions/1/methods/blocks.js index accd19ffbf..f122875cb4 100644 --- a/packages/core-api/lib/versions/1/methods/blocks.js +++ b/packages/core-api/lib/versions/1/methods/blocks.js @@ -34,10 +34,14 @@ const show = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v1.blocks.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -50,7 +54,7 @@ module.exports = server => { server.method('v1.blocks.show', show, { cache: { expiresIn: 600 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.query.id }), diff --git a/packages/core-api/lib/versions/1/methods/delegates.js b/packages/core-api/lib/versions/1/methods/delegates.js index 6ce3b34816..12ff3845c8 100644 --- a/packages/core-api/lib/versions/1/methods/delegates.js +++ b/packages/core-api/lib/versions/1/methods/delegates.js @@ -71,10 +71,14 @@ const voters = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v1.delegates.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -90,7 +94,7 @@ module.exports = server => { server.method('v1.delegates.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -102,7 +106,7 @@ module.exports = server => { server.method('v1.delegates.count', count, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ time: +new Date() }), @@ -111,7 +115,7 @@ module.exports = server => { server.method('v1.delegates.search', search, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -124,7 +128,7 @@ module.exports = server => { server.method('v1.delegates.voters', voters, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.query.publicKey }), diff --git a/packages/core-api/lib/versions/1/methods/transactions.js b/packages/core-api/lib/versions/1/methods/transactions.js index f6d8c1640a..d944826340 100644 --- a/packages/core-api/lib/versions/1/methods/transactions.js +++ b/packages/core-api/lib/versions/1/methods/transactions.js @@ -33,10 +33,14 @@ const show = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v1.transactions.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -49,7 +53,7 @@ module.exports = server => { server.method('v1.transactions.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.query.id }), diff --git a/packages/core-api/lib/versions/2/methods/blocks.js b/packages/core-api/lib/versions/2/methods/blocks.js index 71ff2ee08b..55835b6b4a 100644 --- a/packages/core-api/lib/versions/2/methods/blocks.js +++ b/packages/core-api/lib/versions/2/methods/blocks.js @@ -51,10 +51,14 @@ const search = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v2.blocks.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -67,7 +71,7 @@ module.exports = server => { server.method('v2.blocks.show', show, { cache: { expiresIn: 600 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), @@ -76,7 +80,7 @@ module.exports = server => { server.method('v2.blocks.transactions', transactions, { cache: { expiresIn: 600 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -89,7 +93,7 @@ module.exports = server => { server.method('v2.blocks.search', search, { cache: { expiresIn: 30 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => diff --git a/packages/core-api/lib/versions/2/methods/delegates.js b/packages/core-api/lib/versions/2/methods/delegates.js index d4946f9fb6..0ba8edd0fa 100644 --- a/packages/core-api/lib/versions/2/methods/delegates.js +++ b/packages/core-api/lib/versions/2/methods/delegates.js @@ -86,10 +86,14 @@ const voterBalances = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v2.delegates.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -102,7 +106,7 @@ module.exports = server => { server.method('v2.delegates.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), @@ -111,7 +115,7 @@ module.exports = server => { server.method('v2.delegates.search', search, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -125,7 +129,7 @@ module.exports = server => { server.method('v2.delegates.blocks', blocks, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -138,7 +142,7 @@ module.exports = server => { server.method('v2.delegates.voters', voters, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -151,7 +155,7 @@ module.exports = server => { server.method('v2.delegates.voterBalances', voterBalances, { cache: { expiresIn: 8 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), diff --git a/packages/core-api/lib/versions/2/methods/transactions.js b/packages/core-api/lib/versions/2/methods/transactions.js index 6ee438fcfe..743dd8088c 100644 --- a/packages/core-api/lib/versions/2/methods/transactions.js +++ b/packages/core-api/lib/versions/2/methods/transactions.js @@ -35,10 +35,14 @@ const search = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v2.transactions.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -51,7 +55,7 @@ module.exports = server => { server.method('v2.transactions.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), @@ -60,7 +64,7 @@ module.exports = server => { server.method('v2.transactions.search', search, { cache: { expiresIn: 30 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => diff --git a/packages/core-api/lib/versions/2/methods/votes.js b/packages/core-api/lib/versions/2/methods/votes.js index a2488820d0..ce3061a13c 100644 --- a/packages/core-api/lib/versions/2/methods/votes.js +++ b/packages/core-api/lib/versions/2/methods/votes.js @@ -32,10 +32,14 @@ const show = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v2.votes.index', index, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -48,7 +52,7 @@ module.exports = server => { server.method('v2.votes.show', show, { cache: { expiresIn: 8 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), diff --git a/packages/core-api/lib/versions/2/methods/wallets.js b/packages/core-api/lib/versions/2/methods/wallets.js index 5c7985916f..0576ed99cd 100644 --- a/packages/core-api/lib/versions/2/methods/wallets.js +++ b/packages/core-api/lib/versions/2/methods/wallets.js @@ -116,10 +116,14 @@ const search = async request => { } module.exports = server => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + server.method('v2.wallets.index', index, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -133,7 +137,7 @@ module.exports = server => { server.method('v2.wallets.top', top, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey(utils.paginate(request)), @@ -142,7 +146,7 @@ module.exports = server => { server.method('v2.wallets.show', show, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => generateCacheKey({ id: request.params.id }), @@ -151,7 +155,7 @@ module.exports = server => { server.method('v2.wallets.transactions', transactions, { cache: { expiresIn: 30 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -165,7 +169,7 @@ module.exports = server => { server.method('v2.wallets.transactionsSent', transactionsSent, { cache: { expiresIn: 30 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -179,7 +183,7 @@ module.exports = server => { server.method('v2.wallets.transactionsReceived', transactionsReceived, { cache: { expiresIn: 30 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -193,7 +197,7 @@ module.exports = server => { server.method('v2.wallets.votes', votes, { cache: { expiresIn: 30 * 1000, - generateTimeout: 8000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => @@ -206,7 +210,7 @@ module.exports = server => { server.method('v2.wallets.search', search, { cache: { expiresIn: 30 * 1000, - generateTimeout: 3000, + generateTimeout, getDecoratedValue: true, }, generateKey: request => From 73d434e71e61a2b5c6b44ca40146e8e1d479886f Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Wed, 5 Dec 2018 12:48:42 +0200 Subject: [PATCH 3/6] fix(core-api): ensure booleans for the cache timeout are handled (#1647) --- packages/core-api/CHANGELOG.md | 2 ++ packages/core-api/lib/versions/1/methods/accounts.js | 4 +--- packages/core-api/lib/versions/1/methods/blocks.js | 4 +--- packages/core-api/lib/versions/1/methods/delegates.js | 4 +--- packages/core-api/lib/versions/1/methods/transactions.js | 4 +--- packages/core-api/lib/versions/2/methods/blocks.js | 4 +--- packages/core-api/lib/versions/2/methods/delegates.js | 4 +--- packages/core-api/lib/versions/2/methods/transactions.js | 4 +--- packages/core-api/lib/versions/2/methods/votes.js | 4 +--- packages/core-api/lib/versions/2/methods/wallets.js | 4 +--- packages/core-api/lib/versions/utils.js | 7 +++++++ packages/core-api/package.json | 2 +- 12 files changed, 19 insertions(+), 28 deletions(-) create mode 100644 packages/core-api/lib/versions/utils.js diff --git a/packages/core-api/CHANGELOG.md b/packages/core-api/CHANGELOG.md index 5c6db728e6..7110ef3f0f 100644 --- a/packages/core-api/CHANGELOG.md +++ b/packages/core-api/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## 0.2.12 - 2018-12-05 + ### Changed - Increase cache generation timeout and make it configurable diff --git a/packages/core-api/lib/versions/1/methods/accounts.js b/packages/core-api/lib/versions/1/methods/accounts.js index fcd7d1f970..a3533391d7 100644 --- a/packages/core-api/lib/versions/1/methods/accounts.js +++ b/packages/core-api/lib/versions/1/methods/accounts.js @@ -51,9 +51,7 @@ const publicKey = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v1.accounts.index', index, { cache: { diff --git a/packages/core-api/lib/versions/1/methods/blocks.js b/packages/core-api/lib/versions/1/methods/blocks.js index f122875cb4..3a3a12a477 100644 --- a/packages/core-api/lib/versions/1/methods/blocks.js +++ b/packages/core-api/lib/versions/1/methods/blocks.js @@ -34,9 +34,7 @@ const show = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v1.blocks.index', index, { cache: { diff --git a/packages/core-api/lib/versions/1/methods/delegates.js b/packages/core-api/lib/versions/1/methods/delegates.js index 12ff3845c8..89ff3b62b7 100644 --- a/packages/core-api/lib/versions/1/methods/delegates.js +++ b/packages/core-api/lib/versions/1/methods/delegates.js @@ -71,9 +71,7 @@ const voters = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v1.delegates.index', index, { cache: { diff --git a/packages/core-api/lib/versions/1/methods/transactions.js b/packages/core-api/lib/versions/1/methods/transactions.js index d944826340..6a160100f5 100644 --- a/packages/core-api/lib/versions/1/methods/transactions.js +++ b/packages/core-api/lib/versions/1/methods/transactions.js @@ -33,9 +33,7 @@ const show = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v1.transactions.index', index, { cache: { diff --git a/packages/core-api/lib/versions/2/methods/blocks.js b/packages/core-api/lib/versions/2/methods/blocks.js index 55835b6b4a..a7fc8a1800 100644 --- a/packages/core-api/lib/versions/2/methods/blocks.js +++ b/packages/core-api/lib/versions/2/methods/blocks.js @@ -51,9 +51,7 @@ const search = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v2.blocks.index', index, { cache: { diff --git a/packages/core-api/lib/versions/2/methods/delegates.js b/packages/core-api/lib/versions/2/methods/delegates.js index 0ba8edd0fa..7390c2f3f6 100644 --- a/packages/core-api/lib/versions/2/methods/delegates.js +++ b/packages/core-api/lib/versions/2/methods/delegates.js @@ -86,9 +86,7 @@ const voterBalances = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v2.delegates.index', index, { cache: { diff --git a/packages/core-api/lib/versions/2/methods/transactions.js b/packages/core-api/lib/versions/2/methods/transactions.js index 743dd8088c..2eaa0897d3 100644 --- a/packages/core-api/lib/versions/2/methods/transactions.js +++ b/packages/core-api/lib/versions/2/methods/transactions.js @@ -35,9 +35,7 @@ const search = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v2.transactions.index', index, { cache: { diff --git a/packages/core-api/lib/versions/2/methods/votes.js b/packages/core-api/lib/versions/2/methods/votes.js index ce3061a13c..7d4df6060b 100644 --- a/packages/core-api/lib/versions/2/methods/votes.js +++ b/packages/core-api/lib/versions/2/methods/votes.js @@ -32,9 +32,7 @@ const show = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v2.votes.index', index, { cache: { diff --git a/packages/core-api/lib/versions/2/methods/wallets.js b/packages/core-api/lib/versions/2/methods/wallets.js index 0576ed99cd..4902fffe32 100644 --- a/packages/core-api/lib/versions/2/methods/wallets.js +++ b/packages/core-api/lib/versions/2/methods/wallets.js @@ -116,9 +116,7 @@ const search = async request => { } module.exports = server => { - const { - generateTimeout, - } = require('@arkecosystem/core-container').resolveOptions('api').cache + const generateTimeout = require('../../utils').getCacheTimeout() server.method('v2.wallets.index', index, { cache: { diff --git a/packages/core-api/lib/versions/utils.js b/packages/core-api/lib/versions/utils.js new file mode 100644 index 0000000000..5b1b32f49d --- /dev/null +++ b/packages/core-api/lib/versions/utils.js @@ -0,0 +1,7 @@ +exports.getCacheTimeout = () => { + const { + generateTimeout, + } = require('@arkecosystem/core-container').resolveOptions('api').cache + + return JSON.parse(generateTimeout) +} diff --git a/packages/core-api/package.json b/packages/core-api/package.json index 1512b97bd0..1ba90cb7e2 100644 --- a/packages/core-api/package.json +++ b/packages/core-api/package.json @@ -1,7 +1,7 @@ { "name": "@arkecosystem/core-api", "description": "Public API for Ark Core", - "version": "0.2.11", + "version": "0.2.12", "contributors": [ "Kristjan Košič ", "Brian Faust " From b4e4d5661d8afd5d743d933a9f636459b52aecb3 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Wed, 5 Dec 2018 12:51:12 +0200 Subject: [PATCH 4/6] feat(core-database-postgres): store executed migrations in the database (#1648) --- packages/core-database-postgres/CHANGELOG.md | 6 +++++ .../core-database-postgres/lib/connection.js | 17 +++++++++++++- ...20180304100000-create-migrations-table.sql | 5 ++++ .../20180305300000-create-blocks-table.sql | 3 --- ...d-block_id-index-to-transactions-table.sql | 2 +- ...ator_public_key-index-to-blocks-table.sql} | 2 +- ...tions-timestamp-index-to-blocks-table.sql} | 0 ...eceiver-indices-to-transactions-table.sql} | 0 .../lib/migrations/index.js | 21 +++++++++++++---- .../lib/models/index.js | 1 + .../lib/models/migration.js | 23 +++++++++++++++++++ .../lib/queries/index.js | 4 ++++ .../lib/queries/migrations/create.sql | 1 + .../lib/queries/migrations/find.sql | 3 +++ .../lib/repositories/index.js | 1 + .../lib/repositories/migrations.js | 22 ++++++++++++++++++ 16 files changed, 101 insertions(+), 10 deletions(-) create mode 100644 packages/core-database-postgres/lib/migrations/20180304100000-create-migrations-table.sql rename packages/core-database-postgres/lib/migrations/{20181204100000-blocks-generator_public_key-index.sql => 20181204100000-add-generator_public_key-index-to-blocks-table.sql} (73%) rename packages/core-database-postgres/lib/migrations/{20181204200000-transactions-timestamp-index.sql => 20181204200000-add-transactions-timestamp-index-to-blocks-table.sql} (100%) rename packages/core-database-postgres/lib/migrations/{20181204300000-transactions-sender-and-receiver-indexes.sql => 20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql} (100%) create mode 100644 packages/core-database-postgres/lib/models/migration.js create mode 100644 packages/core-database-postgres/lib/queries/migrations/create.sql create mode 100644 packages/core-database-postgres/lib/queries/migrations/find.sql create mode 100644 packages/core-database-postgres/lib/repositories/migrations.js diff --git a/packages/core-database-postgres/CHANGELOG.md b/packages/core-database-postgres/CHANGELOG.md index 8348be784b..13db840f6b 100644 --- a/packages/core-database-postgres/CHANGELOG.md +++ b/packages/core-database-postgres/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## 0.2.11 - 2018-12-05 + +### Added + +- Store executed migrations in the database + ## 0.2.1 - 2018-12-05 ### Added diff --git a/packages/core-database-postgres/lib/connection.js b/packages/core-database-postgres/lib/connection.js index d20d86e4e1..f79ac58548 100644 --- a/packages/core-database-postgres/lib/connection.js +++ b/packages/core-database-postgres/lib/connection.js @@ -7,6 +7,7 @@ const crypto = require('crypto') const chunk = require('lodash/chunk') const pluralize = require('pluralize') const fs = require('fs') +const path = require('path') const { ConnectionInterface } = require('@arkecosystem/core-database') @@ -658,7 +659,21 @@ module.exports = class PostgresConnection extends ConnectionInterface { */ async __runMigrations() { for (const migration of migrations) { - await this.query.none(migration) + const { name } = path.parse(migration.file) + + if (name === '20180304100000-create-migrations-table') { + await this.query.none(migration) + } else { + const row = await this.db.migrations.findByName(name) + + if (row === null) { + logger.debug(`Migrating ${name}`) + + await this.query.none(migration) + + await this.db.migrations.create({ name }) + } + } } } diff --git a/packages/core-database-postgres/lib/migrations/20180304100000-create-migrations-table.sql b/packages/core-database-postgres/lib/migrations/20180304100000-create-migrations-table.sql new file mode 100644 index 0000000000..d1cc30448e --- /dev/null +++ b/packages/core-database-postgres/lib/migrations/20180304100000-create-migrations-table.sql @@ -0,0 +1,5 @@ +-- Table Definition +CREATE TABLE IF NOT EXISTS ${schema~}.migrations ( + "id" SERIAL PRIMARY KEY, + "name" VARCHAR(255) UNIQUE NOT NULL +); diff --git a/packages/core-database-postgres/lib/migrations/20180305300000-create-blocks-table.sql b/packages/core-database-postgres/lib/migrations/20180305300000-create-blocks-table.sql index 86c32105d6..58551aa6f2 100644 --- a/packages/core-database-postgres/lib/migrations/20180305300000-create-blocks-table.sql +++ b/packages/core-database-postgres/lib/migrations/20180305300000-create-blocks-table.sql @@ -14,6 +14,3 @@ CREATE TABLE IF NOT EXISTS ${schema~}.blocks ( "generator_public_key" VARCHAR(66) NOT NULL, "block_signature" VARCHAR(256) NOT NULL ); - --- Constraints -CREATE UNIQUE INDEX IF NOT EXISTS "blocks_unique" ON blocks ("height", "generator_public_key"); diff --git a/packages/core-database-postgres/lib/migrations/20181129400000-add-block_id-index-to-transactions-table.sql b/packages/core-database-postgres/lib/migrations/20181129400000-add-block_id-index-to-transactions-table.sql index 0300b968a1..7d2be3cc41 100644 --- a/packages/core-database-postgres/lib/migrations/20181129400000-add-block_id-index-to-transactions-table.sql +++ b/packages/core-database-postgres/lib/migrations/20181129400000-add-block_id-index-to-transactions-table.sql @@ -1,2 +1,2 @@ -- Constraints -CREATE INDEX IF NOT EXISTS "transactions_block_id" ON transactions ("block_id"); +CREATE INDEX IF NOT EXISTS "transactions_block_id" ON ${schema~}.transactions ("block_id"); diff --git a/packages/core-database-postgres/lib/migrations/20181204100000-blocks-generator_public_key-index.sql b/packages/core-database-postgres/lib/migrations/20181204100000-add-generator_public_key-index-to-blocks-table.sql similarity index 73% rename from packages/core-database-postgres/lib/migrations/20181204100000-blocks-generator_public_key-index.sql rename to packages/core-database-postgres/lib/migrations/20181204100000-add-generator_public_key-index-to-blocks-table.sql index 61e8e66469..c411dc74cb 100644 --- a/packages/core-database-postgres/lib/migrations/20181204100000-blocks-generator_public_key-index.sql +++ b/packages/core-database-postgres/lib/migrations/20181204100000-add-generator_public_key-index-to-blocks-table.sql @@ -1,2 +1,2 @@ -DROP INDEX "blocks_unique"; +DROP INDEX IF EXISTS "blocks_unique"; CREATE INDEX IF NOT EXISTS "blocks_generator_public_key" ON ${schema~}.blocks ("generator_public_key"); diff --git a/packages/core-database-postgres/lib/migrations/20181204200000-transactions-timestamp-index.sql b/packages/core-database-postgres/lib/migrations/20181204200000-add-transactions-timestamp-index-to-blocks-table.sql similarity index 100% rename from packages/core-database-postgres/lib/migrations/20181204200000-transactions-timestamp-index.sql rename to packages/core-database-postgres/lib/migrations/20181204200000-add-transactions-timestamp-index-to-blocks-table.sql diff --git a/packages/core-database-postgres/lib/migrations/20181204300000-transactions-sender-and-receiver-indexes.sql b/packages/core-database-postgres/lib/migrations/20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql similarity index 100% rename from packages/core-database-postgres/lib/migrations/20181204300000-transactions-sender-and-receiver-indexes.sql rename to packages/core-database-postgres/lib/migrations/20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql diff --git a/packages/core-database-postgres/lib/migrations/index.js b/packages/core-database-postgres/lib/migrations/index.js index 07f0d87fed..b3801097af 100644 --- a/packages/core-database-postgres/lib/migrations/index.js +++ b/packages/core-database-postgres/lib/migrations/index.js @@ -1,12 +1,25 @@ const { loadQueryFile } = require('../utils') module.exports = [ + loadQueryFile(__dirname, './20180304100000-create-migrations-table.sql'), loadQueryFile(__dirname, './20180305100000-create-wallets-table.sql'), loadQueryFile(__dirname, './20180305200000-create-rounds-table.sql'), loadQueryFile(__dirname, './20180305300000-create-blocks-table.sql'), loadQueryFile(__dirname, './20180305400000-create-transactions-table.sql'), - loadQueryFile(__dirname, './20181129400000-add-block_id-index-to-transactions-table.sql'), - loadQueryFile(__dirname, './20181204100000-blocks-generator_public_key-index.sql'), - loadQueryFile(__dirname, './20181204200000-transactions-timestamp-index.sql'), - loadQueryFile(__dirname, './20181204300000-transactions-sender-and-receiver-indexes.sql'), + loadQueryFile( + __dirname, + './20181129400000-add-block_id-index-to-transactions-table.sql', + ), + loadQueryFile( + __dirname, + './20181204100000-add-generator_public_key-index-to-blocks-table.sql', + ), + loadQueryFile( + __dirname, + './20181204200000-add-transactions-timestamp-index-to-blocks-table.sql', + ), + loadQueryFile( + __dirname, + './20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql', + ), ] diff --git a/packages/core-database-postgres/lib/models/index.js b/packages/core-database-postgres/lib/models/index.js index b00c00cc7f..dfbbdc2b42 100644 --- a/packages/core-database-postgres/lib/models/index.js +++ b/packages/core-database-postgres/lib/models/index.js @@ -1,5 +1,6 @@ module.exports = { Block: require('./block'), + Migration: require('./migration'), Round: require('./round'), Transaction: require('./transaction'), Wallet: require('./wallet'), diff --git a/packages/core-database-postgres/lib/models/migration.js b/packages/core-database-postgres/lib/models/migration.js new file mode 100644 index 0000000000..f5f80cd506 --- /dev/null +++ b/packages/core-database-postgres/lib/models/migration.js @@ -0,0 +1,23 @@ +const Model = require('./model') + +module.exports = class Round extends Model { + /** + * The table associated with the model. + * @return {String} + */ + getTable() { + return 'migrations' + } + + /** + * The read-only structure with query-formatting columns. + * @return {Object} + */ + getColumnSet() { + return this.createColumnSet([ + { + name: 'name', + }, + ]) + } +} diff --git a/packages/core-database-postgres/lib/queries/index.js b/packages/core-database-postgres/lib/queries/index.js index 6a5b83cf1b..840e20000d 100644 --- a/packages/core-database-postgres/lib/queries/index.js +++ b/packages/core-database-postgres/lib/queries/index.js @@ -13,6 +13,10 @@ module.exports = { statistics: loadQueryFile(__dirname, './blocks/statistics.sql'), top: loadQueryFile(__dirname, './blocks/top.sql'), }, + migrations: { + create: loadQueryFile(__dirname, './migrations/create.sql'), + find: loadQueryFile(__dirname, './migrations/find.sql'), + }, rounds: { delete: loadQueryFile(__dirname, './rounds/delete.sql'), find: loadQueryFile(__dirname, './rounds/find.sql'), diff --git a/packages/core-database-postgres/lib/queries/migrations/create.sql b/packages/core-database-postgres/lib/queries/migrations/create.sql new file mode 100644 index 0000000000..c751058d0e --- /dev/null +++ b/packages/core-database-postgres/lib/queries/migrations/create.sql @@ -0,0 +1 @@ +INSERT INTO migrations (name) VALUES (${name}) diff --git a/packages/core-database-postgres/lib/queries/migrations/find.sql b/packages/core-database-postgres/lib/queries/migrations/find.sql new file mode 100644 index 0000000000..0828698f04 --- /dev/null +++ b/packages/core-database-postgres/lib/queries/migrations/find.sql @@ -0,0 +1,3 @@ +SELECT * +FROM migrations +WHERE name = ${name} diff --git a/packages/core-database-postgres/lib/repositories/index.js b/packages/core-database-postgres/lib/repositories/index.js index 686c136090..59947e709d 100644 --- a/packages/core-database-postgres/lib/repositories/index.js +++ b/packages/core-database-postgres/lib/repositories/index.js @@ -1,5 +1,6 @@ module.exports = { blocks: require('./blocks'), + migrations: require('./migrations'), rounds: require('./rounds'), transactions: require('./transactions'), wallets: require('./wallets'), diff --git a/packages/core-database-postgres/lib/repositories/migrations.js b/packages/core-database-postgres/lib/repositories/migrations.js new file mode 100644 index 0000000000..a72275c6a7 --- /dev/null +++ b/packages/core-database-postgres/lib/repositories/migrations.js @@ -0,0 +1,22 @@ +const Repository = require('./repository') +const { Migration } = require('../models') +const { migrations: sql } = require('../queries') + +module.exports = class MigrationsRepository extends Repository { + /** + * Find a migration by its name. + * @param {String} name + * @return {Promise} + */ + async findByName(name) { + return this.db.oneOrNone(sql.find, { name }) + } + + /** + * Get the model related to this repository. + * @return {Object} + */ + getModel() { + return new Migration(this.pgp) + } +} From 5406ead51ff0991e1b622540770b9324d581e1f1 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Wed, 5 Dec 2018 12:58:40 +0200 Subject: [PATCH 5/6] chore(core-database-postgres): properly split migrations and name them (#1649) --- ...0181204200000-add-timestamp-index-to-blocks-table.sql} | 0 ...add-sender_public_key-index-to-transactions-table.sql} | 1 - ...00000-add-recipient_id-index-to-transactions-table.sql | 1 + packages/core-database-postgres/lib/migrations/index.js | 8 ++++++-- 4 files changed, 7 insertions(+), 3 deletions(-) rename packages/core-database-postgres/lib/migrations/{20181204200000-add-transactions-timestamp-index-to-blocks-table.sql => 20181204200000-add-timestamp-index-to-blocks-table.sql} (100%) rename packages/core-database-postgres/lib/migrations/{20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql => 20181204300000-add-sender_public_key-index-to-transactions-table.sql} (52%) create mode 100644 packages/core-database-postgres/lib/migrations/20181204400000-add-recipient_id-index-to-transactions-table.sql diff --git a/packages/core-database-postgres/lib/migrations/20181204200000-add-transactions-timestamp-index-to-blocks-table.sql b/packages/core-database-postgres/lib/migrations/20181204200000-add-timestamp-index-to-blocks-table.sql similarity index 100% rename from packages/core-database-postgres/lib/migrations/20181204200000-add-transactions-timestamp-index-to-blocks-table.sql rename to packages/core-database-postgres/lib/migrations/20181204200000-add-timestamp-index-to-blocks-table.sql diff --git a/packages/core-database-postgres/lib/migrations/20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql b/packages/core-database-postgres/lib/migrations/20181204300000-add-sender_public_key-index-to-transactions-table.sql similarity index 52% rename from packages/core-database-postgres/lib/migrations/20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql rename to packages/core-database-postgres/lib/migrations/20181204300000-add-sender_public_key-index-to-transactions-table.sql index a2afefbbd5..d7f701fd4a 100644 --- a/packages/core-database-postgres/lib/migrations/20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql +++ b/packages/core-database-postgres/lib/migrations/20181204300000-add-sender_public_key-index-to-transactions-table.sql @@ -1,2 +1 @@ CREATE INDEX IF NOT EXISTS "transactions_sender_public_key" ON ${schema~}.transactions ("sender_public_key"); -CREATE INDEX IF NOT EXISTS "transactions_recipient_id" ON ${schema~}.transactions ("recipient_id"); diff --git a/packages/core-database-postgres/lib/migrations/20181204400000-add-recipient_id-index-to-transactions-table.sql b/packages/core-database-postgres/lib/migrations/20181204400000-add-recipient_id-index-to-transactions-table.sql new file mode 100644 index 0000000000..722847c4b9 --- /dev/null +++ b/packages/core-database-postgres/lib/migrations/20181204400000-add-recipient_id-index-to-transactions-table.sql @@ -0,0 +1 @@ +CREATE INDEX IF NOT EXISTS "transactions_recipient_id" ON ${schema~}.transactions ("recipient_id"); diff --git a/packages/core-database-postgres/lib/migrations/index.js b/packages/core-database-postgres/lib/migrations/index.js index b3801097af..385f0b9502 100644 --- a/packages/core-database-postgres/lib/migrations/index.js +++ b/packages/core-database-postgres/lib/migrations/index.js @@ -16,10 +16,14 @@ module.exports = [ ), loadQueryFile( __dirname, - './20181204200000-add-transactions-timestamp-index-to-blocks-table.sql', + './20181204200000-add-timestamp-index-to-blocks-table.sql', ), loadQueryFile( __dirname, - './20181204300000-add-transactions-sender-and-receiver-indices-to-transactions-table.sql', + './20181204300000-add-sender_public_key-index-to-transactions-table.sql', + ), + loadQueryFile( + __dirname, + './20181204400000-add-recipient_id-index-to-transactions-table.sql', ), ] From 8aff4304a42f1468908c1981edd8b7f5ddcbe944 Mon Sep 17 00:00:00 2001 From: Brian Faust Date: Wed, 5 Dec 2018 13:07:53 +0200 Subject: [PATCH 6/6] chore(core): update changelog and bump version (#1650) --- packages/core/CHANGELOG.md | 10 ++++++++++ packages/core/package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md index 9304074780..d614ca6b35 100644 --- a/packages/core/CHANGELOG.md +++ b/packages/core/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## 2.0.11 - 2018-12-05 + +### Added + +- Store executed migrations in the database + +### Changed + +- Increase cache generation timeout and make it configurable + ## 2.0.1 - 2018-12-05 ### Changed diff --git a/packages/core/package.json b/packages/core/package.json index 96dee9b940..e1be148799 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@arkecosystem/core", "description": "Core of the Ark Blockchain", - "version": "2.0.1", + "version": "2.0.11", "contributors": [ "François-Xavier Thoorens ", "Kristjan Košič ",