Сделал что бы в базу писался msgSubType и поля to (to login, toBlockchainName и т.д.)
This commit is contained in:
AidarKC
2026-01-02 20:15:59 +03:00
parent eef760d776
commit dd49c4de00
8 changed files with 129 additions and 22 deletions
@@ -21,6 +21,10 @@ import java.sql.Statement;
* - ip_geo_cache
* - blockchain_state (MVP)
* - blocks (login TEXT, bchName TEXT, PK убран)
*
* ОБНОВЛЕНО:
* - blocks: добавлено поле msgSubType (сразу после msgType)
* - blocks: поля to* остаются nullable
*/
public class DatabaseInitializer {
@@ -195,7 +199,7 @@ public class DatabaseInitializer {
ON blockchain_state (updated_at_ms);
""");
// 6. blocks — PK удалён полностью, to* теперь nullable
// 6. blocks — PK удалён полностью, to* теперь nullable, добавлен msgSubType
st.executeUpdate("""
CREATE TABLE IF NOT EXISTS blocks (
login TEXT NOT NULL,
@@ -208,6 +212,7 @@ public class DatabaseInitializer {
blockLinePreHashe TEXT NOT NULL,
msgType INTEGER NOT NULL,
msgSubType INTEGER NOT NULL,
blockByte BLOB,
@@ -45,12 +45,13 @@ public final class BlocksDAO {
blockLineNumber,
blockLinePreHashe,
msgType,
msgSubType,
blockByte,
to_login,
toBchName,
toBlockGlobalNumber,
toBlockHashe
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""";
try (PreparedStatement ps = c.prepareStatement(sql)) {
@@ -104,6 +105,7 @@ public final class BlocksDAO {
blockLineNumber,
blockLinePreHashe,
msgType,
msgSubType,
blockByte,
to_login,
toBchName,
@@ -157,6 +159,7 @@ public final class BlocksDAO {
blockGlobalPreHashe = ?,
blockLinePreHashe = ?,
msgType = ?,
msgSubType = ?,
blockByte = ?,
to_login = ?,
toBchName = ?,
@@ -176,6 +179,7 @@ public final class BlocksDAO {
ps.setString(i++, nn(e.getBlockGlobalPreHashe()));
ps.setString(i++, nn(e.getBlockLinePreHashe()));
ps.setInt(i++, e.getMsgType());
ps.setInt(i++, e.getMsgSubType());
byte[] bytes = e.getBlockByte();
if (bytes != null) ps.setBytes(i++, bytes);
@@ -270,6 +274,7 @@ public final class BlocksDAO {
ps.setString(i++, nn(e.getBlockLinePreHashe()));
ps.setInt(i++, e.getMsgType());
ps.setInt(i++, e.getMsgSubType());
byte[] bytes = e.getBlockByte();
if (bytes != null) ps.setBytes(i++, bytes);
@@ -301,6 +306,7 @@ public final class BlocksDAO {
e.setBlockLinePreHashe(rs.getString("blockLinePreHashe"));
e.setMsgType(rs.getInt("msgType"));
e.setMsgSubType(rs.getInt("msgSubType"));
e.setBlockByte(rs.getBytes("blockByte"));
@@ -11,6 +11,9 @@ package shine.db.entities;
* - toBlockGlobalNumber INTEGER nullable
* - toBlockHashe TEXT nullable
*
* ДОБАВЛЕНО:
* - msgSubType INTEGER (uint16 по смыслу, храним как int)
*
* PRIMARY KEY пока убран вообще.
*/
public class BlockEntry {
@@ -26,6 +29,7 @@ public class BlockEntry {
private String blockLinePreHashe; // TEXT
private int msgType; // int16 (храним как int)
private int msgSubType; // int16 (храним как int)
private byte[] blockByte; // BLOB
@@ -44,6 +48,7 @@ public class BlockEntry {
int blockLineNumber,
String blockLinePreHashe,
int msgType,
int msgSubType,
byte[] blockByte,
String toLogin,
String toBchName,
@@ -57,6 +62,7 @@ public class BlockEntry {
this.blockLineNumber = blockLineNumber;
this.blockLinePreHashe = blockLinePreHashe;
this.msgType = msgType;
this.msgSubType = msgSubType;
this.blockByte = blockByte;
this.toLogin = toLogin;
this.toBchName = toBchName;
@@ -88,6 +94,9 @@ public class BlockEntry {
public int getMsgType() { return msgType; }
public void setMsgType(int msgType) { this.msgType = msgType; }
public int getMsgSubType() { return msgSubType; }
public void setMsgSubType(int msgSubType) { this.msgSubType = msgSubType; }
public byte[] getBlockByte() { return blockByte; }
public void setBlockByte(byte[] blockByte) { this.blockByte = blockByte; }