Browse Source

Fixed various issues relating to syncing data for transactions without any chunks.

qdn
CalDescent 3 years ago
parent
commit
9850c294d1
  1. 3
      src/main/java/org/qortal/arbitrary/ArbitraryDataFile.java
  2. 15
      src/main/java/org/qortal/controller/ArbitraryDataManager.java
  3. 5
      src/main/java/org/qortal/repository/hsqldb/HSQLDBArbitraryRepository.java

3
src/main/java/org/qortal/arbitrary/ArbitraryDataFile.java

@ -390,6 +390,9 @@ public class ArbitraryDataFile {
return chunk.exists();
}
}
if (Arrays.equals(this.getHash(), hash)) {
return this.exists();
}
return false;
}

15
src/main/java/org/qortal/controller/ArbitraryDataManager.java

@ -287,8 +287,11 @@ public class ArbitraryDataManager extends Thread {
for (byte[] hash : hashes) {
//LOGGER.info("Received hash {}", Base58.encode(hash));
if (!arbitraryDataFile.containsChunk(hash)) {
LOGGER.info("Received non-matching chunk hash {} for signature {}", Base58.encode(hash), signature58);
return;
// Check the hash against the complete file
if (!Arrays.equals(arbitraryDataFile.getHash(), hash)) {
LOGGER.info("Received non-matching chunk hash {} for signature {}", Base58.encode(hash), signature58);
return;
}
}
}
@ -391,6 +394,12 @@ public class ArbitraryDataManager extends Thread {
}
}
}
else {
// This transaction has no chunks, so include the complete file if we have it
if (arbitraryDataFile.exists()) {
hashes.add(arbitraryDataFile.getHash());
}
}
}
} catch (DataException e) {
@ -403,7 +412,7 @@ public class ArbitraryDataManager extends Thread {
LOGGER.info("Couldn't send list of hashes");
peer.disconnect("failed to send list of hashes");
}
LOGGER.info("Sent list of hashes", hashes);
LOGGER.info("Sent list of hashes (count: {})", hashes.size());
}
}

5
src/main/java/org/qortal/repository/hsqldb/HSQLDBArbitraryRepository.java

@ -65,6 +65,11 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
return true;
}
// If this transaction doesn't have any chunks, then we require the complete file
if (chunkHashes == null) {
return false;
}
// Alternatively, if we have all the chunks, then it's safe to assume the data is local
if (arbitraryDataFile.allChunksExist(chunkHashes)) {
return true;

Loading…
Cancel
Save