Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rautenrieth-da committed Oct 8, 2021
1 parent a4c25d1 commit cc234a3
Show file tree
Hide file tree
Showing 30 changed files with 325 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ object TimestampConversion {
val fractionNanos = t.getNano % 1000L
if (fractionNanos != 0) {
mode match {
case ConversionMode.Exact => throw new IllegalArgumentException(
s"Conversion of $t to microsecond granularity would result in loss of precision."
)
case ConversionMode.Exact =>
throw new IllegalArgumentException(
s"Conversion of $t to microsecond granularity would result in loss of precision."
)
case ConversionMode.Up => t.plusNanos(1000L - fractionNanos)
case ConversionMode.Down => t.plusNanos(- fractionNanos)
case ConversionMode.HalfUp => t.plusNanos(if (fractionNanos >= 500L) 1000L - fractionNanos else -fractionNanos)
case ConversionMode.Down => t.plusNanos(-fractionNanos)
case ConversionMode.HalfUp =>
t.plusNanos(if (fractionNanos >= 500L) 1000L - fractionNanos else -fractionNanos)
}
} else {
t
Expand All @@ -68,12 +70,16 @@ object TimestampConversion {

sealed trait ConversionMode
object ConversionMode {

/** Throw an exception if the input can not be represented in microsecond resolution */
case object Exact extends ConversionMode

/** Round up to the nearest microsecond */
case object Up extends ConversionMode

/** Round down to the nearest microsecond */
case object Down extends ConversionMode

/** Round to the nearest microsecond */
case object HalfUp extends ConversionMode
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class TimestampConversionSpec
down.toInstant should be <= ts
up.toInstant should be >= ts
down should be < up
halfUp should (be (down) or be (up))
halfUp should (be(down) or be(up))
(up.micros - down.micros) shouldBe 1000
up.toInstant.truncatedTo(java.time.temporal.ChronoUnit.MICROS) shouldBe up.toInstant
down.toInstant.truncatedTo(java.time.temporal.ChronoUnit.MICROS) shouldBe down.toInstant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ object domain {

import Logging._

implicit val `Timestamp to LoggingValue`: ToLoggingValue[Timestamp] = ToLoggingValue.ToStringToLoggingValue
implicit val `Timestamp to LoggingValue`: ToLoggingValue[Timestamp] =
ToLoggingValue.ToStringToLoggingValue

implicit val `Commands to LoggingValue`: ToLoggingValue[Commands] = commands =>
LoggingValue.Nested.fromEntries(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ case class LedgerTimeModel private (
}

def checkTime(
ledgerTime: Timestamp,
recordTime: Timestamp,
ledgerTime: Timestamp,
recordTime: Timestamp,
): Either[OutOfRange, Unit] = {
checkTime(ledgerTime.toInstant, recordTime.toInstant)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import com.daml.lf.data.Time.Timestamp
import com.daml.lf.engine.Blinding
import com.daml.lf.transaction.GlobalKey
import com.daml.lf.value.Value.ContractId
import com.daml.platform.db.migration.translation.{ContractSerializer, TransactionSerializer, ValueSerializer}
import com.daml.platform.db.migration.translation.{
ContractSerializer,
TransactionSerializer,
ValueSerializer,
}
import com.daml.platform.store.Contract.ActiveContract
import com.daml.platform.store.Conversions._
import com.daml.platform.store.entries.LedgerEntry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,23 @@ package com.daml.platform.apiserver
import akka.NotUsed
import akka.stream.scaladsl.Source
import com.daml.daml_lf_dev.DamlLf
import com.daml.ledger.api.domain.{ApplicationId, CommandId, ConfigurationEntry, LedgerId, LedgerOffset, TransactionId}
import com.daml.ledger.api.domain.{
ApplicationId,
CommandId,
ConfigurationEntry,
LedgerId,
LedgerOffset,
TransactionId,
}
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.api.v1.active_contracts_service.GetActiveContractsResponse
import com.daml.ledger.api.v1.command_completion_service.CompletionStreamResponse
import com.daml.ledger.api.v1.transaction_service.{GetFlatTransactionResponse, GetTransactionResponse, GetTransactionTreesResponse, GetTransactionsResponse}
import com.daml.ledger.api.v1.transaction_service.{
GetFlatTransactionResponse,
GetTransactionResponse,
GetTransactionTreesResponse,
GetTransactionsResponse,
}
import com.daml.ledger.api.{TraceIdentifiers, domain}
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.offset.Offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import com.daml.lf.data.Time.Timestamp
import com.daml.lf.engine.{Engine, ValueEnricher}
import com.daml.logging.{ContextualizedLogger, LoggingContext}
import com.daml.metrics.Metrics
import com.daml.platform.configuration.{CommandConfiguration, PartyConfiguration, ServerRole, SubmissionConfiguration}
import com.daml.platform.configuration.{
CommandConfiguration,
PartyConfiguration,
ServerRole,
SubmissionConfiguration,
}
import com.daml.platform.index.JdbcIndex
import com.daml.platform.packages.InMemoryPackageStore
import com.daml.platform.services.time.TimeProviderType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,23 @@ import akka.NotUsed
import akka.stream.scaladsl.Source
import com.daml.daml_lf_dev.DamlLf
import com.daml.ledger.api.domain
import com.daml.ledger.api.domain.{ApplicationId, CommandId, ConfigurationEntry, LedgerId, LedgerOffset, TransactionId}
import com.daml.ledger.api.domain.{
ApplicationId,
CommandId,
ConfigurationEntry,
LedgerId,
LedgerOffset,
TransactionId,
}
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.api.v1.active_contracts_service.GetActiveContractsResponse
import com.daml.ledger.api.v1.command_completion_service.CompletionStreamResponse
import com.daml.ledger.api.v1.transaction_service.{GetFlatTransactionResponse, GetTransactionResponse, GetTransactionTreesResponse, GetTransactionsResponse}
import com.daml.ledger.api.v1.transaction_service.{
GetFlatTransactionResponse,
GetTransactionResponse,
GetTransactionTreesResponse,
GetTransactionsResponse,
}
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.index.v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ private[apiserver] final class ApiSubmissionService private[services] (
commands.commandId,
commands.actAs.toList,
commands.submittedAt,
Timestamp.assertFromInstant(DeduplicationPeriod.deduplicateUntil(
commands.submittedAt.toInstant,
commands.deduplicationPeriod,
)),
Timestamp.assertFromInstant(
DeduplicationPeriod.deduplicateUntil(
commands.submittedAt.toInstant,
commands.deduplicationPeriod,
)
),
)
.flatMap {
case CommandDeduplicationNew =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import com.daml.daml_lf_dev.DamlLf.Archive
import com.daml.ledger.api.domain.{LedgerOffset, PackageEntry}
import com.daml.ledger.api.v1.admin.package_management_service.PackageManagementServiceGrpc.PackageManagementService
import com.daml.ledger.api.v1.admin.package_management_service._
import com.daml.ledger.participant.state.index.v2.{IndexPackagesService, IndexTransactionsService, LedgerEndService}
import com.daml.ledger.participant.state.index.v2.{
IndexPackagesService,
IndexTransactionsService,
LedgerEndService,
}
import com.daml.ledger.participant.state.{v2 => state}
import com.daml.lf.archive.{Dar, DarParser, Decode, GenDarReader}
import com.daml.lf.data.Ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,26 @@ import com.daml.daml_lf_dev.DamlLf.Archive
import com.daml.dec.{DirectExecutionContext => DEC}
import com.daml.ledger.api.domain
import com.daml.ledger.api.domain.ConfigurationEntry.Accepted
import com.daml.ledger.api.domain.{ApplicationId, CommandId, LedgerId, LedgerOffset, PackageEntry, PartyDetails, PartyEntry, TransactionFilter, TransactionId}
import com.daml.ledger.api.domain.{
ApplicationId,
CommandId,
LedgerId,
LedgerOffset,
PackageEntry,
PartyDetails,
PartyEntry,
TransactionFilter,
TransactionId,
}
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.api.v1.active_contracts_service.GetActiveContractsResponse
import com.daml.ledger.api.v1.command_completion_service.CompletionStreamResponse
import com.daml.ledger.api.v1.transaction_service.{GetFlatTransactionResponse, GetTransactionResponse, GetTransactionTreesResponse, GetTransactionsResponse}
import com.daml.ledger.api.v1.transaction_service.{
GetFlatTransactionResponse,
GetTransactionResponse,
GetTransactionTreesResponse,
GetTransactionsResponse,
}
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.index.v2._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import com.daml.ledger.api.domain.{ApplicationId, CommandId, LedgerId, PartyDeta
import com.daml.ledger.api.health.HealthStatus
import com.daml.ledger.api.v1.active_contracts_service.GetActiveContractsResponse
import com.daml.ledger.api.v1.command_completion_service.CompletionStreamResponse
import com.daml.ledger.api.v1.transaction_service.{GetFlatTransactionResponse, GetTransactionResponse, GetTransactionTreesResponse, GetTransactionsResponse}
import com.daml.ledger.api.v1.transaction_service.{
GetFlatTransactionResponse,
GetTransactionResponse,
GetTransactionTreesResponse,
GetTransactionsResponse,
}
import com.daml.ledger.configuration.Configuration
import com.daml.ledger.offset.Offset
import com.daml.ledger.participant.state.index.v2.{CommandDeduplicationResult, PackageDetails}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ package com.daml.platform.store.appendonlydao.events
import com.daml.api.util.TimestampConversion
import com.daml.ledger.api.v1.active_contracts_service.GetActiveContractsResponse
import com.daml.ledger.api.v1.event.Event
import com.daml.ledger.api.v1.transaction.{TreeEvent, Transaction => ApiTransaction, TransactionTree => ApiTransactionTree}
import com.daml.ledger.api.v1.transaction_service.{GetFlatTransactionResponse, GetTransactionResponse, GetTransactionTreesResponse, GetTransactionsResponse}
import com.daml.ledger.api.v1.transaction.{
TreeEvent,
Transaction => ApiTransaction,
TransactionTree => ApiTransactionTree,
}
import com.daml.ledger.api.v1.transaction_service.{
GetFlatTransactionResponse,
GetTransactionResponse,
GetTransactionTreesResponse,
GetTransactionsResponse,
}
import com.daml.ledger.offset.Offset
import com.daml.lf.data.Time.Timestamp
import com.daml.platform.ApiOffset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,30 @@ import com.daml.logging.{ContextualizedLogger, LoggingContext}
import com.daml.platform.store.appendonlydao.events.ContractId
import com.daml.platform.store.backend.EventStorageBackend.FilterParams
import com.daml.platform.store.backend.common.ComposableQuery.{CompositeSql, SqlStringInterpolation}
import com.daml.platform.store.backend.common.{AppendOnlySchema, CompletionStorageBackendTemplate, ConfigurationStorageBackendTemplate, ContractStorageBackendTemplate, DataSourceStorageBackendTemplate, DeduplicationStorageBackendTemplate, EventStorageBackendTemplate, EventStrategy, IngestionStorageBackendTemplate, InitHookDataSourceProxy, IntegrityStorageBackendTemplate, PackageStorageBackendTemplate, ParameterStorageBackendTemplate, PartyStorageBackendTemplate, QueryStrategy}
import com.daml.platform.store.backend.{DBLockStorageBackend, DataSourceStorageBackend, DbDto, StorageBackend, common}
import com.daml.platform.store.backend.common.{
AppendOnlySchema,
CompletionStorageBackendTemplate,
ConfigurationStorageBackendTemplate,
ContractStorageBackendTemplate,
DataSourceStorageBackendTemplate,
DeduplicationStorageBackendTemplate,
EventStorageBackendTemplate,
EventStrategy,
IngestionStorageBackendTemplate,
InitHookDataSourceProxy,
IntegrityStorageBackendTemplate,
PackageStorageBackendTemplate,
ParameterStorageBackendTemplate,
PartyStorageBackendTemplate,
QueryStrategy,
}
import com.daml.platform.store.backend.{
DBLockStorageBackend,
DataSourceStorageBackend,
DbDto,
StorageBackend,
common,
}

import javax.sql.DataSource
import scala.util.control.NonFatal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,30 @@ import com.daml.platform.server.api.validation.ErrorFactories
import com.daml.platform.store.appendonlydao.events.Party
import com.daml.platform.store.backend.EventStorageBackend.FilterParams
import com.daml.platform.store.backend.common.ComposableQuery.{CompositeSql, SqlStringInterpolation}
import com.daml.platform.store.backend.common.{AppendOnlySchema, CompletionStorageBackendTemplate, ConfigurationStorageBackendTemplate, ContractStorageBackendTemplate, DataSourceStorageBackendTemplate, DeduplicationStorageBackendTemplate, EventStorageBackendTemplate, EventStrategy, IngestionStorageBackendTemplate, InitHookDataSourceProxy, IntegrityStorageBackendTemplate, PackageStorageBackendTemplate, ParameterStorageBackendTemplate, PartyStorageBackendTemplate, QueryStrategy}
import com.daml.platform.store.backend.{DBLockStorageBackend, DataSourceStorageBackend, DbDto, StorageBackend, common}
import com.daml.platform.store.backend.common.{
AppendOnlySchema,
CompletionStorageBackendTemplate,
ConfigurationStorageBackendTemplate,
ContractStorageBackendTemplate,
DataSourceStorageBackendTemplate,
DeduplicationStorageBackendTemplate,
EventStorageBackendTemplate,
EventStrategy,
IngestionStorageBackendTemplate,
InitHookDataSourceProxy,
IntegrityStorageBackendTemplate,
PackageStorageBackendTemplate,
ParameterStorageBackendTemplate,
PartyStorageBackendTemplate,
QueryStrategy,
}
import com.daml.platform.store.backend.{
DBLockStorageBackend,
DataSourceStorageBackend,
DbDto,
StorageBackend,
common,
}

import javax.sql.DataSource
import org.postgresql.ds.PGSimpleDataSource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ import com.daml.platform.store.cache.MutableCacheBackedContractStore._
import com.daml.platform.store.dao.events.ContractStateEvent
import com.daml.platform.store.dao.events.ContractStateEvent.LedgerEndMarker
import com.daml.platform.store.interfaces.LedgerDaoContractsReader
import com.daml.platform.store.interfaces.LedgerDaoContractsReader.{ActiveContract, ArchivedContract, ContractState, KeyState}
import com.daml.platform.store.interfaces.LedgerDaoContractsReader.{
ActiveContract,
ArchivedContract,
ContractState,
KeyState,
}

import java.util.concurrent.atomic.AtomicReference
import scala.concurrent.duration.{DurationInt, FiniteDuration}
Expand Down
Loading

0 comments on commit cc234a3

Please sign in to comment.