- @VisibleForTesting
- class RecoveryShardDataTreeTransactionFactory implements ShardDataTreeTransactionFactory {
-
- @Override
- public ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(String txId, String chainId) {
- return new ReadOnlyShardDataTreeTransaction(txId,
- new PruningShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces));
- }
-
- @Override
- public ReadWriteShardDataTreeTransaction newReadWriteTransaction(String txId, String chainId) {
- return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId,
- new PruningShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces).newModification());
- }
- }
-
- @VisibleForTesting
- class RegularShardDataTreeTransactionFactory implements ShardDataTreeTransactionFactory {
-
- @Override
- public ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(String txId, String chainId) {
- return new ReadOnlyShardDataTreeTransaction(txId, dataTree.takeSnapshot());
-
- }
-
- @Override
- public ReadWriteShardDataTreeTransaction newReadWriteTransaction(String txId, String chainId) {
- return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId, dataTree.takeSnapshot()
- .newModification());
- }
+ public DataTreeCandidate commit(DataTreeModification modification) throws DataValidationFailedException {
+ modification.ready();
+ dataTree.validate(modification);
+ DataTreeCandidateTip candidate = dataTree.prepare(modification);
+ dataTree.commit(candidate);
+ return candidate;