forked from Qortal/qortal
Arbitrary transaction names are now case insensitive
This commit is contained in:
parent
c8d5ac9248
commit
f0e13fa492
@ -24,7 +24,7 @@ public class ArbitraryDataBuildQueueItem {
|
|||||||
public static long FAILURE_TIMEOUT = 5*60*1000L; // 5 minutes
|
public static long FAILURE_TIMEOUT = 5*60*1000L; // 5 minutes
|
||||||
|
|
||||||
public ArbitraryDataBuildQueueItem(String resourceId, ResourceIdType resourceIdType, Service service) {
|
public ArbitraryDataBuildQueueItem(String resourceId, ResourceIdType resourceIdType, Service service) {
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId.toLowerCase();
|
||||||
this.resourceIdType = resourceIdType;
|
this.resourceIdType = resourceIdType;
|
||||||
this.service = service;
|
this.service = service;
|
||||||
this.creationTimestamp = NTP.getTime();
|
this.creationTimestamp = NTP.getTime();
|
||||||
|
@ -84,6 +84,9 @@ public class ArbitraryDataBuildManager implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeFromQueue(String resourceId) {
|
private void removeFromQueue(String resourceId) {
|
||||||
ArbitraryDataManager.getInstance().arbitraryDataBuildQueue.remove(resourceId);
|
if (resourceId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ArbitraryDataManager.getInstance().arbitraryDataBuildQueue.remove(resourceId.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,6 +272,10 @@ public class ArbitraryDataManager extends Thread {
|
|||||||
|
|
||||||
// Arbitrary data resource cache
|
// Arbitrary data resource cache
|
||||||
public boolean isResourceCached(String resourceId) {
|
public boolean isResourceCached(String resourceId) {
|
||||||
|
if (resourceId == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
resourceId = resourceId.toLowerCase();
|
||||||
|
|
||||||
// We don't have an entry for this resource ID, it is not cached
|
// We don't have an entry for this resource ID, it is not cached
|
||||||
if (this.arbitraryDataCachedResources == null) {
|
if (this.arbitraryDataCachedResources == null) {
|
||||||
@ -297,6 +301,11 @@ public class ArbitraryDataManager extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addResourceToCache(String resourceId) {
|
public void addResourceToCache(String resourceId) {
|
||||||
|
if (resourceId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resourceId = resourceId.toLowerCase();
|
||||||
|
|
||||||
// Just in case
|
// Just in case
|
||||||
if (this.arbitraryDataCachedResources == null) {
|
if (this.arbitraryDataCachedResources == null) {
|
||||||
this.arbitraryDataCachedResources = new HashMap<>();
|
this.arbitraryDataCachedResources = new HashMap<>();
|
||||||
@ -319,6 +328,7 @@ public class ArbitraryDataManager extends Thread {
|
|||||||
if (resourceId == null) {
|
if (resourceId == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
resourceId = resourceId.toLowerCase();
|
||||||
|
|
||||||
if (this.arbitraryDataBuildQueue == null) {
|
if (this.arbitraryDataBuildQueue == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -398,6 +408,7 @@ public class ArbitraryDataManager extends Thread {
|
|||||||
if (resourceId == null) {
|
if (resourceId == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
resourceId = resourceId.toLowerCase();
|
||||||
|
|
||||||
if (this.arbitraryDataFailedBuilds == null) {
|
if (this.arbitraryDataFailedBuilds == null) {
|
||||||
return false;
|
return false;
|
||||||
@ -537,7 +548,7 @@ public class ArbitraryDataManager extends Thread {
|
|||||||
// so that it is rebuilt the next time we serve it
|
// so that it is rebuilt the next time we serve it
|
||||||
if (arbitraryDataFile.exists() || arbitraryDataFile.allChunksExist(arbitraryTransactionData.getChunkHashes())) {
|
if (arbitraryDataFile.exists() || arbitraryDataFile.allChunksExist(arbitraryTransactionData.getChunkHashes())) {
|
||||||
if (arbitraryTransactionData.getName() != null) {
|
if (arbitraryTransactionData.getName() != null) {
|
||||||
String resourceId = arbitraryTransactionData.getName();
|
String resourceId = arbitraryTransactionData.getName().toLowerCase();
|
||||||
if (this.arbitraryDataCachedResources.containsKey(resourceId)) {
|
if (this.arbitraryDataCachedResources.containsKey(resourceId)) {
|
||||||
this.arbitraryDataCachedResources.remove(resourceId);
|
this.arbitraryDataCachedResources.remove(resourceId);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
"version, nonce, service, size, is_data_raw, data, chunk_hashes, " +
|
"version, nonce, service, size, is_data_raw, data, chunk_hashes, " +
|
||||||
"name, update_method, secret, compression FROM ArbitraryTransactions " +
|
"name, update_method, secret, compression FROM ArbitraryTransactions " +
|
||||||
"JOIN Transactions USING (signature) " +
|
"JOIN Transactions USING (signature) " +
|
||||||
"WHERE name = ? AND service = ?");
|
"WHERE lower(name) = ? AND service = ?");
|
||||||
|
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
sql.append(" AND update_method = ");
|
sql.append(" AND update_method = ");
|
||||||
@ -238,7 +238,7 @@ public class HSQLDBArbitraryRepository implements ArbitraryRepository {
|
|||||||
|
|
||||||
sql.append("ORDER BY created_when DESC LIMIT 1");
|
sql.append("ORDER BY created_when DESC LIMIT 1");
|
||||||
|
|
||||||
try (ResultSet resultSet = this.repository.checkedExecute(sql.toString(), name, service.value)) {
|
try (ResultSet resultSet = this.repository.checkedExecute(sql.toString(), name.toLowerCase(), service.value)) {
|
||||||
if (resultSet == null)
|
if (resultSet == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user