Skip to content

Commit

Permalink
server: Use the TransactionCollectorService on the LedgerSynchronizer…
Browse files Browse the repository at this point in the history
…Service
  • Loading branch information
AlexITC committed Apr 7, 2019
1 parent 9fc35c1 commit 1185c79
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import scala.concurrent.{ExecutionContext, Future}

class LedgerSynchronizerService @Inject() (
xsnService: XSNService,
transactionService: TransactionService,
transactionRPCService: TransactionRPCService,
blockService: BlockService,
transactionCollectorService: TransactionCollectorService,
ledgerDataHandler: LedgerFutureDataHandler,
blockDataHandler: BlockFutureDataHandler)(
implicit ec: ExecutionContext) {
Expand Down Expand Up @@ -172,7 +171,7 @@ class LedgerSynchronizerService @Inject() (
private def getBlockData(rpcBlock: rpc.Block): FutureApplicationResult[BlockData] = {
val result = for {
extractionMethod <- blockService.extractionMethod(rpcBlock).toFutureOr
data <- transactionRPCService.getTransactions(rpcBlock.transactions).toFutureOr
data <- transactionCollectorService.collect(rpcBlock.transactions).toFutureOr
(transactions, contracts) = data
validContracts <- getValidContracts(contracts).toFutureOr
} yield {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import com.xsn.explorer.helpers.LedgerHelper._
import com.xsn.explorer.helpers._
import com.xsn.explorer.models.rpc.Block
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.validators.{AddressValidator, BlockhashValidator, TransactionIdValidator}
import com.xsn.explorer.services.validators.BlockhashValidator
import org.scalactic.{Bad, Good, One, Or}
import org.scalatest.BeforeAndAfter
import org.scalatest.concurrent.ScalaFutures
Expand Down Expand Up @@ -212,15 +212,6 @@ class LedgerSynchronizerServiceSpec extends PostgresDataHandlerSpec with BeforeA
}

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(
xsnService,
new BlockFutureDataHandler(blockDataHandler)(Executors.databaseEC),
Expand All @@ -231,12 +222,14 @@ class LedgerSynchronizerServiceSpec extends PostgresDataHandlerSpec with BeforeA
new OrderingConditionParser,
BlockHeaderCache.default
)
val transactionRPCService = new TransactionRPCService(new TransactionIdValidator, xsnService)
val transactionCollectorService = new TransactionCollectorService(
xsnService,
new TransactionFutureDataHandler(transactionDataHandler)(Executors.databaseEC)
)
new LedgerSynchronizerService(
xsnService,
transactionService,
transactionRPCService,
blockService,
transactionCollectorService,
new LedgerFutureDataHandler(dataHandler)(Executors.databaseEC),
new BlockFutureDataHandler(blockDataHandler)(Executors.databaseEC))
}
Expand Down

0 comments on commit 1185c79

Please sign in to comment.