forked from Qortal/qortal
Speed up fetching block height based on timestamp
This commit is contained in:
parent
8a1e2f4111
commit
c628f97d8c
@ -120,7 +120,7 @@ public class HSQLDBBlockRepository implements BlockRepository {
|
||||
@Override
|
||||
public int getHeightFromTimestamp(long timestamp) throws DataException {
|
||||
// Uses (minted_when, height) index
|
||||
String sql = "SELECT height FROM Blocks WHERE minted_when <= ? ORDER BY minted_when DESC LIMIT 1";
|
||||
String sql = "SELECT height FROM Blocks WHERE minted_when <= ? ORDER BY minted_when DESC, height DESC LIMIT 1";
|
||||
|
||||
try (ResultSet resultSet = this.repository.checkedExecute(sql, timestamp)) {
|
||||
if (resultSet == null)
|
||||
|
Loading…
Reference in New Issue
Block a user