Don't allow new transactions to be submitted if not up to date

This commit is contained in:
catbref 2019-06-04 08:55:20 +01:00
parent 491a6ecd67
commit dcb8d67236
2 changed files with 5 additions and 1 deletions

View File

@ -14,6 +14,7 @@ public enum ApiError {
UNAUTHORIZED(4, 403), UNAUTHORIZED(4, 403),
REPOSITORY_ISSUE(5, 500), REPOSITORY_ISSUE(5, 500),
NON_PRODUCTION(6, 403), NON_PRODUCTION(6, 403),
BLOCKCHAIN_NEEDS_SYNC(7, 503),
// VALIDATION // VALIDATION
INVALID_SIGNATURE(101, 400), INVALID_SIGNATURE(101, 400),

View File

@ -408,9 +408,12 @@ public class TransactionsResource {
} }
) )
@ApiErrors({ @ApiErrors({
ApiError.INVALID_SIGNATURE, ApiError.INVALID_DATA, ApiError.TRANSFORMATION_ERROR, ApiError.REPOSITORY_ISSUE ApiError.BLOCKCHAIN_NEEDS_SYNC, ApiError.INVALID_SIGNATURE, ApiError.INVALID_DATA, ApiError.TRANSFORMATION_ERROR, ApiError.REPOSITORY_ISSUE
}) })
public String processTransaction(String rawBytes58) { public String processTransaction(String rawBytes58) {
if (!Controller.getInstance().isUpToDate())
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.BLOCKCHAIN_NEEDS_SYNC);
try (final Repository repository = RepositoryManager.getRepository()) { try (final Repository repository = RepositoryManager.getRepository()) {
byte[] rawBytes = Base58.decode(rawBytes58); byte[] rawBytes = Base58.decode(rawBytes58);