Мелкие исправления

This commit is contained in:
AidarKC
2026-10-02 09:47:53 +03:00
parent de8700f8e0
commit 6b5734d535
5 changed files with 21 additions and 18 deletions
@@ -88,8 +88,8 @@ public final class ArweaveBlockSyncService {
if (blocksDAO.existsByDataItemId(id32) || importDAO.exists(id32)) continue; if (blocksDAO.existsByDataItemId(id32) || importDAO.exists(id32)) continue;
try { try {
byte[] rawDataItem = downloadSignedDataItem(dataItemId); DownloadedDataItem downloaded = downloadSignedDataItem(dataItemId);
if (importDAO.enqueueIfMissing(id32, height, rawDataItem, System.currentTimeMillis())) discovered++; if (importDAO.enqueueIfMissing(id32, downloaded.rootTxId(), height, downloaded.rawDataItem(), System.currentTimeMillis())) discovered++;
} catch (Exception e) { } catch (Exception e) {
lowestRetryHeight = Math.min(lowestRetryHeight, height); lowestRetryHeight = Math.min(lowestRetryHeight, height);
log.warn("Cannot retrieve signed DataItem {} at height {} yet: {}", dataItemId, height, e.getMessage()); log.warn("Cannot retrieve signed DataItem {} at height {} yet: {}", dataItemId, height, e.getMessage());
@@ -184,7 +184,7 @@ public final class ArweaveBlockSyncService {
* Gateways normally expose only the payload at /{dataItemId}. SHiNE needs the complete signed * Gateways normally expose only the payload at /{dataItemId}. SHiNE needs the complete signed
* DataItem, so obtain its exact offset/size inside the root L1 transaction and range-read it. * DataItem, so obtain its exact offset/size inside the root L1 transaction and range-read it.
*/ */
private byte[] downloadSignedDataItem(String dataItemId) throws Exception { private DownloadedDataItem downloadSignedDataItem(String dataItemId) throws Exception {
JsonNode offsets = getOffsets(dataItemId); JsonNode offsets = getOffsets(dataItemId);
String rootTxId = offsets.path("rootTxId").asText("").trim(); String rootTxId = offsets.path("rootTxId").asText("").trim();
long rootOffset = offsets.path("rootOffset").asLong(-1L); long rootOffset = offsets.path("rootOffset").asLong(-1L);
@@ -215,10 +215,12 @@ public final class ArweaveBlockSyncService {
if (!Arrays.equals(parsed.id32(), expectedId)) { if (!Arrays.equals(parsed.id32(), expectedId)) {
throw new IOException("Range returned another ANS-104 DataItem for " + dataItemId); throw new IOException("Range returned another ANS-104 DataItem for " + dataItemId);
} }
return bytes; return new DownloadedDataItem(rootTxId, bytes);
} }
} }
private record DownloadedDataItem(String rootTxId, byte[] rawDataItem) {}
private JsonNode getOffsets(String dataItemId) throws Exception { private JsonNode getOffsets(String dataItemId) throws Exception {
HttpRequest req = HttpRequest.newBuilder(URI.create(trim(cfg.syncGateway()) + "/ar-io/offsets/" + dataItemId)) HttpRequest req = HttpRequest.newBuilder(URI.create(trim(cfg.syncGateway()) + "/ar-io/offsets/" + dataItemId))
.timeout(Duration.ofSeconds(30)).header("Accept","application/json").GET().build(); .timeout(Duration.ofSeconds(30)).header("Accept","application/json").GET().build();
@@ -51,21 +51,22 @@ public final class ArweaveBlockImportDAO {
} }
/** Insert once. Existing IDs (including REJECTED) are deliberately not re-enqueued. */ /** Insert once. Existing IDs (including REJECTED) are deliberately not re-enqueued. */
public boolean enqueueIfMissing(byte[] dataItemId, long blockHeight, byte[] rawDataItem, long nowMs) public boolean enqueueIfMissing(byte[] dataItemId, String rootTxId, long blockHeight, byte[] rawDataItem, long nowMs)
throws SQLException { throws SQLException {
String sql = """ String sql = """
INSERT INTO arweave_block_import_queue( INSERT INTO arweave_block_import_queue(
data_item_id,block_height,raw_data_item,status,last_error,first_seen_at_ms,updated_at_ms data_item_id,root_tx_id,block_height,raw_data_item,status,last_error,first_seen_at_ms,updated_at_ms
) VALUES(?,?,?,?, '',?,?) ) VALUES(?,?,?,?,?, '',?,?)
ON CONFLICT(data_item_id) DO NOTHING ON CONFLICT(data_item_id) DO NOTHING
"""; """;
try (Connection c = db.getConnection(); PreparedStatement ps = c.prepareStatement(sql)) { try (Connection c = db.getConnection(); PreparedStatement ps = c.prepareStatement(sql)) {
ps.setBytes(1, dataItemId); ps.setBytes(1, dataItemId);
ps.setLong(2, blockHeight); ps.setString(2, rootTxId == null ? "" : rootTxId.trim());
ps.setBytes(3, rawDataItem); ps.setLong(3, blockHeight);
ps.setString(4, STATUS_PENDING); ps.setBytes(4, rawDataItem);
ps.setLong(5, nowMs); ps.setString(5, STATUS_PENDING);
ps.setLong(6, nowMs); ps.setLong(6, nowMs);
ps.setLong(7, nowMs);
return ps.executeUpdate() > 0; return ps.executeUpdate() > 0;
} }
} }
@@ -228,11 +228,11 @@ public final class PeriodicBlockchainSyncService {
try { try {
BlockchainResyncCleanupDAO.CleanupResult cleanup = BlockchainResyncCleanupDAO.CleanupResult cleanup =
RESYNC_CLEANUP_DAO.cleanupBlockchainForFullResync(blockchainName); RESYNC_CLEANUP_DAO.cleanupBlockchainForFullResync(blockchainName);
log.info("Blockchain resync cleanup finished: blockchainName={} login={} likesAdjusted={} repliesAdjusted={} deletedBlocks={} deletedState={}", log.info("Blockchain resync cleanup finished: blockchainName={} login={} deletedReactionsState={} deletedConnectionsState={} deletedBlocks={} deletedState={}",
blockchainName, blockchainName,
cleanup.login(), cleanup.login(),
cleanup.likesAdjustedRows(), cleanup.deletedReactionsStateRows(),
cleanup.repliesAdjustedRows(), cleanup.deletedConnectionsStateRows(),
cleanup.deletedBlocksRows(), cleanup.deletedBlocksRows(),
cleanup.deletedBlockchainStateRows()); cleanup.deletedBlockchainStateRows());
+2 -2
View File
@@ -1,2 +1,2 @@
client.version=1.14.6 client.version=1.14.7
server.version=1.12.4 server.version=1.12.5
@@ -161,7 +161,7 @@ export async function createSolanaWalletFromPrivateBase58(privateKey32Base58) {
}; };
} }
) { export async function getWalletFromStoredClientKey({ login, storagePwd }) {
const cleanLogin = String(login || '').trim(); const cleanLogin = String(login || '').trim();
const cleanPwd = String(storagePwd || '').trim(); const cleanPwd = String(storagePwd || '').trim();
if (!cleanLogin || !cleanPwd) { if (!cleanLogin || !cleanPwd) {
@@ -200,7 +200,7 @@ export async function getWalletFromStoredBlockchainKey({ login, storagePwd }) {
}; };
} }
) { export async function getWalletFromStoredRootKey({ login, storagePwd }) {
const cleanLogin = String(login || '').trim(); const cleanLogin = String(login || '').trim();
const cleanPwd = String(storagePwd || '').trim(); const cleanPwd = String(storagePwd || '').trim();
if (!cleanLogin || !cleanPwd) { if (!cleanLogin || !cleanPwd) {