Browse Source

server: Add BlockFutureDataHandler

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
c1d3d267cd
  1. 37
      server/app/com/xsn/explorer/data/async/BlockFutureDataHandler.scala

37
server/app/com/xsn/explorer/data/async/BlockFutureDataHandler.scala

@ -0,0 +1,37 @@
package com.xsn.explorer.data.async
import javax.inject.Inject
import com.alexitc.playsonify.core.FutureApplicationResult
import com.xsn.explorer.data.{BlockBlockingDataHandler, BlockDataHandler}
import com.xsn.explorer.executors.DatabaseExecutionContext
import com.xsn.explorer.models.Blockhash
import com.xsn.explorer.models.rpc.Block
import scala.concurrent.Future
class BlockFutureDataHandler @Inject() (
blockBlockingDataHandler: BlockBlockingDataHandler)(
implicit ec: DatabaseExecutionContext)
extends BlockDataHandler[FutureApplicationResult] {
def upsert(block: Block): FutureApplicationResult[Block] = Future {
blockBlockingDataHandler.upsert(block)
}
def getBy(blockhash: Blockhash): FutureApplicationResult[Block] = Future {
blockBlockingDataHandler.getBy(blockhash)
}
def delete(blockhash: Blockhash): FutureApplicationResult[Block] = Future {
blockBlockingDataHandler.delete(blockhash)
}
def getLatestBlock(): FutureApplicationResult[Block] = Future {
blockBlockingDataHandler.getLatestBlock()
}
def getFirstBlock(): FutureApplicationResult[Block] = Future {
blockBlockingDataHandler.getFirstBlock()
}
}
Loading…
Cancel
Save