Skip to content

Commit

Permalink
h2->mysql foreign key checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ac0v committed Jul 22, 2017
1 parent 2bbdd96 commit 41430a6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/java/nxt/BlockDb.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static BlockImpl findLastBlock() {
throw new RuntimeException("Last block already in database does not pass validation!", e);
}
}

static BlockImpl findLastBlock(int timestamp) {
try (Connection con = Db.getConnection();
PreparedStatement pstmt = con.prepareStatement("SELECT * FROM block WHERE timestamp <= ? ORDER BY timestamp DESC LIMIT 1")) {
Expand Down Expand Up @@ -136,7 +136,7 @@ static BlockImpl loadBlock(Connection con, ResultSet rs) throws NxtException.Val
long nonce = rs.getLong("nonce");

byte[] blockATs = rs.getBytes("ats");

return new BlockImpl(version, timestamp, previousBlockId, totalAmountNQT, totalFeeNQT, payloadLength, payloadHash,
generatorPublicKey, generationSignature, blockSignature, previousBlockHash,
cumulativeDifficulty, baseTarget, nextBlockId, height, id, nonce, blockATs);
Expand Down Expand Up @@ -241,10 +241,10 @@ static void deleteAll() {
try (Connection con = Db.getConnection();
Statement stmt = con.createStatement()) {
try {
stmt.executeUpdate("SET REFERENTIAL_INTEGRITY FALSE");
stmt.executeUpdate("SET foreign_key_checks = 0");
stmt.executeUpdate("TRUNCATE TABLE transaction");
stmt.executeUpdate("TRUNCATE TABLE block");
stmt.executeUpdate("SET REFERENTIAL_INTEGRITY TRUE");
stmt.executeUpdate("SET foreign_key_checks = 1");
Db.commitTransaction();
} catch (SQLException e) {
Db.rollbackTransaction();
Expand Down

0 comments on commit 41430a6

Please sign in to comment.