diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/blockchain/Net_AddBlock_Handler_utils/BlockchainWriter.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/blockchain/Net_AddBlock_Handler_utils/BlockchainWriter.java index 6d8f13c3..3387d01d 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/blockchain/Net_AddBlock_Handler_utils/BlockchainWriter.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/blockchain/Net_AddBlock_Handler_utils/BlockchainWriter.java @@ -66,14 +66,18 @@ public final class BlockchainWriter { try (Connection c = shine.db.DbController.getInstance().getConnection()) { c.setAutoCommit(false); try { - blocksDAO.insert(c, be); - + // blocks_store имеет внешний ключ (login, fork_number) на + // blockchain_state_store. Сначала создаём/обновляем runtime-state: + // это позволяет без отдельной предварительной записи принять + // самый первый HEADER ранее импортированной цепочки. st.setLastBlockNumber(block.blockNumber); st.setLastBlockHash(block.getHash32()); st.setFileSizeBytes(st.getFileSizeBytes() + rawDataItem.length); st.setUpdatedAtMs(nowMs); stateDAO.upsert(c, st); + blocksDAO.insert(c, be); + if (userParamEntry != null) userParamsDAO.upsertIfNewer(c, userParamEntry); if (channelNameStateEntry != null) channelNameStateDAO.insert(c, channelNameStateEntry); if (channelMetaUpdateEntry != null) channelNameStateDAO.updateMeta(c, channelMetaUpdateEntry); diff --git a/VERSION.properties b/VERSION.properties index 5a973e50..06a13a23 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ client.version=1.20.20 -server.version=1.16.16 +server.version=1.16.17