From 8afa42022621eff378fc0a170230cf526a265ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 17 Oct 2019 12:01:53 +0200 Subject: [PATCH] fix block orger in pond chain explorer --- lotuspond/front/src/ChainExplorer.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lotuspond/front/src/ChainExplorer.js b/lotuspond/front/src/ChainExplorer.js index efd38939e..aec6697bc 100644 --- a/lotuspond/front/src/ChainExplorer.js +++ b/lotuspond/front/src/ChainExplorer.js @@ -60,10 +60,10 @@ class ChainExplorer extends React.Component { } async fetch(h, base, cache, msgcache) { - console.log(h, base, cache) + //console.log(h, base, cache) if (this.fetching[h]) { - return + return cache[h] } this.fetching[h] = true @@ -110,17 +110,16 @@ class ChainExplorer extends React.Component { await this.fetchN(h) } - const tofetch = Array(rows).fill(0).map((_, i) => top - i) - .filter(v => !this.state.cache[v]) - let cache = {...this.state.cache} let msgcache = {...this.state.messages} - await tofetch.reduce(async (prev, next) => { - let prevts = await prev - let newts = await this.fetch(next, prevts, cache, msgcache) - return newts ? newts : prevts - }, Promise.resolve(cache[top])) + console.log("top", top) + + let parent = cache[top] + for(let i = 0; i < rows; i++) { + let newts = await this.fetch(top - i, parent, cache, msgcache) + parent = newts ? newts : parent + } this.setState({cache: cache, messages: msgcache}) }