0

I am trying to tackle an issue of getting the block details based on the start date and end date using JAVASCRIPT, Geth1.4.11.

WHAT I WANT ?

I want to get input of Start date and End date from user and using that start and end date i need to search the block , whatever blocks comes in between those dates have to be traced and data of those block has to be obtained.

e.g :: Assume there are 1000 blocks created between month January and March. I need to get the from,to and value details in the block from February 1st to February 28th.

WHAT I WORKED ON? (My Approach)

Assigned start and End date into variable , obtained from user.

Traverse from 0 to endBlock. Get timestamp of the traversed block number.

Compare the obtained timestamp with the user inputted Start date timestamp, if matched, traverse to capture end date timestamp and compare.

Record the blockNumber at which the start and end date were obtained and then traverse through the StartBlock and EndBlock fetching from ,to and Value.

Problems facing

The traverse crashes my webpage since it has lot of blocks to traverse through.

WHAT I AM LOOKING FOR

An API which takes start date and end date as input and gives the from, to and value.

A Optimized way to jump to the block of start date and end date and use traversal.

or any as such function.

Hem M
  • 326
  • 2
  • 13

1 Answers1

0

The traverse crashes my webpage since it has lot of blocks to traverse through.

This is not a standard way to load so much data all at a time. What I suggest you do is pagination. This way you can send chunks of data time by time. This will make your page much responsive and will prevent it from crashing

Muhammad Usman
  • 10,039
  • 22
  • 39
  • Thanks for your fast response. Pagination is just a way to show up data.. if i'm not wrong. I am not facing problem in **showing** up the data which i get from block, i have problem in **traversing through the blocks and fetching** the block data. I have put the startBlock as 0 and endBlock as current block in for loop, as it has many blocks it take lot of time to traverse and finally webpage becomes unresponsive/crashes – Hem M Nov 20 '17 at 08:01
  • This is the other side of the same coin. I meant `pagination` on the backend too. That means you don't need to process all of the blocks within that range all at once. Just send like first 100 records (within that range) and make a button to load more and show the next values within that range. Make sense ? – Muhammad Usman Nov 20 '17 at 08:04
  • here is a detailed demo of what I am talking about http://www.sourcecodematrix.com/2015/01/server-side-pagination-in-java-using.html – Muhammad Usman Nov 20 '17 at 08:07