forked from Qortal/qortal
Modify API TransactionsResource to notify Controller after closing repository handle/session
This commit is contained in:
parent
c10a5db280
commit
1b50dd5adf
@ -510,14 +510,19 @@ public class TransactionsResource {
|
|||||||
if (!Controller.getInstance().isUpToDate())
|
if (!Controller.getInstance().isUpToDate())
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.BLOCKCHAIN_NEEDS_SYNC);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.BLOCKCHAIN_NEEDS_SYNC);
|
||||||
|
|
||||||
|
byte[] rawBytes = Base58.decode(rawBytes58);
|
||||||
|
|
||||||
|
TransactionData transactionData;
|
||||||
|
try {
|
||||||
|
transactionData = TransactionTransformer.fromBytes(rawBytes);
|
||||||
|
} catch (TransformationException e) {
|
||||||
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.TRANSFORMATION_ERROR, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (transactionData == null)
|
||||||
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
||||||
|
|
||||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||||
byte[] rawBytes = Base58.decode(rawBytes58);
|
|
||||||
|
|
||||||
TransactionData transactionData = TransactionTransformer.fromBytes(rawBytes);
|
|
||||||
|
|
||||||
if (transactionData == null)
|
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA);
|
|
||||||
|
|
||||||
Transaction transaction = Transaction.fromData(repository, transactionData);
|
Transaction transaction = Transaction.fromData(repository, transactionData);
|
||||||
|
|
||||||
if (!transaction.isSignatureValid())
|
if (!transaction.isSignatureValid())
|
||||||
@ -534,22 +539,18 @@ public class TransactionsResource {
|
|||||||
} finally {
|
} finally {
|
||||||
blockchainLock.unlock();
|
blockchainLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify controller of new transaction
|
|
||||||
Controller.getInstance().onNewTransaction(transactionData, null);
|
|
||||||
|
|
||||||
return "true";
|
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA, e);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.INVALID_DATA, e);
|
||||||
} catch (TransformationException e) {
|
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.TRANSFORMATION_ERROR, e);
|
|
||||||
} catch (ApiException e) {
|
|
||||||
throw e;
|
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw createTransactionInvalidException(request, ValidationResult.NO_BLOCKCHAIN_LOCK);
|
throw createTransactionInvalidException(request, ValidationResult.NO_BLOCKCHAIN_LOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Notify controller of new transaction
|
||||||
|
Controller.getInstance().onNewTransaction(transactionData, null);
|
||||||
|
|
||||||
|
return "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
|
Loading…
Reference in New Issue
Block a user