Packages

trait ActiveContractStore extends ActiveContractSnapshot with ConflictDetectionStore[LfContractId, Status]

The active contract store (ACS) stores for every contract ID whether it is ActiveContractStore.Active, ActiveContractStore.Archived, or ActiveContractStore.ReassignedAway, along with the timestamp of the latest change. Every change is associated with the timestamp and the optional repair counter of the operation (e.g. transaction, repair) that triggered the change. The changes are ordered first by timestamp, then by repair counter, and finally by change type (activations before deactivations). Implementations must be thread-safe. Updates must be idempotent.

Creations, reassignments, and archivals can be mixed arbitrarily. A contract may be assigned and unassigned several times during its lifetime. It becomes active with every assignment and reassigned away with every unassignment. If the ACS detects irregularities, the change method reports them.

These methods are supposed to be called by the ConflictDetector only, which coordinates the request journal updates and the updates to the ACS.

Updates may be written asynchronously. Every implementation determines an order over all the changes and queries to the ACS. Each individual change must be applied atomically and the result is determined with respect to this order. This order need not be consistent with the order of the calls, though. However, the following is guaranteed: If the future returned by a call completes and observing the completion happens before another call, then all changes of the former call must be ordered before all changes of the later call.

Bulk methods like ActiveContractStore.markContractsCreated and ActiveContractStore.archiveContracts generate one individual change for each contract. So their changes may be interleaved with other calls.

See also

ActiveContractSnapshot for the ACS snapshot interface

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ActiveContractStore
  2. ConflictDetectionStore
  3. Purgeable
  4. PrunableByTime
  5. ActiveContractSnapshot
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract def activenessOf(contracts: Seq[LfContractId])(implicit traceContext: TraceContext): FutureUnlessShutdown[SortedMap[LfContractId, Seq[(CantonTimestamp, ActivenessChangeDetail)]]]

    Returns the states of contracts at the given timestamp.

    Returns the states of contracts at the given timestamp.

    contracts

    The contracts whose state we return. If empty, we return an empty map. Omits from the response contracts that do not have an activeness state.

    returns

    A map from contracts to the timestamp when the state changed, and the activeness change detail. The map is sorted by cats.kernel.Order[com.digitalasset.canton.protocol.LfContractId].

    Definition Classes
    ActiveContractSnapshot
  2. abstract def advancePruningTimestamp(phase: PruningPhase, timestamp: CantonTimestamp)(implicit traceContext: TraceContext): FutureUnlessShutdown[Unit]
    Attributes
    protected[canton]
    Definition Classes
    PrunableByTime
    Annotations
    @VisibleForTesting()
  3. abstract def assignContracts(assignments: Seq[(LfContractId, Source[SynchronizerId], ReassignmentCounter, TimeOfChange)])(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Marks the given contracts as assigned from toc's timestamp (inclusive) onwards.

    Marks the given contracts as assigned from toc's timestamp (inclusive) onwards.

    assignments

    The contract IDs to assign, each with its source synchronizer, reassignment counter and time of change.

    returns

    The future completes when the contract states have been updated. The following irregularities are reported:

  4. abstract def changesBetween(fromExclusive: TimeOfChange, toInclusive: TimeOfChange)(implicit traceContext: TraceContext): FutureUnlessShutdown[LazyList[(TimeOfChange, ActiveContractIdsChange)]]

    Returns all changes to the active contract set between the two timestamps (exclusive lower bound timestamp, inclusive upper bound timestamp) in the order of their changes.

    Returns all changes to the active contract set between the two timestamps (exclusive lower bound timestamp, inclusive upper bound timestamp) in the order of their changes. The provided lower bound must not be larger than the upper bound.

    fromExclusive

    The lower bound for the changes. Must not be larger than the upper bound.

    toInclusive

    The upper bound for the changes. Must not be smaller than the lower bound.

    Definition Classes
    ActiveContractSnapshot
    Exceptions thrown

    java.lang.IllegalArgumentException If the intervals are in the wrong order.

  5. abstract def contractCount(timestamp: CantonTimestamp)(implicit traceContext: TraceContext): FutureUnlessShutdown[Int]

    Returns the total number of contracts whose states are stored at the given timestamp.

    Returns the total number of contracts whose states are stored at the given timestamp.

    To get a consistent snapshot, the caller must ensure that the timestamp specifies a time that is not in the future, i.e., not after the timestamp of the clean cursor in the com.digitalasset.canton.participant.protocol.RequestJournal Note that the result may change between two invocations if prune is called in the meantime.

  6. abstract def contractSnapshot(contractIds: Set[LfContractId], timeOfChange: TimeOfChange)(implicit traceContext: TraceContext): FutureUnlessShutdown[Map[LfContractId, TimeOfChange]]

    Returns a map to the time of change when the contract became active for the last time before or at the given time of change.

    Returns a map to the time of change when the contract became active for the last time before or at the given time of change. Omits contracts that not active right after the given time of change.

    timeOfChange

    The time of change at which the activeness of the contracts shall be determined. Must be before the timestamp that corresponds to the head cursor in the com.digitalasset.canton.participant.protocol.RequestJournal for the state com.digitalasset.canton.participant.protocol.RequestJournal.RequestState.Clean. If this precondition is violated, the returned snapshot may be inconsistent, i.e., it may omit some contracts that were ActiveContractStore.Active at the given time and it may include contracts that were actually ActiveContractStore.Archived or ActiveContractStore.ReassignedAway.

    Definition Classes
    ActiveContractSnapshot
  7. abstract def contractsReassignmentCounterSnapshotBefore(contractIds: Set[LfContractId], timestampExclusive: CantonTimestamp)(implicit traceContext: TraceContext): FutureUnlessShutdown[Map[LfContractId, ReassignmentCounter]]

    Returns a map to the latest reassignment counter of the contracts before the given timestamp.

    Returns a map to the latest reassignment counter of the contracts before the given timestamp. Fails if not all given contract ids are active in the ACS, or if the ACS has not defined their latest reassignment counter.

    Definition Classes
    ActiveContractSnapshot
    Exceptions thrown

    java.lang.IllegalArgumentException if not all given contract ids are active in the ACS, if the ACS does not contain the latest reassignment counter for each given contract id.

  8. abstract def deleteSince(criterion: TimeOfChange)(implicit traceContext: TraceContext): FutureUnlessShutdown[Unit]

    Deletes all activeness changes from requests whose time of change is at least the given one.

    Deletes all activeness changes from requests whose time of change is at least the given one. This method must not be called concurrently with creating, archiving, or reassigning contracts.

    Therefore, this method need not be linearizable w.r.t. creating, archiving, or reassigning contracts. For example, if a request at toc1 creates a contract c and another request at toc2 archives it while deleteSince is running for some toc <= toc1, toc2, then there are no guarantees which of the effects of the requests remain. For example, c could end up being nonexistent, active, or archived but never created, even if the writes for the requests are successful.

  9. abstract def doPrune(beforeAndIncluding: CantonTimestamp, lastPruning: Option[CantonTimestamp])(implicit traceContext: TraceContext): FutureUnlessShutdown[Int]

    Deletes all entries about archived contracts whose status hasn't changed after the timestamp.

    Deletes all entries about archived contracts whose status hasn't changed after the timestamp.

    The caller must ensure that the given timestamp is at most the one of the clean cursor in the com.digitalasset.canton.participant.protocol.RequestJournal

    returns

    the approximate number of pruned rows, used to adjust the pruning windows to reach optimal batch sizes

    Attributes
    protected[canton]
    Definition Classes
    ActiveContractStorePrunableByTime
  10. implicit abstract val ec: ExecutionContext
    Attributes
    protected
    Definition Classes
    PrunableByTime
  11. abstract def fetchStates(contractIds: Iterable[LfContractId])(implicit traceContext: TraceContext): FutureUnlessShutdown[Map[LfContractId, ContractState]]

    Returns the latest com.digitalasset.canton.participant.store.ActiveContractStore.Status for the given contract IDs along with its com.digitalasset.canton.participant.util.TimeOfChange.

    Returns the latest com.digitalasset.canton.participant.store.ActiveContractStore.Status for the given contract IDs along with its com.digitalasset.canton.participant.util.TimeOfChange.

    This method is used by the protocol processors for conflict detection. In-flight transactions may have changesets not yet written to the ACS datastore. Since only the ConflictDetector tracks in-flight changesets, this method cannot be used as a source of valid data to other components.

    If a contract is created or assigned and archived or unassigned at the same com.digitalasset.canton.participant.util.TimeOfChange, the contract is ActiveContractStore.Archived or ActiveContractStore.ReassignedAway. A contract cannot be archived and unassigned at the same timestamp.

    returns

    The map from contracts in contractIds in the store to their latest state. Nonexistent contracts are excluded from the map.

    Definition Classes
    ActiveContractStoreConflictDetectionStore
    See also

    ActiveContractSnapshot!.snapshot

  12. abstract def markContractsCreatedOrAdded(contracts: Seq[(LfContractId, ReassignmentCounter, TimeOfChange)], isCreation: Boolean)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]
  13. abstract def packageUsage(pkg: PackageId, contractStore: ContractStore)(implicit traceContext: TraceContext): FutureUnlessShutdown[Option[LfContractId]]

    Returns Some(contractId) if an active contract belonging to package pkg exists, otherwise returns None.

    Returns Some(contractId) if an active contract belonging to package pkg exists, otherwise returns None. The returned contractId may be any active contract from package pkg. The most recent contract state is used.

    Definition Classes
    ActiveContractSnapshot
  14. abstract def pruningStatus(implicit traceContext: TraceContext): FutureUnlessShutdown[Option[PruningStatus]]

    Returns the latest timestamp at which pruning was started or completed.

    Returns the latest timestamp at which pruning was started or completed. For com.digitalasset.canton.pruning.PruningPhase.Started, it is guaranteed that no pruning has been run on the store after the returned timestamp. For com.digitalasset.canton.pruning.PruningPhase.Completed, it is guaranteed that the store is pruned at least up to the returned timestamp (inclusive). That is, another pruning with the returned timestamp (or earlier) has no effect on the store. Returns scala.None$ if no pruning has ever been started on the store.

    Definition Classes
    PrunableByTime
  15. abstract def purge()(implicit traceContext: TraceContext): FutureUnlessShutdown[Unit]

    Purges all data from the store.

    Purges all data from the store. This MUST ONLY be invoked when none of the data is needed anymore for example on synchronizer migration once all the data has been reassigned to the new synchronizer.

    Definition Classes
    Purgeable
  16. abstract def purgeOrArchiveContracts(contracts: Seq[(LfContractId, TimeOfChange)], isArchival: Boolean)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Depending on the isArchival, will archive (effect of a Daml transaction) or purge (repair service)

  17. abstract def snapshot(timeOfChange: TimeOfChange)(implicit traceContext: TraceContext): FutureUnlessShutdown[SortedMap[LfContractId, (TimeOfChange, ReassignmentCounter)]]

    Returns all contracts that were active right after the given time of change, and when the contract became active for the last time before or at the given time of change.

    Returns all contracts that were active right after the given time of change, and when the contract became active for the last time before or at the given time of change.

    timeOfChange

    The time of change at which the snapshot shall be taken. Must be before the timestamp that corresponds to the head cursor in the com.digitalasset.canton.participant.protocol.RequestJournal for the state com.digitalasset.canton.participant.protocol.RequestJournal.RequestState.Clean. If this precondition is violated, the returned snapshot may be inconsistent, i.e., it may omit some contracts that were ActiveContractStore.Active at the given time and it may include contracts that were actually ActiveContractStore.Archived or ActiveContractStore.ReassignedAway.

    returns

    A map from contracts to the latest timestamp (no later than the given timeOfChange) when they became active again. It contains exactly those contracts that were active right after the given time of change. If a contract is created or assigned and archived or unassigned at the same time of change, it does not show up in any snapshot. The map is sorted by cats.kernel.Order[com.digitalasset.canton.protocol.LfContractId].

    Definition Classes
    ActiveContractSnapshot
  18. abstract def unassignContracts(unassignments: Seq[(LfContractId, Target[SynchronizerId], ReassignmentCounter, TimeOfChange)])(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Marks the given contracts as ActiveContractStore.ReassignedAway from toc's timestamp (inclusive) onwards.

    Marks the given contracts as ActiveContractStore.ReassignedAway from toc's timestamp (inclusive) onwards.

    unassignments

    The contract IDs to unassign, each with its target synchronizer, reassignment counter and time of change.

    returns

    The future completes when the contract state has been updated. The following irregularities are reported:

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def archiveContract(cid: LfContractId, toc: TimeOfChange)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Shorthand for archiveContracts(Seq(cid), toc)

  5. def archiveContracts(contractIds: Seq[LfContractId], toc: TimeOfChange)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Marks the given contracts as archived from toc's timestamp (inclusive) onwards.

    Marks the given contracts as archived from toc's timestamp (inclusive) onwards.

    contractIds

    The contract IDs of the contracts to be archived Note: this method should not take as parameter the reassignment counter for the archived contract IDs, because one cannot know the correct reassignment counter for an archival at request finalization time, which is when this method is called. The com.digitalasset.canton.participant.event.RecordOrderPublisher determines the correct reassignment counter for an archival only when all requests preceding the archival (i.e., with a lower request counter than the archival transaction) were processed. Therefore, we determine the reassignment counter for archivals in the com.digitalasset.canton.participant.event.RecordOrderPublisher, when the record order publisher triggers an acs change event.

    toc

    The time of change consisting of:

    • The request counter of the confirmation request that archives the contracts.
    • The timestamp on the confirmation request that archives the contracts.
    returns

    The future completes when all contract states have been updated. The following irregularities are reported for each contract:

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def assignContract(contractId: LfContractId, toc: TimeOfChange, sourceSynchronizer: Source[SynchronizerId], reassignmentCounter: ReassignmentCounter)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]
  8. def batchingParameters: Option[PrunableByTimeParameters]

    Parameters to control prune batching

    Parameters to control prune batching

    If defined, then the pruning window will be computed such that it targets the ideal target batch size in order to optimize the load on the database.

    This is currently used with the journal stores. Normal pruning of other stores already does batching on its own.

    Attributes
    protected
    Definition Classes
    PrunableByTime
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  10. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  11. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  12. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  13. def getSynchronizerIndices(synchronizers: Seq[SynchronizerId]): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Map[SynchronizerId, IndexedSynchronizer]]
    Attributes
    protected
  14. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. def kind: String
    Attributes
    protected
    Definition Classes
    ActiveContractStorePrunableByTime
  17. def markContractAdded(contract: (LfContractId, ReassignmentCounter, TimeOfChange))(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Shorthand for markContractAdded(Seq(contract), toc)

  18. def markContractCreated(contract: (LfContractId, ReassignmentCounter), toc: TimeOfChange)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Shorthand for markContractsCreated(Seq(contract), toc)

  19. def markContractsAdded(contracts: Seq[(LfContractId, ReassignmentCounter, TimeOfChange)])(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Marks the given contracts as active from timestamp (inclusive) onwards.

    Marks the given contracts as active from timestamp (inclusive) onwards.

    Unlike creation, add can be done several times in the life of a contract. It is intended to be used for ACS import and purges (e.g. repair service and party replication).

  20. def markContractsCreated(contracts: Seq[(LfContractId, ReassignmentCounter)], toc: TimeOfChange)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Marks the given contracts as active from timestamp (inclusive) onwards.

    Marks the given contracts as active from timestamp (inclusive) onwards.

    contracts

    The contracts represented as a tuple of contract id and reassignment counter

    toc

    The time of change consisting of:

    • The request counter of the confirmation request that created the contracts
    • The timestamp of the confirmation request that created the contracts.
    returns

    The future completes when all contract states have been updated. The following irregularities are reported for each contract:

  21. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  22. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  23. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  24. final def prune(limit: CantonTimestamp)(implicit errorLoggingContext: ErrorLoggingContext, closeContext: CloseContext): FutureUnlessShutdown[Unit]

    Prune all unnecessary data relating to events before the given timestamp.

    Prune all unnecessary data relating to events before the given timestamp.

    The meaning of "unnecessary", and whether the limit is inclusive or exclusive both depend on the particular store. The store must implement the actual pruning logic in the doPrune method.

    Definition Classes
    PrunableByTime
  25. def purgeContract(cid: LfContractId, toc: TimeOfChange)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Shorthand for purgeContracts(Seq(cid), toc)

  26. def purgeContracts(contractIds: Seq[(LfContractId, TimeOfChange)])(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]

    Marks the given contracts as inactive from timestamp (inclusive) onwards.

    Marks the given contracts as inactive from timestamp (inclusive) onwards.

    Unlike archival, purge can be done several times in the life of a contract. It is intended to be used by the repair service.

  27. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  28. def synchronizerIdFromIdx(idx: Int)(implicit ec: ExecutionContext, loggingContext: ErrorLoggingContext): FutureUnlessShutdown[SynchronizerId]
    Attributes
    protected
  29. def toString(): String
    Definition Classes
    AnyRef → Any
  30. def unassignContracts(contractId: LfContractId, toc: TimeOfChange, targetSynchronizer: Target[SynchronizerId], reassignmentCounter: ReassignmentCounter)(implicit traceContext: TraceContext): CheckedT[FutureUnlessShutdown, AcsError, AcsWarning, Unit]
  31. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  32. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from Purgeable

Inherited from PrunableByTime

Inherited from ActiveContractSnapshot

Inherited from AnyRef

Inherited from Any

Ungrouped