-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
R3SOL-367 Extract ledger persistence to library (#6346)
Move `UtxoPersistenceServiceImpl` and its related classes as part of ledger persistence to `ledger-lib-persistence`. The library itself does not have any OSGi services and only includes OSGi package annotations to keep everything working. The library is then called from `ledger-persistence` to keep existing functionality the same. The JSON validator module was also split to remove OSGi references. Changes include: - `UtxoPersistenceServiceImpl` -> `ledger-lib-persistence`. - `DefaultContractStateVaultJsonFactory` -> `ledger-lib-persistence`. - `ContractStateVaultJsonFactoryRegistry` -> `ledger-lib-persistence`. - `PostgresUtxoQueryProvider` -> `ledger-lib-persistence`. - `UtxoRepositoryImpl` -> `ledger-lib-persistence`. - Copies of `SignatureSpec`, `SignatureWithKey` and `SignedGroupParameters` added to remove Avro dependency. - `JsonValidator` -> `json-validator-lib`. - `JsonValidatorImpl` -> `json-validator-lib-impl` with an OSGi version remaining in existing module. --------- Co-authored-by: nkovacsx <[email protected]> Co-authored-by: Dan Newton <[email protected]>
- Loading branch information
1 parent
1979410
commit b1de83d
Showing
95 changed files
with
501 additions
and
239 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
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
2 changes: 1 addition & 1 deletion
2
...ain/kotlin/net/corda/ledger/persistence/consensual/impl/ConsensualComponentGroupMapper.kt
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
2 changes: 1 addition & 1 deletion
2
...in/kotlin/net/corda/ledger/persistence/json/impl/ContractStateVaultJsonFactoryProvider.kt
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
2 changes: 1 addition & 1 deletion
2
...otlin/net/corda/ledger/persistence/json/impl/ContractStateVaultJsonFactoryRegistryImpl.kt
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
2 changes: 1 addition & 1 deletion
2
...kotlin/net/corda/ledger/persistence/json/impl/DefaultContractStateVaultJsonFactoryImpl.kt
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
27 changes: 27 additions & 0 deletions
27
...e/src/main/kotlin/net/corda/ledger/persistence/utxo/impl/PostgresUtxoOsgiQueryProvider.kt
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,27 @@ | ||
package net.corda.ledger.persistence.utxo.impl | ||
|
||
import net.corda.ledger.libs.persistence.utxo.impl.PostgresUtxoQueryProvider | ||
import net.corda.ledger.libs.persistence.utxo.impl.UtxoQueryProvider | ||
import net.corda.orm.DatabaseTypeProvider | ||
import net.corda.orm.DatabaseTypeProvider.Companion.POSTGRES_TYPE_FILTER | ||
import net.corda.utilities.debug | ||
import org.osgi.service.component.annotations.Activate | ||
import org.osgi.service.component.annotations.Component | ||
import org.osgi.service.component.annotations.Reference | ||
import org.slf4j.LoggerFactory | ||
|
||
@Suppress("unused") | ||
@Component(service = [ UtxoQueryProvider::class ]) | ||
class PostgresUtxoOsgiQueryProvider( | ||
databaseTypeProvider: DatabaseTypeProvider, | ||
delegate: UtxoQueryProvider | ||
) : UtxoQueryProvider by delegate { | ||
init { | ||
LoggerFactory.getLogger(this::class.java).debug { "Activated for ${databaseTypeProvider.databaseType}" } | ||
} | ||
|
||
@Activate constructor( | ||
@Reference(target = POSTGRES_TYPE_FILTER) | ||
databaseTypeProvider: DatabaseTypeProvider | ||
) : this(databaseTypeProvider, PostgresUtxoQueryProvider()) | ||
} |
38 changes: 38 additions & 0 deletions
38
...sistence/src/main/kotlin/net/corda/ledger/persistence/utxo/impl/UtxoRepositoryOsgiImpl.kt
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,38 @@ | ||
package net.corda.ledger.persistence.utxo.impl | ||
|
||
import net.corda.db.core.utils.BatchPersistenceServiceImpl | ||
import net.corda.ledger.common.data.transaction.factory.WireTransactionFactory | ||
import net.corda.ledger.libs.persistence.utxo.UtxoRepository | ||
import net.corda.ledger.libs.persistence.utxo.impl.UtxoQueryProvider | ||
import net.corda.ledger.libs.persistence.utxo.impl.UtxoRepositoryImpl | ||
import net.corda.sandbox.type.SandboxConstants.CORDA_MARKER_ONLY_SERVICE | ||
import net.corda.sandbox.type.UsedByPersistence | ||
import net.corda.v5.application.serialization.SerializationService | ||
import org.osgi.service.component.annotations.Activate | ||
import org.osgi.service.component.annotations.Component | ||
import org.osgi.service.component.annotations.Reference | ||
import org.osgi.service.component.annotations.ServiceScope.PROTOTYPE | ||
|
||
/** | ||
* Reads and writes ledger transaction data to and from the virtual node vault database. | ||
* The component only exists to be created inside a PERSISTENCE sandbox. We denote it | ||
* as "corda.marker.only" to force the sandbox to create it, despite it implementing | ||
* only the [UsedByPersistence] marker interface. | ||
*/ | ||
@Component( | ||
service = [ UtxoRepository::class, UsedByPersistence::class ], | ||
property = [ CORDA_MARKER_ONLY_SERVICE ], | ||
scope = PROTOTYPE | ||
) | ||
class UtxoRepositoryOsgiImpl(delegate: UtxoRepository) : UtxoRepository by delegate, UsedByPersistence { | ||
@Suppress("Unused") | ||
@Activate | ||
constructor( | ||
@Reference(service = SerializationService::class) | ||
serializationService: SerializationService, | ||
@Reference(service = WireTransactionFactory::class) | ||
wireTransactionFactory: WireTransactionFactory, | ||
@Reference(service = UtxoQueryProvider::class) | ||
queryProvider: UtxoQueryProvider | ||
) : this(UtxoRepositoryImpl(BatchPersistenceServiceImpl(), serializationService, wireTransactionFactory, queryProvider)) | ||
} |
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
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
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
Oops, something went wrong.