Browse Source

server: Add endpoint "POST /transactions/latest"

This retrieves the latest transaction id for the given addresses.
prometheus-integration
Alexis Hernandez 6 years ago
parent
commit
d4acc18d9f
  1. 5
      server/app/com/xsn/explorer/services/TransactionService.scala
  2. 5
      server/app/controllers/TransactionsController.scala
  3. 1
      server/conf/routes

5
server/app/com/xsn/explorer/services/TransactionService.scala

@ -114,6 +114,11 @@ class TransactionService @Inject() (
result.toFuture
}
def getLatestTransactionBy(addresses: List[Address]): FutureApplicationResult[Map[String, String]] = {
transactionFutureDataHandler.getLatestTransactionBy(addresses)
}
private def getTransactionValue(vin: TransactionVIN): FutureApplicationResult[TransactionValue] = {
val valueMaybe = for {
value <- vin.value

5
server/app/controllers/TransactionsController.scala

@ -3,6 +3,7 @@ package controllers
import javax.inject.Inject
import com.alexitc.playsonify.models.PublicContextWithModel
import com.xsn.explorer.models.Address
import com.xsn.explorer.models.request.SendRawTransactionRequest
import com.xsn.explorer.services.TransactionService
import controllers.common.{MyJsonController, MyJsonControllerComponents}
@ -23,4 +24,8 @@ class TransactionsController @Inject() (
def sendRawTransaction() = publicWithInput { ctx: PublicContextWithModel[SendRawTransactionRequest] =>
transactionService.sendRawTransaction(ctx.model.hex)
}
def getLatestByAddresses() = publicWithInput { ctx: PublicContextWithModel[List[Address]] =>
transactionService.getLatestTransactionBy(ctx.model)
}
}

1
server/conf/routes

@ -8,6 +8,7 @@ GET /health controllers.HealthController.check()
GET /transactions/:txid controllers.TransactionsController.getTransaction(txid: String)
GET /transactions/:txid/raw controllers.TransactionsController.getRawTransaction(txid: String)
POST /transactions controllers.TransactionsController.sendRawTransaction()
POST /transactions/latest controllers.TransactionsController.getLatestByAddresses()
GET /addresses/:address controllers.AddressesController.getBy(address: String)
GET /addresses/:address/transactions controllers.AddressesController.getTransactions(address: String, offset: Int ?= 0, limit: Int ?= 10, orderBy: String ?= "")

Loading…
Cancel
Save