From 6a97930cebddcd0cfc51f3926d7355972db1fcea Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Mon, 22 Oct 2018 11:54:28 +0100 Subject: [PATCH] Only fetch transactions from last 100th blocks --- lib/modules/blockchain_connector/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/modules/blockchain_connector/index.js b/lib/modules/blockchain_connector/index.js index 35f210caf..58a8e937a 100644 --- a/lib/modules/blockchain_connector/index.js +++ b/lib/modules/blockchain_connector/index.js @@ -7,6 +7,8 @@ const embarkJsUtils = require('embarkjs').Utils; const WEB3_READY = 'blockchain:ready'; +const BLOCK_LIMIT = 100; + // TODO: consider another name, this is the blockchain connector class BlockchainConnector { constructor(embark, options) { @@ -481,7 +483,7 @@ class BlockchainConnector { }); }, function(blockNumber, account, next) { - self.getTransactions(blockNumber, blockNumber, (transactions) => { + self.getTransactions(blockNumber - BLOCK_LIMIT, BLOCK_LIMIT, (transactions) => { account.transactions = transactions.filter((transaction) => transaction.from === address); next(null, account); });