forked from Qortal/qortal
Improved logging when fetching data files
This commit is contained in:
parent
cbe83987d8
commit
40a8cdc71f
@ -119,13 +119,16 @@ public class ArbitraryDataFileManager {
|
|||||||
if (!arbitraryDataFile.chunkExists(hash)) {
|
if (!arbitraryDataFile.chunkExists(hash)) {
|
||||||
// Only request the file if we aren't already requesting it from someone else
|
// Only request the file if we aren't already requesting it from someone else
|
||||||
if (!arbitraryDataFileRequests.containsKey(Base58.encode(hash))) {
|
if (!arbitraryDataFileRequests.containsKey(Base58.encode(hash))) {
|
||||||
|
LOGGER.debug("Requesting data file {} from peer {}", Base58.encode(hash), peer);
|
||||||
|
Long startTime = NTP.getTime();
|
||||||
ArbitraryDataFileMessage receivedArbitraryDataFileMessage = fetchArbitraryDataFile(peer, null, signature, hash, null);
|
ArbitraryDataFileMessage receivedArbitraryDataFileMessage = fetchArbitraryDataFile(peer, null, signature, hash, null);
|
||||||
|
Long endTime = NTP.getTime();
|
||||||
if (receivedArbitraryDataFileMessage != null) {
|
if (receivedArbitraryDataFileMessage != null) {
|
||||||
LOGGER.debug("Received data file {} from peer {}", receivedArbitraryDataFileMessage.getArbitraryDataFile().getHash58(), peer);
|
LOGGER.debug("Received data file {} from peer {}. Time taken: {} ms", receivedArbitraryDataFileMessage.getArbitraryDataFile().getHash58(), peer, (endTime-startTime));
|
||||||
receivedAtLeastOneFile = true;
|
receivedAtLeastOneFile = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOGGER.debug("Peer {} didn't respond with data file {} for signature {}", peer, Base58.encode(hash), Base58.encode(signature));
|
LOGGER.debug("Peer {} didn't respond with data file {} for signature {}. Time taken: {} ms", peer, Base58.encode(hash), Base58.encode(signature), (endTime-startTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -171,11 +174,11 @@ public class ArbitraryDataFileManager {
|
|||||||
private ArbitraryDataFileMessage fetchArbitraryDataFile(Peer peer, Peer requestingPeer, byte[] signature, byte[] hash, Message originalMessage) throws DataException {
|
private ArbitraryDataFileMessage fetchArbitraryDataFile(Peer peer, Peer requestingPeer, byte[] signature, byte[] hash, Message originalMessage) throws DataException {
|
||||||
ArbitraryDataFile existingFile = ArbitraryDataFile.fromHash(hash, signature);
|
ArbitraryDataFile existingFile = ArbitraryDataFile.fromHash(hash, signature);
|
||||||
boolean fileAlreadyExists = existingFile.exists();
|
boolean fileAlreadyExists = existingFile.exists();
|
||||||
|
String hash58 = Base58.encode(hash);
|
||||||
Message message = null;
|
Message message = null;
|
||||||
|
|
||||||
// Fetch the file if it doesn't exist locally
|
// Fetch the file if it doesn't exist locally
|
||||||
if (!fileAlreadyExists) {
|
if (!fileAlreadyExists) {
|
||||||
String hash58 = Base58.encode(hash);
|
|
||||||
LOGGER.debug(String.format("Fetching data file %.8s from peer %s", hash58, peer));
|
LOGGER.debug(String.format("Fetching data file %.8s from peer %s", hash58, peer));
|
||||||
arbitraryDataFileRequests.put(hash58, NTP.getTime());
|
arbitraryDataFileRequests.put(hash58, NTP.getTime());
|
||||||
Message getArbitraryDataFileMessage = new GetArbitraryDataFileMessage(signature, hash);
|
Message getArbitraryDataFileMessage = new GetArbitraryDataFileMessage(signature, hash);
|
||||||
@ -195,6 +198,9 @@ public class ArbitraryDataFileManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
LOGGER.debug(String.format("File hash %s already exists, so skipping the request", hash58));
|
||||||
|
}
|
||||||
ArbitraryDataFileMessage arbitraryDataFileMessage = (ArbitraryDataFileMessage) message;
|
ArbitraryDataFileMessage arbitraryDataFileMessage = (ArbitraryDataFileMessage) message;
|
||||||
|
|
||||||
// We might want to forward the request to the peer that originally requested it
|
// We might want to forward the request to the peer that originally requested it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user