Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (32 sloc) 1.41 KB
module Y2016.M10.D10.Exercise where
import Data.Time.Clock.POSIX
-- below imports available as a cabal install
import Data.Aeson
import Network.HTTP.Conduit
So, last week you created a webservice that showed block information for the
latest block, then refined that to show block information for some requested
The problem here is that: do you know a block hash off the top of your head?
No, you don't.
So it's best to survey block information by some criteria, such as by address,
or by day, or by pool, or by height.
Let's survey blocks by day today.
A sample set of block (meta-)information returned from a block at a specified
time (the POSIX-integer representation of time) is located at this directory:
or at this URL:
Create a structure that accepts these data, then, you know: read it in.
data BlockInfo = AStructureYouCreate
instance FromJSON BlockInfo where
parseJSON = undefined
-- now read in the block info for some time from the api
blocksAtTimeURL :: Integer -> FilePath
blocksAtTimeURL t = "" ++ show t ++ "?format=json"
readBlockInfo :: POSIXTime -> IO [BlockInfo]
readBlockInfo t = undefined
-- now read in the block info for today/the current POSIX time
readTodaysBlockInfo :: IO [BlockInfo]
readTodaysBlockInfo = undefined
You can’t perform that action at this time.