Browse Source

server: Use the TransactionCollectorService on the LedgerSynchronizerService

bitcoin
Alexis Hernandez 6 years ago
parent
commit
1185c799ba
  1. 5
      server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala
  2. 21
      server/test/com/xsn/explorer/services/LedgerSynchronizerServiceSpec.scala

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

@ -17,9 +17,8 @@ import scala.concurrent.{ExecutionContext, Future}
class LedgerSynchronizerService @Inject() ( class LedgerSynchronizerService @Inject() (
xsnService: XSNService, xsnService: XSNService,
transactionService: TransactionService,
transactionRPCService: TransactionRPCService,
blockService: BlockService, blockService: BlockService,
transactionCollectorService: TransactionCollectorService,
ledgerDataHandler: LedgerFutureDataHandler, ledgerDataHandler: LedgerFutureDataHandler,
blockDataHandler: BlockFutureDataHandler)( blockDataHandler: BlockFutureDataHandler)(
implicit ec: ExecutionContext) { implicit ec: ExecutionContext) {
@ -172,7 +171,7 @@ class LedgerSynchronizerService @Inject() (
private def getBlockData(rpcBlock: rpc.Block): FutureApplicationResult[BlockData] = { private def getBlockData(rpcBlock: rpc.Block): FutureApplicationResult[BlockData] = {
val result = for { val result = for {
extractionMethod <- blockService.extractionMethod(rpcBlock).toFutureOr extractionMethod <- blockService.extractionMethod(rpcBlock).toFutureOr
data <- transactionRPCService.getTransactions(rpcBlock.transactions).toFutureOr data <- transactionCollectorService.collect(rpcBlock.transactions).toFutureOr
(transactions, contracts) = data (transactions, contracts) = data
validContracts <- getValidContracts(contracts).toFutureOr validContracts <- getValidContracts(contracts).toFutureOr
} yield { } yield {

21
server/test/com/xsn/explorer/services/LedgerSynchronizerServiceSpec.scala

@ -11,9 +11,9 @@ import com.xsn.explorer.helpers.LedgerHelper._
import com.xsn.explorer.helpers._ import com.xsn.explorer.helpers._
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.rpc.Block
import com.xsn.explorer.models.values.{Blockhash, Height} import com.xsn.explorer.models.values.{Blockhash, Height}
import com.xsn.explorer.parsers.{OrderingConditionParser, TransactionOrderingParser} import com.xsn.explorer.parsers.OrderingConditionParser
import com.xsn.explorer.services.logic.{BlockLogic, TransactionLogic} import com.xsn.explorer.services.logic.{BlockLogic, TransactionLogic}
import com.xsn.explorer.services.validators.{AddressValidator, BlockhashValidator, TransactionIdValidator} import com.xsn.explorer.services.validators.BlockhashValidator
import org.scalactic.{Bad, Good, One, Or} import org.scalactic.{Bad, Good, One, Or}
import org.scalatest.BeforeAndAfter import org.scalatest.BeforeAndAfter
import org.scalatest.concurrent.ScalaFutures import org.scalatest.concurrent.ScalaFutures
@ -212,15 +212,6 @@ class LedgerSynchronizerServiceSpec extends PostgresDataHandlerSpec with BeforeA
} }
private def ledgerSynchronizerService(xsnService: XSNService): LedgerSynchronizerService = { private def ledgerSynchronizerService(xsnService: XSNService): LedgerSynchronizerService = {
val transactionService = new TransactionService(
new PaginatedQueryValidator,
new OrderingConditionParser,
new TransactionOrderingParser,
new AddressValidator,
new TransactionIdValidator,
new BlockhashValidator,
new TransactionFutureDataHandler(transactionDataHandler)(Executors.databaseEC))
val blockService = new BlockService( val blockService = new BlockService(
xsnService, xsnService,
new BlockFutureDataHandler(blockDataHandler)(Executors.databaseEC), new BlockFutureDataHandler(blockDataHandler)(Executors.databaseEC),
@ -231,12 +222,14 @@ class LedgerSynchronizerServiceSpec extends PostgresDataHandlerSpec with BeforeA
new OrderingConditionParser, new OrderingConditionParser,
BlockHeaderCache.default BlockHeaderCache.default
) )
val transactionRPCService = new TransactionRPCService(new TransactionIdValidator, xsnService) val transactionCollectorService = new TransactionCollectorService(
xsnService,
new TransactionFutureDataHandler(transactionDataHandler)(Executors.databaseEC)
)
new LedgerSynchronizerService( new LedgerSynchronizerService(
xsnService, xsnService,
transactionService,
transactionRPCService,
blockService, blockService,
transactionCollectorService,
new LedgerFutureDataHandler(dataHandler)(Executors.databaseEC), new LedgerFutureDataHandler(dataHandler)(Executors.databaseEC),
new BlockFutureDataHandler(blockDataHandler)(Executors.databaseEC)) new BlockFutureDataHandler(blockDataHandler)(Executors.databaseEC))
} }

Loading…
Cancel
Save