|
|
@ -1,7 +1,6 @@
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
@ -9,6 +8,7 @@ import java.math.BigDecimal;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
import java.sql.Connection;
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.PreparedStatement;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.sql.Timestamp;
|
|
|
|
import java.sql.Timestamp;
|
|
|
@ -17,6 +17,7 @@ import java.util.Arrays;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
|
|
|
|
|
|
import org.json.simple.JSONArray;
|
|
|
|
import org.json.simple.JSONArray;
|
|
|
|
import org.json.simple.JSONObject;
|
|
|
|
import org.json.simple.JSONObject;
|
|
|
@ -35,6 +36,8 @@ import utils.Base58;
|
|
|
|
|
|
|
|
|
|
|
|
public class migrate {
|
|
|
|
public class migrate {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String connectionUrl = "jdbc:hsqldb:file:db/test;create=true;close_result=true;sql.strict_exec=true;sql.enforce_names=true;sql.syntax_mys=true";
|
|
|
|
|
|
|
|
|
|
|
|
private static final String GENESIS_ADDRESS = "QfGMeDQQUQePMpAmfLBJzgqyrM35RWxHGD";
|
|
|
|
private static final String GENESIS_ADDRESS = "QfGMeDQQUQePMpAmfLBJzgqyrM35RWxHGD";
|
|
|
|
private static final byte[] GENESIS_PUBLICKEY = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1 };
|
|
|
|
private static final byte[] GENESIS_PUBLICKEY = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1 };
|
|
|
|
|
|
|
|
|
|
|
@ -77,6 +80,16 @@ public class migrate {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void savePublicKeys(Connection connection) throws SQLException {
|
|
|
|
|
|
|
|
PreparedStatement pStmt = connection.prepareStatement("INSERT IGNORE INTO Test_public_keys VALUES (?, ?)");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Entry<String, byte[]> entry : publicKeyByAddress.entrySet()) {
|
|
|
|
|
|
|
|
pStmt.setString(1, entry.getKey());
|
|
|
|
|
|
|
|
pStmt.setBytes(2, entry.getValue());
|
|
|
|
|
|
|
|
pStmt.execute();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String formatWithPlaceholders(String... columns) {
|
|
|
|
public static String formatWithPlaceholders(String... columns) {
|
|
|
|
String[] placeholders = new String[columns.length];
|
|
|
|
String[] placeholders = new String[columns.length];
|
|
|
|
Arrays.setAll(placeholders, (int i) -> "?");
|
|
|
|
Arrays.setAll(placeholders, (int i) -> "?");
|
|
|
@ -97,11 +110,13 @@ public class migrate {
|
|
|
|
publicKeyByAddress.put("QcDLhirHkSbR4TLYeShLzHw61B8UGTFusk", Base58.decode("HP58uWRBae654ze6ysmdyGv3qaDrr9BEk6cHv4WuiF7d"));
|
|
|
|
publicKeyByAddress.put("QcDLhirHkSbR4TLYeShLzHw61B8UGTFusk", Base58.decode("HP58uWRBae654ze6ysmdyGv3qaDrr9BEk6cHv4WuiF7d"));
|
|
|
|
|
|
|
|
|
|
|
|
// TODO convert to repository
|
|
|
|
// TODO convert to repository
|
|
|
|
Connection c = null;
|
|
|
|
Connection c = DriverManager.getConnection(connectionUrl);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.createStatement()
|
|
|
|
|
|
|
|
.execute("CREATE TABLE IF NOT EXISTS Test_public_keys ( address varchar(64), public_key varbinary(32) not null, primary key(address) )");
|
|
|
|
|
|
|
|
c.createStatement().execute("CREATE INDEX IF NOT EXISTS Test_public_key_index ON Test_public_keys (public_key)");
|
|
|
|
|
|
|
|
|
|
|
|
test.Common.setRepository();
|
|
|
|
test.Common.setRepository();
|
|
|
|
Repository repository = RepositoryManager.getRepository();
|
|
|
|
|
|
|
|
BlockRepository blockRepository = repository.getBlockRepository();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PreparedStatement blocksPStmt = c
|
|
|
|
PreparedStatement blocksPStmt = c
|
|
|
|
.prepareStatement("INSERT INTO Blocks " + formatWithPlaceholders("signature", "version", "reference", "transaction_count", "total_fees",
|
|
|
|
.prepareStatement("INSERT INTO Blocks " + formatWithPlaceholders("signature", "version", "reference", "transaction_count", "total_fees",
|
|
|
@ -126,7 +141,7 @@ public class migrate {
|
|
|
|
PreparedStatement buyNamePStmt = c
|
|
|
|
PreparedStatement buyNamePStmt = c
|
|
|
|
.prepareStatement("INSERT INTO BuyNameTransactions " + formatWithPlaceholders("signature", "buyer", "name", "seller", "amount"));
|
|
|
|
.prepareStatement("INSERT INTO BuyNameTransactions " + formatWithPlaceholders("signature", "buyer", "name", "seller", "amount"));
|
|
|
|
PreparedStatement createPollPStmt = c
|
|
|
|
PreparedStatement createPollPStmt = c
|
|
|
|
.prepareStatement("INSERT INTO CreatePollTransactions " + formatWithPlaceholders("signature", "creator", "poll", "description"));
|
|
|
|
.prepareStatement("INSERT INTO CreatePollTransactions " + formatWithPlaceholders("signature", "creator", "owner", "poll", "description"));
|
|
|
|
PreparedStatement createPollOptionPStmt = c
|
|
|
|
PreparedStatement createPollOptionPStmt = c
|
|
|
|
.prepareStatement("INSERT INTO CreatePollTransactionOptions " + formatWithPlaceholders("signature", "option"));
|
|
|
|
.prepareStatement("INSERT INTO CreatePollTransactionOptions " + formatWithPlaceholders("signature", "option"));
|
|
|
|
PreparedStatement voteOnPollPStmt = c
|
|
|
|
PreparedStatement voteOnPollPStmt = c
|
|
|
@ -140,7 +155,7 @@ public class migrate {
|
|
|
|
PreparedStatement createAssetOrderPStmt = c.prepareStatement("INSERT INTO CreateAssetOrderTransactions "
|
|
|
|
PreparedStatement createAssetOrderPStmt = c.prepareStatement("INSERT INTO CreateAssetOrderTransactions "
|
|
|
|
+ formatWithPlaceholders("signature", "creator", "have_asset_id", "amount", "want_asset_id", "price"));
|
|
|
|
+ formatWithPlaceholders("signature", "creator", "have_asset_id", "amount", "want_asset_id", "price"));
|
|
|
|
PreparedStatement cancelAssetOrderPStmt = c
|
|
|
|
PreparedStatement cancelAssetOrderPStmt = c
|
|
|
|
.prepareStatement("INSERT INTO CancelAssetOrderTransactions " + formatWithPlaceholders("signature", "creator", "asset_order"));
|
|
|
|
.prepareStatement("INSERT INTO CancelAssetOrderTransactions " + formatWithPlaceholders("signature", "creator", "asset_order_id"));
|
|
|
|
PreparedStatement multiPaymentPStmt = c.prepareStatement("INSERT INTO MultiPaymentTransactions " + formatWithPlaceholders("signature", "sender"));
|
|
|
|
PreparedStatement multiPaymentPStmt = c.prepareStatement("INSERT INTO MultiPaymentTransactions " + formatWithPlaceholders("signature", "sender"));
|
|
|
|
PreparedStatement deployATPStmt = c.prepareStatement("INSERT INTO DeployATTransactions "
|
|
|
|
PreparedStatement deployATPStmt = c.prepareStatement("INSERT INTO DeployATTransactions "
|
|
|
|
+ formatWithPlaceholders("signature", "creator", "AT_name", "description", "AT_type", "AT_tags", "creation_bytes", "amount"));
|
|
|
|
+ formatWithPlaceholders("signature", "creator", "AT_name", "description", "AT_type", "AT_tags", "creation_bytes", "amount"));
|
|
|
@ -153,7 +168,12 @@ public class migrate {
|
|
|
|
PreparedStatement blockTxPStmt = c
|
|
|
|
PreparedStatement blockTxPStmt = c
|
|
|
|
.prepareStatement("INSERT INTO BlockTransactions " + formatWithPlaceholders("block_signature", "sequence", "transaction_signature"));
|
|
|
|
.prepareStatement("INSERT INTO BlockTransactions " + formatWithPlaceholders("block_signature", "sequence", "transaction_signature"));
|
|
|
|
|
|
|
|
|
|
|
|
int height = blockRepository.getBlockchainHeight() + 1;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
|
|
|
|
|
|
|
BlockRepository blockRepository = repository.getBlockRepository();
|
|
|
|
|
|
|
|
height = blockRepository.getBlockchainHeight() + 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte[] milestone_block = null;
|
|
|
|
byte[] milestone_block = null;
|
|
|
|
System.out.println("Starting migration from block height " + height);
|
|
|
|
System.out.println("Starting migration from block height " + height);
|
|
|
|
|
|
|
|
|
|
|
@ -178,23 +198,23 @@ public class migrate {
|
|
|
|
|
|
|
|
|
|
|
|
byte[] generatorPublicKey = addressToPublicKey((String) json.get("generator"));
|
|
|
|
byte[] generatorPublicKey = addressToPublicKey((String) json.get("generator"));
|
|
|
|
|
|
|
|
|
|
|
|
blocksPStmt.setBinaryStream(1, new ByteArrayInputStream(blockSignature));
|
|
|
|
blocksPStmt.setBytes(1, blockSignature);
|
|
|
|
blocksPStmt.setInt(2, ((Long) json.get("version")).intValue());
|
|
|
|
blocksPStmt.setInt(2, ((Long) json.get("version")).intValue());
|
|
|
|
blocksPStmt.setBinaryStream(3, new ByteArrayInputStream(blockReference));
|
|
|
|
blocksPStmt.setBytes(3, blockReference);
|
|
|
|
blocksPStmt.setInt(4, transactions.size());
|
|
|
|
blocksPStmt.setInt(4, transactions.size());
|
|
|
|
blocksPStmt.setBigDecimal(5, BigDecimal.valueOf(Double.valueOf((String) json.get("fee")).doubleValue()));
|
|
|
|
blocksPStmt.setBigDecimal(5, BigDecimal.valueOf(Double.valueOf((String) json.get("fee")).doubleValue()));
|
|
|
|
blocksPStmt.setBinaryStream(6, new ByteArrayInputStream(blockTransactionsSignature));
|
|
|
|
blocksPStmt.setBytes(6, blockTransactionsSignature);
|
|
|
|
blocksPStmt.setInt(7, height);
|
|
|
|
blocksPStmt.setInt(7, height);
|
|
|
|
blocksPStmt.setTimestamp(8, new Timestamp((Long) json.get("timestamp")));
|
|
|
|
blocksPStmt.setTimestamp(8, new Timestamp((Long) json.get("timestamp")));
|
|
|
|
blocksPStmt.setBigDecimal(9, BigDecimal.valueOf((Long) json.get("generatingBalance")));
|
|
|
|
blocksPStmt.setBigDecimal(9, BigDecimal.valueOf((Long) json.get("generatingBalance")));
|
|
|
|
blocksPStmt.setBinaryStream(10, new ByteArrayInputStream(generatorPublicKey));
|
|
|
|
blocksPStmt.setBytes(10, generatorPublicKey);
|
|
|
|
blocksPStmt.setBinaryStream(11, new ByteArrayInputStream(blockGeneratorSignature));
|
|
|
|
blocksPStmt.setBytes(11, blockGeneratorSignature);
|
|
|
|
|
|
|
|
|
|
|
|
String blockATs = (String) json.get("blockATs");
|
|
|
|
String blockATs = (String) json.get("blockATs");
|
|
|
|
if (blockATs != null && blockATs.length() > 0) {
|
|
|
|
if (blockATs != null && blockATs.length() > 0) {
|
|
|
|
HashCode atBytes = HashCode.fromString(blockATs);
|
|
|
|
HashCode atBytes = HashCode.fromString(blockATs);
|
|
|
|
|
|
|
|
|
|
|
|
blocksPStmt.setBinaryStream(12, new ByteArrayInputStream(atBytes.asBytes()));
|
|
|
|
blocksPStmt.setBytes(12, atBytes.asBytes());
|
|
|
|
blocksPStmt.setBigDecimal(13, BigDecimal.valueOf(((Long) json.get("atFees")).longValue(), 8));
|
|
|
|
blocksPStmt.setBigDecimal(13, BigDecimal.valueOf(((Long) json.get("atFees")).longValue(), 8));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
blocksPStmt.setNull(12, java.sql.Types.VARBINARY);
|
|
|
|
blocksPStmt.setNull(12, java.sql.Types.VARBINARY);
|
|
|
@ -211,14 +231,14 @@ public class migrate {
|
|
|
|
JSONObject transaction = (JSONObject) transactions.get(txIndex);
|
|
|
|
JSONObject transaction = (JSONObject) transactions.get(txIndex);
|
|
|
|
|
|
|
|
|
|
|
|
byte[] txSignature = Base58.decode((String) transaction.get("signature"));
|
|
|
|
byte[] txSignature = Base58.decode((String) transaction.get("signature"));
|
|
|
|
txPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
txPStmt.setBytes(1, txSignature);
|
|
|
|
|
|
|
|
|
|
|
|
String txReference58 = (String) transaction.get("reference");
|
|
|
|
String txReference58 = (String) transaction.get("reference");
|
|
|
|
byte[] txReference = txReference58.isEmpty() ? null : Base58.decode(txReference58);
|
|
|
|
byte[] txReference = txReference58.isEmpty() ? null : Base58.decode(txReference58);
|
|
|
|
int type = ((Long) transaction.get("type")).intValue();
|
|
|
|
int type = ((Long) transaction.get("type")).intValue();
|
|
|
|
|
|
|
|
|
|
|
|
if (txReference != null)
|
|
|
|
if (txReference != null)
|
|
|
|
txPStmt.setBinaryStream(2, new ByteArrayInputStream(txReference));
|
|
|
|
txPStmt.setBytes(2, txReference);
|
|
|
|
else if (height == 1 && type == 1)
|
|
|
|
else if (height == 1 && type == 1)
|
|
|
|
txPStmt.setNull(2, java.sql.Types.VARBINARY); // genesis transactions only
|
|
|
|
txPStmt.setNull(2, java.sql.Types.VARBINARY); // genesis transactions only
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -229,27 +249,27 @@ public class migrate {
|
|
|
|
// Determine transaction "creator" from specific transaction info
|
|
|
|
// Determine transaction "creator" from specific transaction info
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case 1: // genesis
|
|
|
|
case 1: // genesis
|
|
|
|
txPStmt.setBinaryStream(4, new ByteArrayInputStream(GENESIS_PUBLICKEY)); // genesis transactions only
|
|
|
|
txPStmt.setBytes(4, GENESIS_PUBLICKEY); // genesis transactions only
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 2: // payment
|
|
|
|
case 2: // payment
|
|
|
|
case 12: // transfer asset
|
|
|
|
case 12: // transfer asset
|
|
|
|
case 15: // multi-payment
|
|
|
|
case 15: // multi-payment
|
|
|
|
txPStmt.setBinaryStream(4, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("sender"))));
|
|
|
|
txPStmt.setBytes(4, addressToPublicKey((String) transaction.get("sender")));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 3: // register name
|
|
|
|
case 3: // register name
|
|
|
|
txPStmt.setBinaryStream(4, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("registrant"))));
|
|
|
|
txPStmt.setBytes(4, addressToPublicKey((String) transaction.get("registrant")));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 4: // update name
|
|
|
|
case 4: // update name
|
|
|
|
case 5: // sell name
|
|
|
|
case 5: // sell name
|
|
|
|
case 6: // cancel sell name
|
|
|
|
case 6: // cancel sell name
|
|
|
|
txPStmt.setBinaryStream(4, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("owner"))));
|
|
|
|
txPStmt.setBytes(4, addressToPublicKey((String) transaction.get("owner")));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 7: // buy name
|
|
|
|
case 7: // buy name
|
|
|
|
txPStmt.setBinaryStream(4, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("buyer"))));
|
|
|
|
txPStmt.setBytes(4, addressToPublicKey((String) transaction.get("buyer")));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 8: // create poll
|
|
|
|
case 8: // create poll
|
|
|
@ -260,7 +280,7 @@ public class migrate {
|
|
|
|
case 14: // cancel asset order
|
|
|
|
case 14: // cancel asset order
|
|
|
|
case 16: // deploy CIYAM AT
|
|
|
|
case 16: // deploy CIYAM AT
|
|
|
|
case 17: // message
|
|
|
|
case 17: // message
|
|
|
|
txPStmt.setBinaryStream(4, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
txPStmt.setBytes(4, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
@ -272,7 +292,7 @@ public class migrate {
|
|
|
|
txPStmt.setBigDecimal(6, BigDecimal.valueOf(Double.valueOf((String) transaction.get("fee")).doubleValue()));
|
|
|
|
txPStmt.setBigDecimal(6, BigDecimal.valueOf(Double.valueOf((String) transaction.get("fee")).doubleValue()));
|
|
|
|
|
|
|
|
|
|
|
|
if (milestone_block != null)
|
|
|
|
if (milestone_block != null)
|
|
|
|
txPStmt.setBinaryStream(7, new ByteArrayInputStream(milestone_block));
|
|
|
|
txPStmt.setBytes(7, milestone_block);
|
|
|
|
else if (height == 1 && type == 1)
|
|
|
|
else if (height == 1 && type == 1)
|
|
|
|
txPStmt.setNull(7, java.sql.Types.VARBINARY); // genesis transactions only
|
|
|
|
txPStmt.setNull(7, java.sql.Types.VARBINARY); // genesis transactions only
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -331,7 +351,7 @@ public class migrate {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (String recipient : recipients) {
|
|
|
|
for (String recipient : recipients) {
|
|
|
|
recipientPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
recipientPStmt.setBytes(1, txSignature);
|
|
|
|
recipientPStmt.setString(2, recipient);
|
|
|
|
recipientPStmt.setString(2, recipient);
|
|
|
|
|
|
|
|
|
|
|
|
recipientPStmt.execute();
|
|
|
|
recipientPStmt.execute();
|
|
|
@ -341,7 +361,7 @@ public class migrate {
|
|
|
|
// Transaction-type-specific processing
|
|
|
|
// Transaction-type-specific processing
|
|
|
|
switch (type) {
|
|
|
|
switch (type) {
|
|
|
|
case 1: // genesis
|
|
|
|
case 1: // genesis
|
|
|
|
genesisPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
genesisPStmt.setBytes(1, txSignature);
|
|
|
|
genesisPStmt.setString(2, recipients.get(0));
|
|
|
|
genesisPStmt.setString(2, recipients.get(0));
|
|
|
|
genesisPStmt.setBigDecimal(3, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
genesisPStmt.setBigDecimal(3, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
|
|
|
|
|
|
|
@ -350,8 +370,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 2: // payment
|
|
|
|
case 2: // payment
|
|
|
|
paymentPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
paymentPStmt.setBytes(1, txSignature);
|
|
|
|
paymentPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("sender"))));
|
|
|
|
paymentPStmt.setBytes(2, addressToPublicKey((String) transaction.get("sender")));
|
|
|
|
paymentPStmt.setString(3, recipients.get(0));
|
|
|
|
paymentPStmt.setString(3, recipients.get(0));
|
|
|
|
paymentPStmt.setBigDecimal(4, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
paymentPStmt.setBigDecimal(4, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
|
|
|
|
|
|
|
@ -360,8 +380,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 3: // register name
|
|
|
|
case 3: // register name
|
|
|
|
registerNamePStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
registerNamePStmt.setBytes(1, txSignature);
|
|
|
|
registerNamePStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("registrant"))));
|
|
|
|
registerNamePStmt.setBytes(2, addressToPublicKey((String) transaction.get("registrant")));
|
|
|
|
registerNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
registerNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
registerNamePStmt.setString(4, (String) transaction.get("owner"));
|
|
|
|
registerNamePStmt.setString(4, (String) transaction.get("owner"));
|
|
|
|
registerNamePStmt.setString(5, (String) transaction.get("value"));
|
|
|
|
registerNamePStmt.setString(5, (String) transaction.get("value"));
|
|
|
@ -371,8 +391,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 4: // update name
|
|
|
|
case 4: // update name
|
|
|
|
updateNamePStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
updateNamePStmt.setBytes(1, txSignature);
|
|
|
|
updateNamePStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("owner"))));
|
|
|
|
updateNamePStmt.setBytes(2, addressToPublicKey((String) transaction.get("owner")));
|
|
|
|
updateNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
updateNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
updateNamePStmt.setString(4, (String) transaction.get("newOwner"));
|
|
|
|
updateNamePStmt.setString(4, (String) transaction.get("newOwner"));
|
|
|
|
updateNamePStmt.setString(5, (String) transaction.get("newValue"));
|
|
|
|
updateNamePStmt.setString(5, (String) transaction.get("newValue"));
|
|
|
@ -382,8 +402,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 5: // sell name
|
|
|
|
case 5: // sell name
|
|
|
|
sellNamePStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
sellNamePStmt.setBytes(1, txSignature);
|
|
|
|
sellNamePStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("owner"))));
|
|
|
|
sellNamePStmt.setBytes(2, addressToPublicKey((String) transaction.get("owner")));
|
|
|
|
sellNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
sellNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
sellNamePStmt.setBigDecimal(4, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
sellNamePStmt.setBigDecimal(4, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
|
|
|
|
|
|
|
@ -392,8 +412,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 6: // cancel sell name
|
|
|
|
case 6: // cancel sell name
|
|
|
|
cancelSellNamePStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
cancelSellNamePStmt.setBytes(1, txSignature);
|
|
|
|
cancelSellNamePStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("owner"))));
|
|
|
|
cancelSellNamePStmt.setBytes(2, addressToPublicKey((String) transaction.get("owner")));
|
|
|
|
cancelSellNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
cancelSellNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
|
|
|
|
|
|
|
|
cancelSellNamePStmt.execute();
|
|
|
|
cancelSellNamePStmt.execute();
|
|
|
@ -401,8 +421,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 7: // buy name
|
|
|
|
case 7: // buy name
|
|
|
|
buyNamePStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
buyNamePStmt.setBytes(1, txSignature);
|
|
|
|
buyNamePStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("buyer"))));
|
|
|
|
buyNamePStmt.setBytes(2, addressToPublicKey((String) transaction.get("buyer")));
|
|
|
|
buyNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
buyNamePStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
buyNamePStmt.setString(4, (String) transaction.get("seller"));
|
|
|
|
buyNamePStmt.setString(4, (String) transaction.get("seller"));
|
|
|
|
buyNamePStmt.setBigDecimal(5, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
buyNamePStmt.setBigDecimal(5, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
@ -412,10 +432,12 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 8: // create poll
|
|
|
|
case 8: // create poll
|
|
|
|
createPollPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
createPollPStmt.setBytes(1, txSignature);
|
|
|
|
createPollPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
createPollPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
createPollPStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
// In gen1, there are no polls where the owner is not the creator
|
|
|
|
createPollPStmt.setString(4, (String) transaction.get("description"));
|
|
|
|
createPollPStmt.setString(3, (String) transaction.get("creator")); // owner
|
|
|
|
|
|
|
|
createPollPStmt.setString(4, (String) transaction.get("name"));
|
|
|
|
|
|
|
|
createPollPStmt.setString(5, (String) transaction.get("description"));
|
|
|
|
|
|
|
|
|
|
|
|
createPollPStmt.execute();
|
|
|
|
createPollPStmt.execute();
|
|
|
|
createPollPStmt.clearParameters();
|
|
|
|
createPollPStmt.clearParameters();
|
|
|
@ -423,7 +445,7 @@ public class migrate {
|
|
|
|
// options
|
|
|
|
// options
|
|
|
|
JSONArray options = (JSONArray) transaction.get("options");
|
|
|
|
JSONArray options = (JSONArray) transaction.get("options");
|
|
|
|
for (Object option : options) {
|
|
|
|
for (Object option : options) {
|
|
|
|
createPollOptionPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
createPollOptionPStmt.setBytes(1, txSignature);
|
|
|
|
createPollOptionPStmt.setString(2, (String) option);
|
|
|
|
createPollOptionPStmt.setString(2, (String) option);
|
|
|
|
|
|
|
|
|
|
|
|
createPollOptionPStmt.execute();
|
|
|
|
createPollOptionPStmt.execute();
|
|
|
@ -432,8 +454,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 9: // vote on poll
|
|
|
|
case 9: // vote on poll
|
|
|
|
voteOnPollPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
voteOnPollPStmt.setBytes(1, txSignature);
|
|
|
|
voteOnPollPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
voteOnPollPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
voteOnPollPStmt.setString(3, (String) transaction.get("poll"));
|
|
|
|
voteOnPollPStmt.setString(3, (String) transaction.get("poll"));
|
|
|
|
voteOnPollPStmt.setInt(4, ((Long) transaction.get("option")).intValue());
|
|
|
|
voteOnPollPStmt.setInt(4, ((Long) transaction.get("option")).intValue());
|
|
|
|
|
|
|
|
|
|
|
@ -442,8 +464,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 10: // arbitrary transactions
|
|
|
|
case 10: // arbitrary transactions
|
|
|
|
arbitraryPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
arbitraryPStmt.setBytes(1, txSignature);
|
|
|
|
arbitraryPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
arbitraryPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
arbitraryPStmt.setInt(3, ((Long) transaction.get("service")).intValue());
|
|
|
|
arbitraryPStmt.setInt(3, ((Long) transaction.get("service")).intValue());
|
|
|
|
arbitraryPStmt.setString(4, "TODO");
|
|
|
|
arbitraryPStmt.setString(4, "TODO");
|
|
|
|
|
|
|
|
|
|
|
@ -454,7 +476,7 @@ public class migrate {
|
|
|
|
for (Object paymentObj : multiPayments) {
|
|
|
|
for (Object paymentObj : multiPayments) {
|
|
|
|
JSONObject payment = (JSONObject) paymentObj;
|
|
|
|
JSONObject payment = (JSONObject) paymentObj;
|
|
|
|
|
|
|
|
|
|
|
|
sharedPaymentPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
sharedPaymentPStmt.setBytes(1, txSignature);
|
|
|
|
sharedPaymentPStmt.setString(2, (String) payment.get("recipient"));
|
|
|
|
sharedPaymentPStmt.setString(2, (String) payment.get("recipient"));
|
|
|
|
sharedPaymentPStmt.setBigDecimal(3, BigDecimal.valueOf(Double.valueOf((String) payment.get("amount")).doubleValue()));
|
|
|
|
sharedPaymentPStmt.setBigDecimal(3, BigDecimal.valueOf(Double.valueOf((String) payment.get("amount")).doubleValue()));
|
|
|
|
sharedPaymentPStmt.setLong(4, ((Long) payment.get("asset")).longValue());
|
|
|
|
sharedPaymentPStmt.setLong(4, ((Long) payment.get("asset")).longValue());
|
|
|
@ -465,9 +487,10 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 11: // issue asset
|
|
|
|
case 11: // issue asset
|
|
|
|
issueAssetPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
issueAssetPStmt.setBytes(1, txSignature);
|
|
|
|
issueAssetPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
issueAssetPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
issueAssetPStmt.setString(3, (String) transaction.get("owner"));
|
|
|
|
// In gen1, there are no polls where the owner is not the creator
|
|
|
|
|
|
|
|
issueAssetPStmt.setString(3, (String) transaction.get("creator")); // owner
|
|
|
|
issueAssetPStmt.setString(4, (String) transaction.get("name"));
|
|
|
|
issueAssetPStmt.setString(4, (String) transaction.get("name"));
|
|
|
|
issueAssetPStmt.setString(5, (String) transaction.get("description"));
|
|
|
|
issueAssetPStmt.setString(5, (String) transaction.get("description"));
|
|
|
|
issueAssetPStmt.setBigDecimal(6, BigDecimal.valueOf(((Long) transaction.get("quantity")).longValue()));
|
|
|
|
issueAssetPStmt.setBigDecimal(6, BigDecimal.valueOf(((Long) transaction.get("quantity")).longValue()));
|
|
|
@ -478,8 +501,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 12: // transfer asset
|
|
|
|
case 12: // transfer asset
|
|
|
|
transferAssetPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
transferAssetPStmt.setBytes(1, txSignature);
|
|
|
|
transferAssetPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("sender"))));
|
|
|
|
transferAssetPStmt.setBytes(2, addressToPublicKey((String) transaction.get("sender")));
|
|
|
|
transferAssetPStmt.setString(3, (String) transaction.get("recipient"));
|
|
|
|
transferAssetPStmt.setString(3, (String) transaction.get("recipient"));
|
|
|
|
transferAssetPStmt.setLong(4, ((Long) transaction.get("asset")).longValue());
|
|
|
|
transferAssetPStmt.setLong(4, ((Long) transaction.get("asset")).longValue());
|
|
|
|
transferAssetPStmt.setBigDecimal(5, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
transferAssetPStmt.setBigDecimal(5, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
@ -489,8 +512,8 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 13: // create asset order
|
|
|
|
case 13: // create asset order
|
|
|
|
createAssetOrderPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
createAssetOrderPStmt.setBytes(1, txSignature);
|
|
|
|
createAssetOrderPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
createAssetOrderPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject assetOrder = (JSONObject) transaction.get("order");
|
|
|
|
JSONObject assetOrder = (JSONObject) transaction.get("order");
|
|
|
|
createAssetOrderPStmt.setLong(3, ((Long) assetOrder.get("have")).longValue());
|
|
|
|
createAssetOrderPStmt.setLong(3, ((Long) assetOrder.get("have")).longValue());
|
|
|
@ -503,17 +526,17 @@ public class migrate {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 14: // cancel asset order
|
|
|
|
case 14: // cancel asset order
|
|
|
|
cancelAssetOrderPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
cancelAssetOrderPStmt.setBytes(1, txSignature);
|
|
|
|
cancelAssetOrderPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
cancelAssetOrderPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
cancelAssetOrderPStmt.setString(3, (String) transaction.get("order"));
|
|
|
|
cancelAssetOrderPStmt.setBytes(3, Base58.decode((String) transaction.get("order")));
|
|
|
|
|
|
|
|
|
|
|
|
cancelAssetOrderPStmt.execute();
|
|
|
|
cancelAssetOrderPStmt.execute();
|
|
|
|
cancelAssetOrderPStmt.clearParameters();
|
|
|
|
cancelAssetOrderPStmt.clearParameters();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case 15: // multi-payment
|
|
|
|
case 15: // multi-payment
|
|
|
|
multiPaymentPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
multiPaymentPStmt.setBytes(1, txSignature);
|
|
|
|
multiPaymentPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("sender"))));
|
|
|
|
multiPaymentPStmt.setBytes(2, addressToPublicKey((String) transaction.get("sender")));
|
|
|
|
|
|
|
|
|
|
|
|
multiPaymentPStmt.execute();
|
|
|
|
multiPaymentPStmt.execute();
|
|
|
|
multiPaymentPStmt.clearParameters();
|
|
|
|
multiPaymentPStmt.clearParameters();
|
|
|
@ -521,7 +544,7 @@ public class migrate {
|
|
|
|
for (Object paymentObj : multiPayments) {
|
|
|
|
for (Object paymentObj : multiPayments) {
|
|
|
|
JSONObject payment = (JSONObject) paymentObj;
|
|
|
|
JSONObject payment = (JSONObject) paymentObj;
|
|
|
|
|
|
|
|
|
|
|
|
sharedPaymentPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
sharedPaymentPStmt.setBytes(1, txSignature);
|
|
|
|
sharedPaymentPStmt.setString(2, (String) payment.get("recipient"));
|
|
|
|
sharedPaymentPStmt.setString(2, (String) payment.get("recipient"));
|
|
|
|
sharedPaymentPStmt.setBigDecimal(3, BigDecimal.valueOf(Double.valueOf((String) payment.get("amount")).doubleValue()));
|
|
|
|
sharedPaymentPStmt.setBigDecimal(3, BigDecimal.valueOf(Double.valueOf((String) payment.get("amount")).doubleValue()));
|
|
|
|
sharedPaymentPStmt.setLong(4, ((Long) payment.get("asset")).longValue());
|
|
|
|
sharedPaymentPStmt.setLong(4, ((Long) payment.get("asset")).longValue());
|
|
|
@ -533,15 +556,14 @@ public class migrate {
|
|
|
|
|
|
|
|
|
|
|
|
case 16: // deploy AT
|
|
|
|
case 16: // deploy AT
|
|
|
|
HashCode creationBytes = HashCode.fromString((String) transaction.get("creationBytes"));
|
|
|
|
HashCode creationBytes = HashCode.fromString((String) transaction.get("creationBytes"));
|
|
|
|
InputStream creationBytesStream = new ByteArrayInputStream(creationBytes.asBytes());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
deployATPStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
deployATPStmt.setBytes(1, txSignature);
|
|
|
|
deployATPStmt.setBinaryStream(2, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
deployATPStmt.setBytes(2, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
deployATPStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
deployATPStmt.setString(3, (String) transaction.get("name"));
|
|
|
|
deployATPStmt.setString(4, (String) transaction.get("description"));
|
|
|
|
deployATPStmt.setString(4, (String) transaction.get("description"));
|
|
|
|
deployATPStmt.setString(5, (String) transaction.get("atType"));
|
|
|
|
deployATPStmt.setString(5, (String) transaction.get("atType"));
|
|
|
|
deployATPStmt.setString(6, (String) transaction.get("tags"));
|
|
|
|
deployATPStmt.setString(6, (String) transaction.get("tags"));
|
|
|
|
deployATPStmt.setBinaryStream(7, creationBytesStream);
|
|
|
|
deployATPStmt.setBytes(7, creationBytes.asBytes());
|
|
|
|
deployATPStmt.setBigDecimal(8, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
deployATPStmt.setBigDecimal(8, BigDecimal.valueOf(Double.valueOf((String) transaction.get("amount")).doubleValue()));
|
|
|
|
|
|
|
|
|
|
|
|
deployATPStmt.execute();
|
|
|
|
deployATPStmt.execute();
|
|
|
@ -553,17 +575,17 @@ public class migrate {
|
|
|
|
boolean isEncrypted = (Boolean) transaction.get("encrypted");
|
|
|
|
boolean isEncrypted = (Boolean) transaction.get("encrypted");
|
|
|
|
String messageData = (String) transaction.get("data");
|
|
|
|
String messageData = (String) transaction.get("data");
|
|
|
|
|
|
|
|
|
|
|
|
InputStream messageDataStream;
|
|
|
|
byte[] messageDataBytes;
|
|
|
|
if (isText && !isEncrypted) {
|
|
|
|
if (isText && !isEncrypted) {
|
|
|
|
messageDataStream = new ByteArrayInputStream(messageData.getBytes("UTF-8"));
|
|
|
|
messageDataBytes = messageData.getBytes("UTF-8");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
HashCode messageBytes = HashCode.fromString(messageData);
|
|
|
|
HashCode messageBytes = HashCode.fromString(messageData);
|
|
|
|
messageDataStream = new ByteArrayInputStream(messageBytes.asBytes());
|
|
|
|
messageDataBytes = messageBytes.asBytes();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
messagePStmt.setBinaryStream(1, new ByteArrayInputStream(txSignature));
|
|
|
|
messagePStmt.setBytes(1, txSignature);
|
|
|
|
messagePStmt.setInt(2, Transaction.getVersionByTimestamp(transactionTimestamp));
|
|
|
|
messagePStmt.setInt(2, Transaction.getVersionByTimestamp(transactionTimestamp));
|
|
|
|
messagePStmt.setBinaryStream(3, new ByteArrayInputStream(addressToPublicKey((String) transaction.get("creator"))));
|
|
|
|
messagePStmt.setBytes(3, addressToPublicKey((String) transaction.get("creator")));
|
|
|
|
messagePStmt.setString(4, (String) transaction.get("recipient"));
|
|
|
|
messagePStmt.setString(4, (String) transaction.get("recipient"));
|
|
|
|
messagePStmt.setBoolean(5, isText);
|
|
|
|
messagePStmt.setBoolean(5, isText);
|
|
|
|
messagePStmt.setBoolean(6, isEncrypted);
|
|
|
|
messagePStmt.setBoolean(6, isEncrypted);
|
|
|
@ -574,7 +596,7 @@ public class migrate {
|
|
|
|
else
|
|
|
|
else
|
|
|
|
messagePStmt.setLong(8, 0L); // QORA simulated asset
|
|
|
|
messagePStmt.setLong(8, 0L); // QORA simulated asset
|
|
|
|
|
|
|
|
|
|
|
|
messagePStmt.setBinaryStream(9, messageDataStream);
|
|
|
|
messagePStmt.setBytes(9, messageDataBytes);
|
|
|
|
|
|
|
|
|
|
|
|
messagePStmt.execute();
|
|
|
|
messagePStmt.execute();
|
|
|
|
messagePStmt.clearParameters();
|
|
|
|
messagePStmt.clearParameters();
|
|
|
@ -584,14 +606,14 @@ public class migrate {
|
|
|
|
// fail();
|
|
|
|
// fail();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
blockTxPStmt.setBinaryStream(1, new ByteArrayInputStream(blockSignature));
|
|
|
|
blockTxPStmt.setBytes(1, blockSignature);
|
|
|
|
blockTxPStmt.setInt(2, txIndex);
|
|
|
|
blockTxPStmt.setInt(2, txIndex);
|
|
|
|
blockTxPStmt.setBinaryStream(3, new ByteArrayInputStream(txSignature));
|
|
|
|
blockTxPStmt.setBytes(3, txSignature);
|
|
|
|
|
|
|
|
|
|
|
|
blockTxPStmt.execute();
|
|
|
|
blockTxPStmt.execute();
|
|
|
|
blockTxPStmt.clearParameters();
|
|
|
|
blockTxPStmt.clearParameters();
|
|
|
|
|
|
|
|
|
|
|
|
repository.saveChanges();
|
|
|
|
// repository.saveChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// new milestone block every 500 blocks?
|
|
|
|
// new milestone block every 500 blocks?
|
|
|
@ -601,7 +623,16 @@ public class migrate {
|
|
|
|
++height;
|
|
|
|
++height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("Migration finished with new blockchain height " + blockRepository.getBlockchainHeight());
|
|
|
|
savePublicKeys(c);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
c.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
|
|
|
|
|
|
|
BlockRepository blockRepository = repository.getBlockRepository();
|
|
|
|
|
|
|
|
System.out.println("Migration finished with new blockchain height " + blockRepository.getBlockchainHeight());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
RepositoryManager.closeRepositoryFactory();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|