forked from Qortal/qortal
Perform the base58 decoding outside of the arbitraryDataFileHashResponses lock, to reduce the amount of waiting around by other threads.
This commit is contained in:
parent
ab4ba9bb17
commit
0a88a0c95e
@ -45,8 +45,8 @@ public class ArbitraryDataFileRequestThread implements Runnable {
|
|||||||
ArbitraryDataFileManager arbitraryDataFileManager = ArbitraryDataFileManager.getInstance();
|
ArbitraryDataFileManager arbitraryDataFileManager = ArbitraryDataFileManager.getInstance();
|
||||||
|
|
||||||
ArbitraryTransactionData arbitraryTransactionData = null;
|
ArbitraryTransactionData arbitraryTransactionData = null;
|
||||||
byte[] signature = null;
|
String signature58 = null;
|
||||||
byte[] hash = null;
|
String hash58 = null;
|
||||||
Peer peer = null;
|
Peer peer = null;
|
||||||
boolean shouldProcess = false;
|
boolean shouldProcess = false;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public class ArbitraryDataFileRequestThread implements Runnable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String hash58 = (String) entry.getKey();
|
hash58 = (String) entry.getKey();
|
||||||
Triple<Peer, String, Long> value = (Triple<Peer, String, Long>) entry.getValue();
|
Triple<Peer, String, Long> value = (Triple<Peer, String, Long>) entry.getValue();
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -71,7 +71,7 @@ public class ArbitraryDataFileRequestThread implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
peer = value.getA();
|
peer = value.getA();
|
||||||
String signature58 = value.getB();
|
signature58 = value.getB();
|
||||||
Long timestamp = value.getC();
|
Long timestamp = value.getC();
|
||||||
|
|
||||||
if (now - timestamp >= ArbitraryDataManager.ARBITRARY_RELAY_TIMEOUT || signature58 == null || peer == null) {
|
if (now - timestamp >= ArbitraryDataManager.ARBITRARY_RELAY_TIMEOUT || signature58 == null || peer == null) {
|
||||||
@ -80,9 +80,6 @@ public class ArbitraryDataFileRequestThread implements Runnable {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = Base58.decode(hash58);
|
|
||||||
signature = Base58.decode(signature58);
|
|
||||||
|
|
||||||
// We want to process this file
|
// We want to process this file
|
||||||
shouldProcess = true;
|
shouldProcess = true;
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -95,6 +92,9 @@ public class ArbitraryDataFileRequestThread implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] hash = Base58.decode(hash58);
|
||||||
|
byte[] signature = Base58.decode(signature58);
|
||||||
|
|
||||||
// Fetch the transaction data
|
// Fetch the transaction data
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
arbitraryTransactionData = ArbitraryTransactionUtils.fetchTransactionData(repository, signature);
|
arbitraryTransactionData = ArbitraryTransactionUtils.fetchTransactionData(repository, signature);
|
||||||
@ -106,7 +106,6 @@ public class ArbitraryDataFileRequestThread implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String hash58 = Base58.encode(hash);
|
|
||||||
LOGGER.debug("Fetching file {} from peer {} via request thread...", hash58, peer);
|
LOGGER.debug("Fetching file {} from peer {} via request thread...", hash58, peer);
|
||||||
arbitraryDataFileManager.fetchArbitraryDataFiles(repository, peer, signature, arbitraryTransactionData, Arrays.asList(hash));
|
arbitraryDataFileManager.fetchArbitraryDataFiles(repository, peer, signature, arbitraryTransactionData, Arrays.asList(hash));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user