Skip to content

Commit 5de7411

Browse files
author
DA Automation
committed
[ci] Fix formatting.
Signed-off-by: DA Automation <splice-maintainers@digitalasset.com>
1 parent 1145264 commit 5de7411

File tree

3 files changed

+88
-75
lines changed

3 files changed

+88
-75
lines changed

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanHistoryBackfillingIntegrationTest.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@ package org.lfdecentralizedtrust.splice.integration.tests
22

33
import com.daml.ledger.javaapi.data.TransactionTree
44
import org.lfdecentralizedtrust.splice.config.ConfigTransforms
5-
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{ConfigurableApp, updateAutomationConfig}
5+
import org.lfdecentralizedtrust.splice.config.ConfigTransforms.{
6+
ConfigurableApp,
7+
updateAutomationConfig,
8+
}
69
import org.lfdecentralizedtrust.splice.console.ScanAppBackendReference
710
import org.lfdecentralizedtrust.splice.environment.ledger.api.TransactionTreeUpdate
811
import org.lfdecentralizedtrust.splice.http.v0.definitions
912
import org.lfdecentralizedtrust.splice.http.v0.definitions.DamlValueEncoding.members.CompactJson
1013
import org.lfdecentralizedtrust.splice.integration.EnvironmentDefinition
11-
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.{IntegrationTest, SpliceTestConsoleEnvironment}
14+
import org.lfdecentralizedtrust.splice.integration.tests.SpliceTests.{
15+
IntegrationTest,
16+
SpliceTestConsoleEnvironment,
17+
}
1218
import org.lfdecentralizedtrust.splice.scan.admin.http.ProtobufJsonScanHttpEncodings
1319
import org.lfdecentralizedtrust.splice.scan.automation.ScanHistoryBackfillingTrigger
1420
import org.lfdecentralizedtrust.splice.store.{PageLimit, TreeUpdateWithMigrationId}
@@ -21,14 +27,12 @@ import scala.math.BigDecimal.javaBigDecimal2bigDecimal
2127
import com.digitalasset.canton.{HasActorSystem, HasExecutionContext}
2228
import org.lfdecentralizedtrust.splice.automation.TxLogBackfillingTrigger
2329
import org.lfdecentralizedtrust.splice.http.v0.definitions.TransactionHistoryRequest.SortOrder
24-
import org.lfdecentralizedtrust.splice.http.v0.definitions.UpdateHistoryItemV2
2530
import org.lfdecentralizedtrust.splice.scan.store.TxLogEntry
2631
import org.lfdecentralizedtrust.splice.store.MultiDomainAcsStore.TxLogBackfillingState
2732
import org.lfdecentralizedtrust.splice.store.UpdateHistory.BackfillingState
2833
import org.scalactic.source.Position
2934

3035
import scala.annotation.nowarn
31-
import scala.collection.immutable.SortedMap
3236
import scala.jdk.CollectionConverters.*
3337
import scala.jdk.OptionConverters.*
3438

@@ -401,10 +405,6 @@ class ScanHistoryBackfillingIntegrationTest
401405
commonLength should be > 10
402406
val sv1Items = sv1HttpUpdates.take(commonLength)
403407
val sv2Items = sv2HttpUpdates.take(commonLength)
404-
def collectEventsById(items: Seq[UpdateHistoryItemV2]) = items.collect {
405-
case definitions.UpdateHistoryItemV2.members.UpdateHistoryTransactionV2(http) =>
406-
http.eventsById
407-
}
408408
sv1Items should contain theSameElementsInOrderAs sv2Items
409409
}
410410

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/admin/api/client/commands/HttpScanAppClient.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,16 +1259,16 @@ object HttpScanAppClient {
12591259
}
12601260

12611261
case class GetUpdateHistoryV2(
1262-
count: Int,
1263-
after: Option[(Long, String)],
1264-
damlValueEncoding: definitions.DamlValueEncoding,
1265-
) extends InternalBaseCommand[http.GetUpdateHistoryV2Response, Seq[
1266-
definitions.UpdateHistoryItemV2
1267-
]] {
1268-
override def submitRequest(
1269-
client: http.ScanClient,
1270-
headers: List[HttpHeader],
1271-
): EitherT[Future, Either[
1262+
count: Int,
1263+
after: Option[(Long, String)],
1264+
damlValueEncoding: definitions.DamlValueEncoding,
1265+
) extends InternalBaseCommand[http.GetUpdateHistoryV2Response, Seq[
1266+
definitions.UpdateHistoryItemV2
1267+
]] {
1268+
override def submitRequest(
1269+
client: http.ScanClient,
1270+
headers: List[HttpHeader],
1271+
): EitherT[Future, Either[
12721272
Throwable,
12731273
HttpResponse,
12741274
], http.GetUpdateHistoryV2Response] = {

apps/scan/src/main/scala/org/lfdecentralizedtrust/splice/scan/admin/http/HttpScanHandler.scala

Lines changed: 70 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -853,24 +853,6 @@ class HttpScanHandler(
853853
)
854854
}
855855

856-
override def getUpdateByIdV2(respond: ScanResource.GetUpdateByIdV2Response.type)(
857-
updateId: String,
858-
damlValueEncoding: Option[DamlValueEncoding],
859-
)(extracted: TraceContext): Future[ScanResource.GetUpdateByIdV2Response] = {
860-
getUpdateById(
861-
updateId = updateId,
862-
encoding = damlValueEncoding.getOrElse(definitions.DamlValueEncoding.members.CompactJson),
863-
consistentResponses = true,
864-
extracted,
865-
)
866-
.map {
867-
case Left(error) =>
868-
ScanResource.GetUpdateByIdV2Response.NotFound(error)
869-
case Right(update) =>
870-
ScanResource.GetUpdateByIdV2Response.OK(toUpdateV2(update))
871-
}
872-
}
873-
874856
override def listActivity(
875857
respond: v0.ScanResource.ListActivityResponse.type
876858
)(
@@ -1484,24 +1466,22 @@ class HttpScanHandler(
14841466
extracted: TraceContext,
14851467
): Future[Either[definitions.ErrorResponse, definitions.UpdateHistoryItem]] = {
14861468
implicit val tc = extracted
1487-
withSpan(s"$workflowId.getUpdateById") { _ => _ =>
1488-
for {
1489-
tx <- store.updateHistory.getUpdate(updateId)
1490-
} yield {
1491-
tx.fold[Either[definitions.ErrorResponse, definitions.UpdateHistoryItem]](
1492-
Left(
1493-
definitions.ErrorResponse(s"Transaction with id $updateId not found")
1494-
)
1495-
)(txWithMigration =>
1496-
Right(
1497-
ScanHttpEncodings.encodeUpdate(
1498-
txWithMigration,
1499-
encoding = encoding,
1500-
version = if (consistentResponses) ScanHttpEncodings.V1 else ScanHttpEncodings.V0,
1501-
)
1469+
for {
1470+
tx <- store.updateHistory.getUpdate(updateId)
1471+
} yield {
1472+
tx.fold[Either[definitions.ErrorResponse, definitions.UpdateHistoryItem]](
1473+
Left(
1474+
definitions.ErrorResponse(s"Transaction with id $updateId not found")
1475+
)
1476+
)(txWithMigration =>
1477+
Right(
1478+
ScanHttpEncodings.encodeUpdate(
1479+
txWithMigration,
1480+
encoding = encoding,
1481+
version = if (consistentResponses) ScanHttpEncodings.V1 else ScanHttpEncodings.V0,
15021482
)
15031483
)
1504-
}
1484+
)
15051485
}
15061486
}
15071487

@@ -1510,37 +1490,70 @@ class HttpScanHandler(
15101490
)(updateId: String, lossless: Option[Boolean])(
15111491
extracted: TraceContext
15121492
): Future[ScanResource.GetUpdateByIdResponse] = {
1513-
val encoding = if (lossless.getOrElse(false)) {
1514-
definitions.DamlValueEncoding.ProtobufJson
1515-
} else {
1516-
definitions.DamlValueEncoding.CompactJson
1517-
}
1518-
getUpdateById(updateId = updateId, encoding = encoding, consistentResponses = false, extracted)
1519-
.map {
1520-
case Left(error) =>
1521-
ScanResource.GetUpdateByIdResponse.NotFound(error)
1522-
case Right(update) =>
1523-
ScanResource.GetUpdateByIdResponse.OK(update)
1493+
implicit val tc = extracted
1494+
// in openAPI the operationID for /v0/updates/{update_id} is `getUpdateById`, logging as `getUpdateByIdV0` for clarity
1495+
withSpan(s"$workflowId.getUpdateByIdV0") { _ => _ =>
1496+
val encoding = if (lossless.getOrElse(false)) {
1497+
definitions.DamlValueEncoding.ProtobufJson
1498+
} else {
1499+
definitions.DamlValueEncoding.CompactJson
15241500
}
1501+
getUpdateById(
1502+
updateId = updateId,
1503+
encoding = encoding,
1504+
consistentResponses = false,
1505+
extracted,
1506+
)
1507+
.map {
1508+
case Left(error) =>
1509+
ScanResource.GetUpdateByIdResponse.NotFound(error)
1510+
case Right(update) =>
1511+
ScanResource.GetUpdateByIdResponse.OK(update)
1512+
}
1513+
}
15251514
}
15261515

15271516
override def getUpdateByIdV1(
15281517
respond: ScanResource.GetUpdateByIdV1Response.type
15291518
)(updateId: String, damlValueEncoding: Option[definitions.DamlValueEncoding])(
15301519
extracted: TraceContext
15311520
): Future[ScanResource.GetUpdateByIdV1Response] = {
1532-
getUpdateById(
1533-
updateId = updateId,
1534-
encoding = damlValueEncoding.getOrElse(definitions.DamlValueEncoding.members.CompactJson),
1535-
consistentResponses = true,
1536-
extracted,
1537-
)
1538-
.map {
1539-
case Left(error) =>
1540-
ScanResource.GetUpdateByIdV1Response.NotFound(error)
1541-
case Right(update) =>
1542-
ScanResource.GetUpdateByIdV1Response.OK(update)
1543-
}
1521+
implicit val tc = extracted
1522+
withSpan(s"$workflowId.getUpdateByIdV1") { _ => _ =>
1523+
getUpdateById(
1524+
updateId = updateId,
1525+
encoding = damlValueEncoding.getOrElse(definitions.DamlValueEncoding.members.CompactJson),
1526+
consistentResponses = true,
1527+
extracted,
1528+
)
1529+
.map {
1530+
case Left(error) =>
1531+
ScanResource.GetUpdateByIdV1Response.NotFound(error)
1532+
case Right(update) =>
1533+
ScanResource.GetUpdateByIdV1Response.OK(update)
1534+
}
1535+
}
1536+
}
1537+
1538+
override def getUpdateByIdV2(respond: ScanResource.GetUpdateByIdV2Response.type)(
1539+
updateId: String,
1540+
damlValueEncoding: Option[DamlValueEncoding],
1541+
)(extracted: TraceContext): Future[ScanResource.GetUpdateByIdV2Response] = {
1542+
implicit val tc = extracted
1543+
withSpan(s"$workflowId.getUpdateByIdV2") { _ => _ =>
1544+
getUpdateById(
1545+
updateId = updateId,
1546+
encoding = damlValueEncoding.getOrElse(definitions.DamlValueEncoding.members.CompactJson),
1547+
consistentResponses = true,
1548+
extracted,
1549+
)
1550+
.map {
1551+
case Left(error) =>
1552+
ScanResource.GetUpdateByIdV2Response.NotFound(error)
1553+
case Right(update) =>
1554+
ScanResource.GetUpdateByIdV2Response.OK(toUpdateV2(update))
1555+
}
1556+
}
15441557
}
15451558

15461559
private def ensureValidRange[T](start: Long, end: Long, maxRounds: Int)(

0 commit comments

Comments
 (0)