forked from Qortal/qortal
Refactor to simplify some duplicated code
This commit is contained in:
parent
6d031130b9
commit
d7ddcda9da
@ -138,20 +138,11 @@ public class ArbitraryDataCleanupManager extends Thread {
|
||||
|
||||
|
||||
// Check to see if we should be hosting data for this transaction at all
|
||||
if (arbitraryTransactionData.getName() != null) {
|
||||
if (!storageManager.shouldStoreDataForName(arbitraryTransactionData.getName())) {
|
||||
LOGGER.info("Deleting transaction {} because we are no longer storing data for name {}",
|
||||
Base58.encode(arbitraryTransactionData.getSignature()), arbitraryTransactionData.getName());
|
||||
ArbitraryTransactionUtils.deleteCompleteFileAndChunks(arbitraryTransactionData);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Transaction has no name associated with it
|
||||
if (!storageManager.shouldStoreDataWithoutName()) {
|
||||
ArbitraryTransactionUtils.deleteCompleteFileAndChunks(arbitraryTransactionData);
|
||||
continue;
|
||||
}
|
||||
if (!storageManager.shouldStoreDataForName(arbitraryTransactionData.getName())) {
|
||||
LOGGER.info("Deleting transaction {} because we are no longer storing data for name {}",
|
||||
Base58.encode(arbitraryTransactionData.getSignature()), arbitraryTransactionData.getName());
|
||||
ArbitraryTransactionUtils.deleteCompleteFileAndChunks(arbitraryTransactionData);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check to see if we have had a more recent PUT
|
||||
|
@ -182,17 +182,9 @@ public class ArbitraryDataManager extends Thread {
|
||||
ArbitraryTransactionData arbitraryTransactionData = (ArbitraryTransactionData) arbitraryTransaction.getTransactionData();
|
||||
|
||||
// Skip transactions that we don't need to store data for
|
||||
if (arbitraryTransactionData.getName() != null) {
|
||||
if (!storageManager.shouldStoreDataForName(arbitraryTransactionData.getName())) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// Transaction has no name associated with it
|
||||
if (!storageManager.shouldStoreDataWithoutName()) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (!storageManager.shouldStoreDataForName(arbitraryTransactionData.getName())) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove transactions that we already have local data for
|
||||
|
@ -26,6 +26,10 @@ public class ArbitraryDataStorageManager {
|
||||
}
|
||||
|
||||
public boolean shouldStoreDataForName(String name) {
|
||||
if (name == null) {
|
||||
return this.shouldStoreDataWithoutName();
|
||||
}
|
||||
|
||||
switch (Settings.getInstance().getStoragePolicy()) {
|
||||
case FOLLOWED:
|
||||
case FOLLOWED_AND_VIEWED:
|
||||
@ -41,7 +45,7 @@ public class ArbitraryDataStorageManager {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldStoreDataWithoutName() {
|
||||
private boolean shouldStoreDataWithoutName() {
|
||||
switch (Settings.getInstance().getStoragePolicy()) {
|
||||
case ALL:
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user