TCOAKCGGHOIRJCTZYEZQ3K6KCGL2LGAYGYFRGSPCHBTJJY2V6AXAC
WFZDMVUXZ2KPTMRAZGEYHKEJTKOKWVYCXKKAKQ7K6I5TMSLBUJ4QC
64C6AWH66FDKU6UE6Z6JPX2J2GBM2JOPTH2GL6LHKAIUBGNGDZ5AC
WZUHEZSBRKHQMNWDKVG4X6DDIQEAXTGI6IGAJ5ERPRQ3W2KUMX4QC
EMVTF2IWNQGRL44FC4JNG5FYYQTZSFPNM6SOM7IAEH6T7PPK2NVAC
ADMKQQGCGVSHHIMVQ4XFRDCG544SBJCYALSKZV45CQQBZ4ACUH2AC
RSEB2NFGUBTFESE5BJKDUVQL5Y5ZVGY5O4CJX2LNP63MS3NRHHZQC
Z3M53KTLZMPOISMHE25SZJSWX5TA37IV33IRE7KNRAD3PKEAEJXQC
64VI73NPSFNWTL6UXM6YHRFLNJZ3NUJ2R3CL53MO2HSZWFGBIRTQC
LAROLAYUGJ4Q5AEFV5EJMIA2ZKBNCBWHHHPCJ3CKCNIUIYUKRFVQC
site adb = route
[ ("logStart/:btcAddr", handleLogRequest adb StartWork)
, ("logEnd/:btcAddr", handleLogRequest adb StopWork)
, ("payouts", currentPayouts adb)
site qdb = route
[ ("logStart/:btcAddr", handleLogRequest qdb StartWork)
, ("logEnd/:btcAddr", handleLogRequest qdb StopWork)
, ("payouts", currentPayouts qdb)
handleLogRequest :: QDB IO a -> (UTCTime -> WorkEvent) -> ReaderT a Snap ()
handleLogRequest db adb ev = do
handleLogRequest :: QDB IO a -> EventType -> ReaderT a Snap ()
handleLogRequest qdb ev = do
let QDB{..} = qdb
let addr = fmap T.pack addrBytes >>= parseBtcAddr
timestamp <- liftIO getCurrentTime
liftIO $ recordEvent adb db $ LogEntry addr (ev timestamp)
timestamp <- lift $ liftIO getCurrentTime
maybe
(lift $ snapError 400 "")
(\a -> mapReaderT liftIO $ recordEvent (LogEntry a (WorkEvent ev timestamp)))
(fmap decodeUtf8 addrBytes >>= parseBtcAddr)
currentPayouts db adb = do
ptime <- liftIO getCurrentTime
let dep = linearDepreciation (Months 6) (Months 60)
currentPayouts qdb = do
let QDB{..} = qdb
dep = linearDepreciation (Months 6) (Months 60)
buildPayoutsResponse :: WorkIndex -> Snap ()
buildPayoutsResponse widx = writeBS . A.encode . PayoutsResponse $ payouts dep ptime widx
payoutsAction :: EitherT T.Text Snap WorkIndex
payoutsAction = mapEitherT liftIO $ readWorkIndex adb db
ptime <- lift . liftIO $ getCurrentTime
widx <- mapReaderT liftIO $ readWorkIndex
lift . writeLBS . A.encode . PayoutsResponse $ payouts dep ptime widx