diff --git a/src/main/java/org/qora/repository/BlockRepository.java b/src/main/java/org/qora/repository/BlockRepository.java index 99029146..459c72ed 100644 --- a/src/main/java/org/qora/repository/BlockRepository.java +++ b/src/main/java/org/qora/repository/BlockRepository.java @@ -94,7 +94,7 @@ public interface BlockRepository { } /** - * Returns number of blocks forged by account with given public key. + * Returns number of blocks forged by account with given public key, including proxy-forged blocks. * * @param publicKey * @return number of blocks diff --git a/src/main/java/org/qora/repository/hsqldb/HSQLDBBlockRepository.java b/src/main/java/org/qora/repository/hsqldb/HSQLDBBlockRepository.java index 02295e5a..d8ec9e9c 100644 --- a/src/main/java/org/qora/repository/hsqldb/HSQLDBBlockRepository.java +++ b/src/main/java/org/qora/repository/hsqldb/HSQLDBBlockRepository.java @@ -156,7 +156,11 @@ public class HSQLDBBlockRepository implements BlockRepository { @Override public int countForgedBlocks(byte[] publicKey) throws DataException { - try (ResultSet resultSet = this.repository.checkedExecute("SELECT COUNT(*) FROM Blocks WHERE generator = ? LIMIT 1", publicKey)) { + String subquerySql = "SELECT proxy_public_key FROM ProxyForgers WHERE forger = ?"; + + String sql = "SELECT COUNT(*) FROM Blocks WHERE generator IN (?, (" + subquerySql + ")) LIMIT 1"; + + try (ResultSet resultSet = this.repository.checkedExecute(sql, publicKey, publicKey)) { return resultSet.getInt(1); } catch (SQLException e) { throw new DataException("Unable to fetch forged blocks count from repository", e);