From 886f9f8a18271a3488a1804ab2e7cb6664d54f2e Mon Sep 17 00:00:00 2001 From: gjgd Date: Wed, 18 Dec 2019 16:04:15 +0100 Subject: [PATCH] feat: add transactionTimeHash to getTransactions --- .../src/sidetree-v2/protocol/getTransactions.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/element-lib/src/sidetree-v2/protocol/getTransactions.js b/packages/element-lib/src/sidetree-v2/protocol/getTransactions.js index a924eaf1..fdcaa5a4 100644 --- a/packages/element-lib/src/sidetree-v2/protocol/getTransactions.js +++ b/packages/element-lib/src/sidetree-v2/protocol/getTransactions.js @@ -1,7 +1,14 @@ -const getTransactions = sidetree => async () => { +const getTransactions = sidetree => async ({ transactionTimeHash } = {}) => { + let since = 0; + let end = 'latest'; + if (transactionTimeHash) { + const blockchainTime = await sidetree.blockchain.getBlockchainTime(transactionTimeHash); + since = blockchainTime.time; + end = since + 1; + } const transactions = await sidetree.blockchain.getTransactions( - 0, - 'latest', + since, + end, { omitTimestamp: true }, ); // Only get the last 20 transactions to avoid crashing the page