forked from Qortal-Forker/qortal
No need for database.DB class as the code is specific to HSQLDB so moved into relevant repository.hsqldb classes. Top-level Repository instance (e.g. HSQLDBRepository) is used within subclasses, e.g. HSQLDBBlockRepository, so they can share the same repository state, like underlying SQL Connection for easier transactional support. HSQLDBRepository subclasses now call checkedExecute() on top-level repository instance, instead of passing Connection to obsolete DB.checkedExecute. No need for qora.block.BlockFactory any more as those methods are now in repository. More work on Blocks and Transactions in general.
30 lines
961 B
Java
30 lines
961 B
Java
package repository.hsqldb;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import data.block.BlockTransactionData;
|
|
import repository.BlockTransactionRepository;
|
|
import repository.DataException;
|
|
|
|
public class HSQLDBBlockTransactionRepository implements BlockTransactionRepository {
|
|
|
|
protected HSQLDBRepository repository;
|
|
|
|
public HSQLDBBlockTransactionRepository(HSQLDBRepository repository) {
|
|
this.repository = repository;
|
|
}
|
|
|
|
public void save(BlockTransactionData blockTransactionData) throws DataException {
|
|
HSQLDBSaver saveHelper = new HSQLDBSaver("BlockTransactions");
|
|
saveHelper.bind("block_signature", blockTransactionData.getBlockSignature()).bind("sequence", blockTransactionData.getSequence())
|
|
.bind("transaction_signature", blockTransactionData.getTransactionSignature());
|
|
|
|
try {
|
|
saveHelper.execute(this.repository.connection);
|
|
} catch (SQLException e) {
|
|
throw new DataException("Unable to save BlockTransaction into repository", e);
|
|
}
|
|
}
|
|
|
|
}
|