Refactor stupid getResultSetBytes() method & fix migrate

* Replaced occurances of "this.repository.getResultSetBytes(resultSet.getBinaryStream(index))"
with "resultSet.getBytes(index)"

* Replaced corresponding preparedStatement.setBinaryStream() with preparedStatement.setBytes()

* Fixed migrate app so DB can be rebuilt using old v1 Qora client
This commit is contained in:
catbref 2018-06-19 16:49:42 +01:00
parent 5e674cbaab
commit 795da06505
14 changed files with 132 additions and 134 deletions

View File

@ -28,18 +28,10 @@ as previously public key objects could be stored directly in MapDB.
e.g. ```PaymentTransactions.sender```, e.g. ```PaymentTransactions.sender```,
so that all transactions by a specific Qora account can be quickly found without scanning all child tables. so that all transactions by a specific Qora account can be quickly found without scanning all child tables.
- Trying to keep all SQL inside respective Java classes, - SQL is contained within repository classes repository.* (interfaces) and repository.hsqldb.* (implementations).
e.g. operations on ```Blocks``` table only done within ```Block.java```.
- Some MapDB-based objects had Java Map<> obejcts as their values. These will need to be unpicked into separate tables. - We use transfer objects in data.*
### Possible gen2 refactoring already - "Business logic" is left in qora.*
- We might need to change ```Blocks.generator``` from Qora address in VARCHAR to public key in VARBINARY, - Some MapDB-based objects had Java Map<> objects as their values. These will need to be unpacked into separate tables.
then derive address from public key as needed.
- Ditto ```Transactions.creator``` and equivalent columns in child tables.
- Extracting values from a ```ResultSet``` by column index is efficient but prone to mistakes
as the indexes have to be maintained by a human. There might be a better, general solution to this
without having to resort to importing an external ORM library. Maybe simply ```value = resultSet.getInt(columnIndex++)```

View File

@ -5,8 +5,7 @@ To use:
- Use maven to fetch dependencies. - Use maven to fetch dependencies.
- Build project. - Build project.
- Fire up an old-gen Qora node. - Fire up an old-gen Qora node.
- Run ```src/test/update.java``` as a JUnit test to build DB structure. - Run ```src/migrate.java``` as a Java application to migrate old Qora blocks to DB.
- Run ```src/test/migrate.java``` as a JUnit test to migrate old Qora blocks to DB.
You should now be able to run ```src/test/load.java``` and ```src/test/save.java``` You should now be able to run ```src/test/load.java``` and ```src/test/save.java```
as JUnit tests demonstrating loading/saving Transactions from/to database. as JUnit tests demonstrating loading/saving Transactions from/to database.
@ -45,3 +44,5 @@ Another idea is to assign a shell alias in your ```.bashrc``` like:
alias sqltool='rlwrap java -cp ${HSQLDB_JAR}:${SQLTOOL_JAR} org.hsqldb.cmdline.SqlTool --rcFile=${SQLTOOL_RC}' alias sqltool='rlwrap java -cp ${HSQLDB_JAR}:${SQLTOOL_JAR} org.hsqldb.cmdline.SqlTool --rcFile=${SQLTOOL_RC}'
``` ```
So you can simply type: ```sqltool qora``` So you can simply type: ```sqltool qora```
Don't forget to use ```SHUTDOWN;``` before exiting sqltool so that database files are closed cleanly.

View File

@ -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();
} }
} }

View File

@ -23,7 +23,7 @@ public class HSQLDBAccountRepository implements AccountRepository {
if (resultSet == null) if (resultSet == null)
return null; return null;
return new AccountData(address, this.repository.getResultSetBytes(resultSet.getBinaryStream(1))); return new AccountData(address, resultSet.getBytes(1));
} catch (SQLException e) { } catch (SQLException e) {
throw new DataException("Unable to fetch account info from repository", e); throw new DataException("Unable to fetch account info from repository", e);
} }

View File

@ -31,7 +31,7 @@ public class HSQLDBAssetRepository implements AssetRepository {
String description = resultSet.getString(3); String description = resultSet.getString(3);
long quantity = resultSet.getLong(4); long quantity = resultSet.getLong(4);
boolean isDivisible = resultSet.getBoolean(5); boolean isDivisible = resultSet.getBoolean(5);
byte[] reference = this.repository.getResultSetBytes(resultSet.getBinaryStream(6)); byte[] reference = resultSet.getBytes(6);
return new AssetData(assetId, owner, assetName, description, quantity, isDivisible, reference); return new AssetData(assetId, owner, assetName, description, quantity, isDivisible, reference);
} catch (SQLException e) { } catch (SQLException e) {
@ -89,7 +89,7 @@ public class HSQLDBAssetRepository implements AssetRepository {
if (resultSet == null) if (resultSet == null)
return null; return null;
byte[] creatorPublicKey = this.repository.getResultSetBytes(resultSet.getBinaryStream(1)); byte[] creatorPublicKey = resultSet.getBytes(1);
long haveAssetId = resultSet.getLong(2); long haveAssetId = resultSet.getLong(2);
long wantAssetId = resultSet.getLong(3); long wantAssetId = resultSet.getLong(3);
BigDecimal amount = resultSet.getBigDecimal(4); BigDecimal amount = resultSet.getBigDecimal(4);

View File

@ -31,16 +31,16 @@ public class HSQLDBBlockRepository implements BlockRepository {
try { try {
int version = rs.getInt(1); int version = rs.getInt(1);
byte[] reference = this.repository.getResultSetBytes(rs.getBinaryStream(2)); byte[] reference = rs.getBytes(2);
int transactionCount = rs.getInt(3); int transactionCount = rs.getInt(3);
BigDecimal totalFees = rs.getBigDecimal(4); BigDecimal totalFees = rs.getBigDecimal(4);
byte[] transactionsSignature = this.repository.getResultSetBytes(rs.getBinaryStream(5)); byte[] transactionsSignature = rs.getBytes(5);
int height = rs.getInt(6); int height = rs.getInt(6);
long timestamp = rs.getTimestamp(7).getTime(); long timestamp = rs.getTimestamp(7).getTime();
BigDecimal generatingBalance = rs.getBigDecimal(8); BigDecimal generatingBalance = rs.getBigDecimal(8);
byte[] generatorPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(9)); byte[] generatorPublicKey = rs.getBytes(9);
byte[] generatorSignature = this.repository.getResultSetBytes(rs.getBinaryStream(10)); byte[] generatorSignature = rs.getBytes(10);
byte[] atBytes = this.repository.getResultSetBytes(rs.getBinaryStream(11)); byte[] atBytes = rs.getBytes(11);
BigDecimal atFees = rs.getBigDecimal(12); BigDecimal atFees = rs.getBigDecimal(12);
return new BlockData(version, reference, transactionCount, totalFees, transactionsSignature, height, timestamp, generatingBalance, return new BlockData(version, reference, transactionCount, totalFees, transactionsSignature, height, timestamp, generatingBalance,
@ -117,7 +117,7 @@ public class HSQLDBBlockRepository implements BlockRepository {
// NB: do-while loop because .checkedExecute() implicitly calls ResultSet.next() for us // NB: do-while loop because .checkedExecute() implicitly calls ResultSet.next() for us
do { do {
byte[] transactionSignature = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] transactionSignature = rs.getBytes(1);
transactions.add(transactionRepo.fromSignature(transactionSignature)); transactions.add(transactionRepo.fromSignature(transactionSignature));
} while (rs.next()); } while (rs.next());
} catch (SQLException e) { } catch (SQLException e) {

View File

@ -1,7 +1,5 @@
package repository.hsqldb; package repository.hsqldb;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -101,30 +99,6 @@ public class HSQLDBRepository implements Repository {
public void rebuild() throws DataException { public void rebuild() throws DataException {
} }
/**
* Convert InputStream, from ResultSet.getBinaryStream(), into byte[].
*
* @param inputStream
* @return byte[]
*/
public byte[] getResultSetBytes(InputStream inputStream) {
// inputStream could be null if database's column's value is null
if (inputStream == null)
return null;
try {
int length = inputStream.available();
byte[] result = new byte[length];
if (inputStream.read(result) == length)
return result;
} catch (IOException e) {
// Fall-through to return null
}
return null;
}
/** /**
* Execute SQL and return ResultSet with but added checking. * Execute SQL and return ResultSet with but added checking.
* <p> * <p>

View File

@ -22,7 +22,7 @@ public class HSQLDBCancelOrderTransactionRepository extends HSQLDBTransactionRep
if (rs == null) if (rs == null)
return null; return null;
byte[] assetOrderId = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] assetOrderId = rs.getBytes(1);
return new CancelOrderTransactionData(creatorPublicKey, assetOrderId, fee, timestamp, reference, signature); return new CancelOrderTransactionData(creatorPublicKey, assetOrderId, fee, timestamp, reference, signature);
} catch (SQLException e) { } catch (SQLException e) {

View File

@ -24,7 +24,7 @@ public class HSQLDBIssueAssetTransactionRepository extends HSQLDBTransactionRepo
if (rs == null) if (rs == null)
return null; return null;
byte[] issuerPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] issuerPublicKey = rs.getBytes(1);
String owner = rs.getString(2); String owner = rs.getString(2);
String assetName = rs.getString(3); String assetName = rs.getString(3);
String description = rs.getString(4); String description = rs.getString(4);

View File

@ -24,13 +24,13 @@ public class HSQLDBMessageTransactionRepository extends HSQLDBTransactionReposit
return null; return null;
int version = rs.getInt(1); int version = rs.getInt(1);
byte[] senderPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(2)); byte[] senderPublicKey = rs.getBytes(2);
String recipient = rs.getString(3); String recipient = rs.getString(3);
boolean isText = rs.getBoolean(4); boolean isText = rs.getBoolean(4);
boolean isEncrypted = rs.getBoolean(5); boolean isEncrypted = rs.getBoolean(5);
BigDecimal amount = rs.getBigDecimal(6); BigDecimal amount = rs.getBigDecimal(6);
Long assetId = rs.getLong(7); Long assetId = rs.getLong(7);
byte[] data = this.repository.getResultSetBytes(rs.getBinaryStream(8)); byte[] data = rs.getBytes(8);
return new MessageTransactionData(version, senderPublicKey, recipient, assetId, amount, fee, data, isText, isEncrypted, timestamp, reference, return new MessageTransactionData(version, senderPublicKey, recipient, assetId, amount, fee, data, isText, isEncrypted, timestamp, reference,
signature); signature);

View File

@ -24,7 +24,7 @@ public class HSQLDBMultiPaymentTransactionRepository extends HSQLDBTransactionRe
if (rs == null) if (rs == null)
return null; return null;
byte[] senderPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] senderPublicKey = rs.getBytes(1);
List<PaymentData> payments = this.getPaymentsFromSignature(signature); List<PaymentData> payments = this.getPaymentsFromSignature(signature);

View File

@ -22,7 +22,7 @@ public class HSQLDBPaymentTransactionRepository extends HSQLDBTransactionReposit
if (rs == null) if (rs == null)
return null; return null;
byte[] senderPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] senderPublicKey = rs.getBytes(1);
String recipient = rs.getString(2); String recipient = rs.getString(2);
BigDecimal amount = rs.getBigDecimal(3); BigDecimal amount = rs.getBigDecimal(3);

View File

@ -52,8 +52,8 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
return null; return null;
TransactionType type = TransactionType.valueOf(rs.getInt(1)); TransactionType type = TransactionType.valueOf(rs.getInt(1));
byte[] reference = this.repository.getResultSetBytes(rs.getBinaryStream(2)); byte[] reference = rs.getBytes(2);
byte[] creatorPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(3)); byte[] creatorPublicKey = rs.getBytes(3);
long timestamp = rs.getTimestamp(4).getTime(); long timestamp = rs.getTimestamp(4).getTime();
BigDecimal fee = rs.getBigDecimal(5).setScale(8); BigDecimal fee = rs.getBigDecimal(5).setScale(8);
@ -70,8 +70,8 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
return null; return null;
TransactionType type = TransactionType.valueOf(rs.getInt(1)); TransactionType type = TransactionType.valueOf(rs.getInt(1));
byte[] signature = this.repository.getResultSetBytes(rs.getBinaryStream(2)); byte[] signature = rs.getBytes(2);
byte[] creatorPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(3)); byte[] creatorPublicKey = rs.getBytes(3);
long timestamp = rs.getTimestamp(4).getTime(); long timestamp = rs.getTimestamp(4).getTime();
BigDecimal fee = rs.getBigDecimal(5).setScale(8); BigDecimal fee = rs.getBigDecimal(5).setScale(8);
@ -185,7 +185,7 @@ public class HSQLDBTransactionRepository implements TransactionRepository {
if (rs == null) if (rs == null)
return null; return null;
byte[] blockSignature = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] blockSignature = rs.getBytes(1);
return this.repository.getBlockRepository().fromSignature(blockSignature); return this.repository.getBlockRepository().fromSignature(blockSignature);
} catch (SQLException | DataException e) { } catch (SQLException | DataException e) {

View File

@ -23,7 +23,7 @@ public class HSQLDBTransferAssetTransactionRepository extends HSQLDBTransactionR
if (rs == null) if (rs == null)
return null; return null;
byte[] senderPublicKey = this.repository.getResultSetBytes(rs.getBinaryStream(1)); byte[] senderPublicKey = rs.getBytes(1);
String recipient = rs.getString(2); String recipient = rs.getString(2);
long assetId = rs.getLong(3); long assetId = rs.getLong(3);
BigDecimal amount = rs.getBigDecimal(4); BigDecimal amount = rs.getBigDecimal(4);