forked from Qortal/qortal
Include proxy-forged blocks in BlockRepository.countForgedBlocks.
As used during validity check for ENABLE_FORGING transaction.
This commit is contained in:
parent
ae6b41a893
commit
7409c024f6
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user