Some fixes for the new Kotlin based version of Jabit.
This commit is contained in:
parent
1a52af880d
commit
e362cb1251
@ -27,11 +27,9 @@ import ch.dissem.bitmessage.extensions.pow.ProofOfWorkRequest;
|
||||
import ch.dissem.bitmessage.ports.CustomCommandHandler;
|
||||
import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
|
||||
import ch.dissem.bitmessage.server.repository.ServerProofOfWorkRepository;
|
||||
import ch.dissem.bitmessage.utils.UnixTime;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
@ -81,7 +79,6 @@ public class ProofOfWorkRequestHandler implements CustomCommandHandler, Internal
|
||||
|
||||
@Override
|
||||
public MessagePayload handle(CustomMessage message) {
|
||||
try {
|
||||
CryptoCustomMessage<ProofOfWorkRequest> cryptoMessage = CryptoCustomMessage.read(message,
|
||||
ProofOfWorkRequest::read);
|
||||
ProofOfWorkRequest request = decrypt(cryptoMessage);
|
||||
@ -118,9 +115,6 @@ public class ProofOfWorkRequestHandler implements CustomCommandHandler, Internal
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return CustomMessage.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private BitmessageAddress getIdentity() {
|
||||
@ -148,8 +142,6 @@ public class ProofOfWorkRequestHandler implements CustomCommandHandler, Internal
|
||||
try {
|
||||
return cryptoMessage.decrypt(key);
|
||||
} catch (DecryptionFailedException ignore) {
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -25,7 +25,10 @@ import com.google.zxing.qrcode.encoder.QRCode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Scanner;
|
||||
import java.util.Set;
|
||||
@ -91,17 +94,13 @@ public class Utils {
|
||||
if (address.getAlias() != null) {
|
||||
link.append("?label=").append(address.getAlias());
|
||||
}
|
||||
if (address.getPubkey() != null) {
|
||||
link.append(address.getAlias() == null ? '?' : '&');
|
||||
ByteArrayOutputStream pubkey = new ByteArrayOutputStream();
|
||||
try {
|
||||
address.getPubkey().writeUnencrypted(pubkey);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// This makes the QR code quite big, so it's not active. But sometimes it might be useful:
|
||||
// link.append("pubkey=").append(Base64.getUrlEncoder().encodeToString(pubkey.toByteArray()));
|
||||
}
|
||||
// if (address.getPubkey() != null) {
|
||||
// link.append(address.getAlias() == null ? '?' : '&');
|
||||
// ByteArrayOutputStream pubkey = new ByteArrayOutputStream();
|
||||
// address.getPubkey().writeUnencrypted(pubkey);
|
||||
// link.append("pubkey=").append(Base64.getUrlEncoder().encodeToString(pubkey.toByteArray()));
|
||||
// }
|
||||
QRCode code;
|
||||
try {
|
||||
code = Encoder.encode(link.toString(), ErrorCorrectionLevel.L, null);
|
||||
@ -111,8 +110,8 @@ public class Utils {
|
||||
}
|
||||
ByteMatrix matrix = code.getMatrix();
|
||||
StringBuilder result = new StringBuilder();
|
||||
for (int i=0; i<2; i++){
|
||||
for (int j=0;j<matrix.getWidth()+8; j++){
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < matrix.getWidth() + 8; j++) {
|
||||
result.append('█');
|
||||
}
|
||||
result.append('\n');
|
||||
@ -136,8 +135,8 @@ public class Utils {
|
||||
}
|
||||
result.append("████\n");
|
||||
}
|
||||
for (int i=0; i<2; i++){
|
||||
for (int j=0;j<matrix.getWidth()+8; j++){
|
||||
for (int i = 0; i < 2; i++) {
|
||||
for (int j = 0; j < matrix.getWidth() + 8; j++) {
|
||||
result.append('█');
|
||||
}
|
||||
result.append('\n');
|
||||
|
@ -118,7 +118,7 @@ public class ServerProofOfWorkRepository extends JdbcHelper {
|
||||
try (Connection connection = config.getConnection()) {
|
||||
PreparedStatement ps = connection.prepareStatement(
|
||||
"DELETE FROM ProofOfWorkTask WHERE timestamp < ?");
|
||||
ps.setLong(1, UnixTime.now(-ageInSeconds));
|
||||
ps.setLong(1, UnixTime.now() - ageInSeconds);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
Loading…
Reference in New Issue
Block a user