-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented in-memory buffers prunning in BaseLedger (#9936)
CHANGELOG_BEGIN CHANGELOG_END
- Loading branch information
Showing
8 changed files
with
86 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
ledger/participant-integration-api/src/main/scala/platform/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml | ||
|
||
import com.daml.ledger.participant.state.v1.Offset | ||
|
||
/** Type aliases used throughout the package */ | ||
package object platform { | ||
type PruneBuffers = Offset => Unit | ||
val PruneBuffersNoOp: PruneBuffers = _ => () | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ledger/participant-integration-api/src/test/suite/scala/platform/store/BaseLedgerSpec.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.daml.platform.store | ||
|
||
import com.daml.ledger.api.domain.LedgerId | ||
import com.daml.ledger.participant.state.v1.Offset | ||
import com.daml.logging.LoggingContext | ||
import com.daml.platform.PruneBuffers | ||
import com.daml.platform.store.dao.LedgerReadDao | ||
import org.mockito.MockitoSugar | ||
import org.scalatest.matchers.should.Matchers | ||
import org.scalatest.wordspec.AnyWordSpec | ||
|
||
class BaseLedgerSpec extends AnyWordSpec with MockitoSugar with Matchers { | ||
private val ledgerDao = mock[LedgerReadDao] | ||
private val pruneBuffers = mock[PruneBuffers] | ||
private implicit val loggingContext: LoggingContext = LoggingContext.ForTesting | ||
|
||
private val baseLedger = new BaseLedger( | ||
ledgerDao = ledgerDao, | ||
pruneBuffers = pruneBuffers, | ||
ledgerId = LedgerId("some ledger id"), | ||
transactionsReader = null, | ||
contractStore = null, | ||
dispatcher = null, | ||
) {} | ||
|
||
classOf[BaseLedger].getSimpleName when { | ||
"prune" should { | ||
"trigger prune on the ledger read dao and the buffers" in { | ||
val someOffset = Offset.fromByteArray(BigInt(1337L).toByteArray) | ||
baseLedger.prune(someOffset) | ||
|
||
verify(ledgerDao).prune(someOffset) | ||
verify(pruneBuffers).apply(someOffset) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters