Ускорить публикацию блоков в Arweave

This commit is contained in:
AidarKC
2026-10-03 16:39:35 +03:00
parent aca1e3054e
commit daa221a158
13 changed files with 629 additions and 240 deletions
@@ -68,6 +68,16 @@ public final class BlocksDAO {
}
}
/** Возвращает ещё не опубликованный пользовательский DataItem для быстрой Turbo-попытки. */
public BlockEntry getPendingArweaveByDataItemId(byte[] dataItemId) throws SQLException {
if (dataItemId == null || dataItemId.length != 32) return null;
String sql = baseSelect() + " WHERE data_item_id=? AND arweave_publish_pending=TRUE LIMIT 1";
try (Connection c = db.getConnection(); PreparedStatement ps = c.prepareStatement(sql)) {
ps.setBytes(1, dataItemId);
try (ResultSet rs = ps.executeQuery()) { return rs.next() ? mapRow(rs) : null; }
}
}
public List<BlockEntry> listPendingArweave(int limit) throws SQLException {
int safeLimit = Math.max(1, Math.min(limit, 100_000));
String sql = """
@@ -132,6 +132,20 @@ public final class KeyRotationCandidateBlocksDAO {
}
}
/** Возвращает ещё не опубликованный candidate DataItem для быстрой Turbo-попытки. */
public KeyRotationCandidateBlockEntry getPendingArweaveByDataItemId(byte[] dataItemId) throws SQLException {
if (dataItemId == null || dataItemId.length != 32) return null;
try (Connection c = db.getConnection();
PreparedStatement ps = c.prepareStatement("""
SELECT * FROM key_rotation_candidate_blocks
WHERE data_item_id = ? AND arweave_publish_pending = TRUE
LIMIT 1
""")) {
ps.setBytes(1, dataItemId);
try (ResultSet rs = ps.executeQuery()) { return rs.next() ? map(rs) : null; }
}
}
/** Candidate-блоки имеют приоритет перед обычной очередью publisher-а. */
public List<KeyRotationCandidateBlockEntry> listPendingArweave(int limit) throws SQLException {
if (limit <= 0) return List.of();