From 514847e1a4b4d6d780e6b673599a044b24cf91fa Mon Sep 17 00:00:00 2001 From: ohager Date: Sat, 29 Jun 2024 17:56:28 -0300 Subject: [PATCH 1/4] feat: added request timout --- src/main/java/signumj/Constants.java | 2 + .../java/signumj/service/NodeService.java | 81 +++++++++++-------- .../service/impl/UseBestNodeService.java | 38 ++++----- 3 files changed, 70 insertions(+), 51 deletions(-) diff --git a/src/main/java/signumj/Constants.java b/src/main/java/signumj/Constants.java index c1fcbc67..c258299f 100644 --- a/src/main/java/signumj/Constants.java +++ b/src/main/java/signumj/Constants.java @@ -13,4 +13,6 @@ public class Constants { public static final String HTTP_NODE_LOCAL_TESTNET = "http://localhost:6876"; public static final String HTTP_NODE_TESTNET = "https://europe3.testnet.signum.network"; + + public static final int HTTP_REQUEST_TIMEOUT = 30_000; } diff --git a/src/main/java/signumj/service/NodeService.java b/src/main/java/signumj/service/NodeService.java index 2e79783e..c731f7f0 100644 --- a/src/main/java/signumj/service/NodeService.java +++ b/src/main/java/signumj/service/NodeService.java @@ -15,19 +15,19 @@ import java.util.Set; public interface NodeService extends AutoCloseable { - + /** * @return the address of this node service */ String getAddress(); - + /** * Get a block via a block ID * @param block The block ID of the requested block * @return The block details, wrapped in a Single */ Single getBlock(SignumID block); - + /** * @return the blockchain status */ @@ -60,7 +60,7 @@ public interface NodeService extends AutoCloseable { * @return The constants, wrapped in a single */ Single getConstants(); - + /** * Get the account details of the specified account * @param accountId The address of the account @@ -70,7 +70,7 @@ public interface NodeService extends AutoCloseable { * @return The account details, wrapped in a single */ Single getAccount(SignumAddress accountId, Integer height, Boolean estimateCommitment, Boolean getCommittedAmount); - + /** * Get the account details of the specified account * @param accountId The address of the account @@ -134,7 +134,7 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi * @param quantityMinimum the minimum quantity for the number of accounts count (0 if null) * @param heightStart the height start for the volume and price statistics (past 24h if null) * @param heightEnd the height start for the volume and price statistics (past 24h if null) - * + * * @return The asset, wrapped in a single */ Single getAsset(SignumID assetId, SignumValue quantityMinimum, Integer heightStart, Integer heightEnd); @@ -148,12 +148,12 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi /** * Get the trades for a given asset - * + * * @param assetId The asset id * @param account The account of interest (optional) * @param firstIndex The first index (optional for pagination) * @param lastIndex The last index (optional for pagination) - * + * * @return A list trades, wrapped in a single */ Single getAssetTrades(SignumID assetId, SignumAddress account, Integer firstIndex, Integer lastIndex); @@ -161,7 +161,7 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi /** * Get the ask orders for a given asset * @param assetId The asset id - * + * * @return A list trades, wrapped in a single */ Single getAskOrders(SignumID assetId); @@ -169,30 +169,30 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi /** * Get the bid orders for a given asset * @param assetId The asset id - * + * * @return A list trades, wrapped in a single */ Single getBidOrders(SignumID assetId); - + /** * Get the aliases - * + * * @return A list of aliases, wrapped in a single */ Single getAliases(SignumAddress account, String aliasName, String tld, SignumTimestamp timestamp, Integer firstIndex, Integer lastIndex); /** * Get the TLDs. - * + * * @return all the Top Level Domains/Namespaces of the alias system. */ Single getTLDs(SignumTimestamp timestamp, Integer firstIndex, Integer lastIndex); /** * Get the subscriptions of a given account - * + * * @param account - * + * * @return A list of subscriptions, wrapped in a single */ Single getAccountSubscriptions(SignumAddress account); @@ -203,7 +203,7 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi * @return The details of the AT, wrapped in a single */ Single getAt(SignumAddress at); - + /** * Get the details for all ATs matching the given code hash Id * @param codeHashId The code hash ID we are filtering for @@ -211,7 +211,7 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi * @return The AT array */ Single getAts(SignumID codeHashId, Boolean includeDetails, Integer firstIndex, Integer lastIndex); - + /** * Get the details of an AT * @param at The address of the AT @@ -240,8 +240,8 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi * @return The transaction details, wrapped in a single */ Single getTransaction(byte[] fullHash); - - + + /** * Get the indirect incoming details for the given account and transaction * @param account @@ -301,7 +301,7 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi */ @Deprecated Single generateTransactionSetRewardRecipient(SignumAddress recipient, byte[] senderPublicKey, SignumValue fee, int deadline); - + /** * Generate a transaction with a plaintext message, please use {@link #generateTransaction(TransactionBuilder)} * @param recipient The recipient @@ -431,9 +431,9 @@ Single getAccountTransactions(SignumAddress accountId, Integer fi /** * Ask the node service to generate the unsigned bytes for the given transaction builder. - * + * * To sign the transaction, use {@link SignumCrypto#signTransaction(byte[], byte[])}. - * + * * @param builder the transaction builder * @return the unsigned bytes for the transaction */ @@ -641,7 +641,7 @@ Single generateDistributeToAssetHolders(byte[] senderPublicKey, SignumID * @param deadline The deadline for the transaction * @param message The encrypted message to include in the transaction * @param amount The SIGNA amount to send along with this transfer (optional) - * + * * @return The unsigned transaction bytes, wrapped in a single */ @Deprecated @@ -724,31 +724,48 @@ static NodeService getInstance(String nodeAddress) { } static NodeService getInstance(String nodeAddress, String userAgent) { + return getInstance(nodeAddress, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT); + } + + static NodeService getInstance(String nodeAddress, String userAgent, int requestTimeoutSecs) { if (userAgent == null) userAgent = "burstkit4j/" + signumj.Constants.VERSION; - return new HttpNodeService(nodeAddress, userAgent); + return new HttpNodeService(nodeAddress, userAgent, requestTimeoutSecs); } static NodeService getCompositeInstance(String... nodeAddresses) { return getCompositeInstanceWithUserAgent(null, nodeAddresses); } - + /** * Returns a node service instance that will use the best node of a list. - * + * * @param checkUpToDate check from time to time if the node is up-to-date or not (recent block) * @param userAgent the user agent * @param nodeAddresses the list of node addresses to choose the best one * @return a new node service instance */ static NodeService getUseBestInstance(boolean checkUpToDate, String userAgent, String... nodeAddresses) { - ArrayList nodeList = new ArrayList<>(); - for(String address : nodeAddresses) { - nodeList.add(getInstance(address, userAgent)); - } - return new UseBestNodeService(checkUpToDate, nodeList); + return getUseBestInstance(checkUpToDate, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT, nodeAddresses); } - static NodeService getCompositeInstanceWithUserAgent(String userAgent, String... nodeAddresses) { + /** + * Returns a node service instance that will use the best node of a list. + * + * @param checkUpToDate check from time to time if the node is up-to-date or not (recent block) + * @param userAgent the user agent + * @param requestTimeoutSecs Timeout for requests to node + * @param nodeAddresses the list of node addresses to choose the best one + * @return a new node service instance + */ + static NodeService getUseBestInstance(boolean checkUpToDate, String userAgent, int requestTimeoutSecs, String... nodeAddresses) { + ArrayList nodeList = new ArrayList<>(); + for(String address : nodeAddresses) { + nodeList.add(getInstance(address, userAgent, requestTimeoutSecs)); + } + return new UseBestNodeService(checkUpToDate, nodeList); + } + + static NodeService getCompositeInstanceWithUserAgent(String userAgent, String... nodeAddresses) { if (nodeAddresses.length == 0) throw new IllegalArgumentException("No node addresses specified"); if (nodeAddresses.length == 1) return getInstance(nodeAddresses[0], userAgent); return new CompositeNodeService(Arrays.stream(nodeAddresses) diff --git a/src/main/java/signumj/service/impl/UseBestNodeService.java b/src/main/java/signumj/service/impl/UseBestNodeService.java index 71579f1a..92350f82 100644 --- a/src/main/java/signumj/service/impl/UseBestNodeService.java +++ b/src/main/java/signumj/service/impl/UseBestNodeService.java @@ -40,38 +40,38 @@ /** * A node server using the 'best' of a list of nodes. - * + * * The best one is the one responding faster and that is up-to-date. - * + * * The best node is updated from time to time or when a call to the * current best one fails. - * + * */ @SuppressWarnings("deprecation") // TODO: remove after the deprecated methods are removed public class UseBestNodeService implements NodeService { - + private final List burstNodeServices; private NodeService firstWorkingNode; private AtomicReference bestNode = new AtomicReference<>(); private AtomicLong lastCheck = new AtomicLong(0L); private boolean checkUpToDate; - + private static final int LATE_BLOCK_MINUTES = 8; private final static long NODE_CHECK_INTERVAL_MILLIS = 4 * 60_000L; /** * A node server using a list of nodes, priority is given to the one responding faster and that is up-to-date. - * + * * @param burstNodeServices The burst node services this will wrap * @param checkUpToDate if true nodes that are not up-to-date have a lower priority */ public UseBestNodeService(boolean checkUpToDate, List burstNodeServices) { - if (burstNodeServices == null || burstNodeServices.size() == 0) + if (burstNodeServices == null || burstNodeServices.isEmpty()) throw new IllegalArgumentException("No Node Services Provided"); this.burstNodeServices = burstNodeServices; this.checkUpToDate = checkUpToDate; this.bestNode.set(burstNodeServices.get(0)); - + // Keep checking on nodes and adjusting the list Thread nodeChecker = new Thread("node-checker") { public void run() { @@ -80,7 +80,7 @@ public void run() { }; nodeChecker.start(); } - + @Override public String getAddress() { return bestNode.get().getAddress(); @@ -110,12 +110,12 @@ private void checkBestNode() { // lowest priority for late nodes elapsed += 1000; } - + if(elapsed < bestElapsed) { newNode = node; bestElapsed = elapsed; } - + if(firstWorkingNode == null) { // let's have at least a working node as soon as possible firstWorkingNode = node; @@ -127,7 +127,7 @@ private void checkBestNode() { } bestNode.set(newNode); } - + try { Thread.sleep(10); } catch (InterruptedException ignored) { @@ -135,9 +135,9 @@ private void checkBestNode() { } } } - + private Single performOnBest(Function> function) { - return function.apply(bestNode.get()).doOnError(throwable -> + return function.apply(bestNode.get()).doOnError(throwable -> // if this node fails, we reset the timer so we re-evaluate the nodes ASAP lastCheck.set(0L) ); @@ -350,7 +350,7 @@ public Observable getMiningInfo() { } } }); - + return obs.subscribeOn(SignumUtils.defaultNodeServiceScheduler()); } @@ -383,7 +383,7 @@ public Single generateMultiOutSameTransaction(byte[] senderPublicKey, Si public Single generateCreateATTransaction(byte[] senderPublicKey, SignumValue fee, int deadline, String name, String description, byte[] creationBytes, String referencedTransactionFullHash) { return performOnBest(service -> service.generateCreateATTransaction(senderPublicKey, fee, deadline, name, description, creationBytes, referencedTransactionFullHash)); } - + @Override public Single generateCreateATTransaction(byte[] senderPublicKey, SignumValue fee, SignumValue minActivation, int deadline, String name, String description, byte[] code, byte[] data, @@ -405,13 +405,13 @@ public Single generateTransferAssetMultiTransaction(byte[] senderPublicK public Single generateIssueAssetTransaction(byte[] senderPublicKey, String name, String description, SignumValue quantity, int decimals, SignumValue fee, int deadline) { return performOnBest(service -> service.generateIssueAssetTransaction(senderPublicKey, name, description, quantity, decimals, fee, deadline)); } - + @Override public Single generateAddAssetTreasuryAccountTransaction(SignumAddress recipient, byte[] senderPublicKey, String referencedTransactionFullHash, SignumValue fee, int deadline) { return performOnBest(service -> service.generateAddAssetTreasuryAccountTransaction(recipient, senderPublicKey, referencedTransactionFullHash, fee, deadline)); } - + @Override public Single generateDistributeToAssetHolders(byte[] senderPublicKey, SignumID assetId, SignumValue quantityMinimumQNT, SignumValue amount, SignumID assetToDistribute, SignumValue quantityQNT, @@ -448,7 +448,7 @@ public Single generatePlaceBidOrderTransaction(byte[] senderPublicKey, S public Single generateCancelAskOrderTransaction(byte[] senderPublicKey, SignumID orderId, SignumValue fee, int deadline) { return performOnBest(service -> service.generateCancelAskOrderTransaction(senderPublicKey, orderId, fee, deadline)); } - + @Override public Single generateCancelBidOrderTransaction(byte[] senderPublicKey, SignumID orderId, SignumValue fee, int deadline) { return performOnBest(service -> service.generateCancelBidOrderTransaction(senderPublicKey, orderId, fee, deadline)); From 575882de577893ab9b5c12f1c742b4b90ade0958 Mon Sep 17 00:00:00 2001 From: ohager Date: Sat, 29 Jun 2024 17:58:23 -0300 Subject: [PATCH 2/4] chore: using default constant --- .../signumj/service/impl/HttpNodeService.java | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/java/signumj/service/impl/HttpNodeService.java b/src/main/java/signumj/service/impl/HttpNodeService.java index 9bed813c..276b24e7 100644 --- a/src/main/java/signumj/service/impl/HttpNodeService.java +++ b/src/main/java/signumj/service/impl/HttpNodeService.java @@ -39,15 +39,15 @@ public final class HttpNodeService implements NodeService { private String nodeAddress; public HttpNodeService(String nodeAddress, String userAgent) { - this(nodeAddress, userAgent, 10); + this(nodeAddress, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT); } - + public HttpNodeService(String nodeAddress, String userAgent, int readTimeout) { - + this.nodeAddress = nodeAddress; SocketFactory socketFactory = SocketFactory.getDefault(); Dns dns = Dns.SYSTEM; - + OkHttpClient okHttpClient = new OkHttpClient.Builder() .readTimeout(readTimeout, TimeUnit.SECONDS) .socketFactory(socketFactory) @@ -61,7 +61,7 @@ public HttpNodeService(String nodeAddress, String userAgent, int readTimeout) { apiService = retrofit.create(SignumAPIService.class); } - + @Override public String getAddress() { return nodeAddress; @@ -107,7 +107,7 @@ public Single getBlocks(int firstIndex, int lastIndex) { .map(response -> Arrays.stream(response.getBlocks()).map(Block::new) .collect(Collectors.toList()).toArray(new Block[0])); } - + @Override public Single getBlockChainStatus() { return assign(apiService.getBlockchainStatus(SignumUtils.getEndpoint()).map(BlockchainStatus::new)); @@ -168,7 +168,7 @@ public Single getAccountTransactions(SignumAddress accountId, Int .map(response -> Arrays.stream(response.getTransactions()).map(Transaction::new) .toArray(Transaction[]::new)); } - + @Override public Single getUnconfirmedTransactions(SignumAddress accountId) { return assign(apiService.getUnconfirmedTransactions(SignumUtils.getEndpoint(), accountId==null ? null : accountId.getID())) @@ -213,7 +213,7 @@ public Single getBidOrders(SignumID assetId) { return assign(apiService.getBidOrders(SignumUtils.getEndpoint(), assetId.getID())) .map(response -> Arrays.stream(response.getOrders()).map(AssetOrder::new).toArray(AssetOrder[]::new)); } - + @Override public Single getAliases(SignumAddress account, String aliasName, String tld, SignumTimestamp timestamp, Integer firstIndex, Integer lastIndex) { @@ -221,14 +221,14 @@ public Single getAliases(SignumAddress account, String aliasName, Strin timestamp == null ? null : String.valueOf(timestamp.getTimestamp()), firstIndex, lastIndex)) .map(response -> Arrays.stream(response.getAliases()).map(Alias::new).toArray(Alias[]::new)); } - + @Override public Single getTLDs(SignumTimestamp timestamp, Integer firstIndex, Integer lastIndex) { return assign(apiService.getTLDs(SignumUtils.getEndpoint(), timestamp == null ? null : String.valueOf(timestamp.getTimestamp()), firstIndex, lastIndex)) .map(response -> Arrays.stream(response.getTLDs()).map(TLD::new).toArray(TLD[]::new)); } - + @Override public Single getAccountSubscriptions(SignumAddress account) { return assign(apiService.getAccountSubscriptions(SignumUtils.getEndpoint(), account)) @@ -239,7 +239,7 @@ public Single getAccountSubscriptions(SignumAddress account) { public Single getAt(SignumAddress atId) { return getAt(atId, null); } - + @Override public Single getAt(SignumAddress atId, Boolean includeDetails) { return assign(apiService.getAt(SignumUtils.getEndpoint(), atId.getID(), includeDetails)).map(AT::new); @@ -250,7 +250,7 @@ public Single getAtIds(SignumID codeHashId) { return assign(apiService.getAtIds(SignumUtils.getEndpoint(), codeHashId == null ? null : codeHashId.getID())).map( response -> Arrays.stream(response.getAtIds()).map(SignumAddress::fromId).toArray(SignumAddress[]::new)); } - + @Override public Single getAts(SignumID codeHashId, Boolean includeDetails, Integer firstIndex, Integer lastIndex) { return assign(apiService.getAts(SignumUtils.getEndpoint(), codeHashId.getID(), includeDetails, firstIndex, lastIndex).map( @@ -280,7 +280,7 @@ public Single getTransactionBytes(SignumID transactionId) { return assign(apiService.getTransactionBytes(SignumUtils.getEndpoint(), transactionId.getID())) .map(response -> Hex.decode(response.getTransactionBytes())); } - + @Override public Single generateTransaction(TransactionBuilder builder) { String url = SignumUtils.getEndpoint() + "?requestType=" + builder.getRequestType(); @@ -411,7 +411,7 @@ public Single generateIssueAssetTransaction(byte[] senderPublicKey, Stri decimals, null, Hex.toHexString(senderPublicKey), fee.toNQT().toString(), deadline, null, false, null, null, null, null, null, null, null, null, null, null)) .map(response -> Hex.decode(response.getUnsignedTransactionBytes())); } - + @Override public Single generateAddAssetTreasuryAccountTransaction(SignumAddress recipient, byte[] senderPublicKey, String referencedTransactionFullHash, SignumValue fee, int deadline) { @@ -419,7 +419,7 @@ public Single generateAddAssetTreasuryAccountTransaction(SignumAddress r fee.toNQT().toString(), deadline, referencedTransactionFullHash, false, null, false, null, false, null, null, null, false, null, null)) .map(response -> Hex.decode(response.getUnsignedTransactionBytes())); } - + @Override public Single generateDistributeToAssetHolders(byte[] senderPublicKey, SignumID assetId, SignumValue quantityMinimumQNT, SignumValue amount, SignumID assetToDistribute, SignumValue quantityQNT, @@ -438,10 +438,10 @@ public Single generateTransferAssetTransaction(byte[] senderPublicKey, S null, Hex.toHexString(senderPublicKey), fee.toNQT().toString(), deadline, null, false, null, null, null, null, null, null, null, null, null, null)) .map(response -> Hex.decode(response.getUnsignedTransactionBytes())); } - + @Override public Single generateTransferAssetMultiTransaction(byte[] senderPublicKey, SignumAddress recipient, Map assetIdAndQuantity, SignumValue amount, SignumValue fee, int deadline) { - + StringBuilder assetIdAndQuantityString = new StringBuilder(); if (assetIdAndQuantity.size() > 4 || assetIdAndQuantity.size() < 2) { throw new IllegalArgumentException("Must have 2-4 assets, had " + assetIdAndQuantity.size()); @@ -451,7 +451,7 @@ public Single generateTransferAssetMultiTransaction(byte[] senderPublicK .append(";"); } assetIdAndQuantityString.setLength(assetIdAndQuantityString.length() - 1); - + return assign(apiService.transferAssetMulti(SignumUtils.getEndpoint(), recipient.getID(),null, assetIdAndQuantityString.toString(), amount == null ? null : amount.toNQT().toString(), null, Hex.toHexString(senderPublicKey), fee.toNQT().toString(), deadline, null, false, null, null, null, null, null, null, null, null, null, null)) .map(response -> Hex.decode(response.getUnsignedTransactionBytes())); @@ -546,7 +546,7 @@ public Observable getMiningInfo() { } })); } - + @Override public Single getMiningInfoSingle() { return apiService.getMiningInfo(SignumUtils.getEndpoint()).map(this::checkBrsResponse).map(MiningInfo::new); @@ -556,7 +556,7 @@ public Single getMiningInfoSingle() { public Single broadcastTransaction(byte[] transactionBytes) { if (transactionBytes.length >= 2560) { return assign(apiService.broadcastTransactionBig(SignumUtils.getEndpoint(), Hex.toHexString(transactionBytes))) - .map(TransactionBroadcast::new); + .map(TransactionBroadcast::new); } return assign(apiService.broadcastTransaction(SignumUtils.getEndpoint(), Hex.toHexString(transactionBytes))) .map(TransactionBroadcast::new); @@ -626,7 +626,7 @@ public Single generateCreateATTransaction(byte[] senderPublicKey, Signum if (response.getError() != null) throw new IllegalArgumentException(response.getError()); return response; - }).map(response -> Hex.decode(response.getUnsignedTransactionBytes())); + }).map(response -> Hex.decode(response.getUnsignedTransactionBytes())); } return assign(apiService.createATProgram(SignumUtils.getEndpoint(), Hex.toHexString(senderPublicKey), fee.toNQT().toString(), deadline, referencedTransactionFullHash, false, name, description, Hex.toHexString(creationBytes), null, @@ -721,25 +721,25 @@ Single getAssetAccounts(@Path("endpoint") String endpoint @GET("{endpoint}?requestType=getTrades") Single getAssetTrades(@Path("endpoint") String endpoint, @Query("asset") String assetId, @Query("account") String account, @Query("firstIndex") Integer firstIndex, @Query("lastIndex") Integer lastIndex); - + @GET("{endpoint}?requestType=getAskOrders") Single getAskOrders(@Path("endpoint") String endpoint, @Query("asset") String assetId); - + @GET("{endpoint}?requestType=getBidOrders") Single getBidOrders(@Path("endpoint") String endpoint, @Query("asset") String assetId); @GET("{endpoint}?requestType=getAliases") Single getAliases(@Path("endpoint") String endpoint, @Query("account") String accountId, @Query("aliasName") String aliasName, @Query("tld") String tld, @Query("timestamp") String timestamp, @Query("firstIndex") Integer firstIndex, @Query("lastIndex") Integer lastIndex); - + @GET("{endpoint}?requestType=getTLDs") Single getTLDs(@Path("endpoint") String endpoint, @Query("timestamp") String timestamp, @Query("firstIndex") Integer firstIndex, @Query("lastIndex") Integer lastIndex); - + @GET("{endpoint}?requestType=getAccountSubscriptions") Single getAccountSubscriptions(@Path("endpoint") String endpoint, @Query("account") SignumAddress account); - + @GET("{endpoint}?requestType=getAT") Single getAt(@Path("endpoint") String endpoint, @Query("at") String atId, @Query("includeDetails") Boolean includeDetails); @@ -761,7 +761,7 @@ Single getIndirectIncoming(@Path("endpoint") String en @GET("{endpoint}?requestType=getTransactionBytes") Single getTransactionBytes(@Path("endpoint") String endpoint, @Query("transaction") String transaction); - + @POST Single generateTransaction(@Url String url, @QueryMap Map params, @Body String body); @@ -874,7 +874,7 @@ Single addAssetTreasuryAccount(@Path("endpoint") St @Query("messageToEncryptToSelfIsText") Boolean messageToEncryptToSelfIsText, @Query("encryptedToSelfMessageData") String encryptedToSelfMessageData, @Query("encryptedToSelfMessageNonce") String encryptedToSelfMessageNonce); - + @POST("{endpoint}?requestType=distributeToAssetHolders") Single distributeToAssetHolders(@Path("endpoint") String endpoint, @Query("asset") String asset, @@ -974,8 +974,8 @@ Single cancelAskOrder(@Path("endpoint") String endp @Query("messageToEncryptToSelfIsText") Boolean messageToEncryptToSelfIsText, @Query("encryptedToSelfMessageData") String encryptedToSelfMessageData, @Query("encryptedToSelfMessageNonce") String encryptedToSelfMessageNonce); - - + + @POST("{endpoint}?requestType=cancelBidOrder") Single cancelBidOrder(@Path("endpoint") String endpoint, @Query("order") String order, @@ -1072,13 +1072,13 @@ Single createATProgram(@Path("endpoint") String endpoint, @Query("code") String code, @Query("data") String data, @Query("dpages") int dpages, @Query("cspages") int cspages, @Query("uspages") int uspages, @Query("minActivationAmountNQT") String minActivationAmountNQT); - + @POST("{endpoint}?requestType=createATProgram") Single createATProgramBig(@Path("endpoint") String endpoint, @Query("publicKey") String publicKey, @Query("feeNQT") String fee, @Query("deadline") int deadline, @Query("referencedTransactionFullHash") String referencedTransactionFullHash, @Query("broadcast") boolean broadcast, @Query("name") String name, - @Query("description") String description, @Body String creationBytes, + @Query("description") String description, @Body String creationBytes, @Query("code") String code, @Query("data") String data, @Query("dpages") int dpages, @Query("cspages") int cspages, @Query("uspages") int uspages, @Query("minActivationAmountNQT") String minActivationAmountNQT); From 7dfe9b0f281f543de21222cdb980d73ea3a895a1 Mon Sep 17 00:00:00 2001 From: ohager Date: Sat, 29 Jun 2024 17:59:56 -0300 Subject: [PATCH 3/4] chore: consider seconds for default param --- src/main/java/signumj/Constants.java | 2 +- src/main/java/signumj/service/NodeService.java | 4 ++-- src/main/java/signumj/service/impl/HttpNodeService.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/signumj/Constants.java b/src/main/java/signumj/Constants.java index c258299f..7ce122d5 100644 --- a/src/main/java/signumj/Constants.java +++ b/src/main/java/signumj/Constants.java @@ -14,5 +14,5 @@ public class Constants { public static final String HTTP_NODE_TESTNET = "https://europe3.testnet.signum.network"; - public static final int HTTP_REQUEST_TIMEOUT = 30_000; + public static final int HTTP_REQUEST_TIMEOUT_SECS = 30; } diff --git a/src/main/java/signumj/service/NodeService.java b/src/main/java/signumj/service/NodeService.java index c731f7f0..8ca685df 100644 --- a/src/main/java/signumj/service/NodeService.java +++ b/src/main/java/signumj/service/NodeService.java @@ -724,7 +724,7 @@ static NodeService getInstance(String nodeAddress) { } static NodeService getInstance(String nodeAddress, String userAgent) { - return getInstance(nodeAddress, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT); + return getInstance(nodeAddress, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT_SECS); } static NodeService getInstance(String nodeAddress, String userAgent, int requestTimeoutSecs) { @@ -745,7 +745,7 @@ static NodeService getCompositeInstance(String... nodeAddresses) { * @return a new node service instance */ static NodeService getUseBestInstance(boolean checkUpToDate, String userAgent, String... nodeAddresses) { - return getUseBestInstance(checkUpToDate, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT, nodeAddresses); + return getUseBestInstance(checkUpToDate, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT_SECS, nodeAddresses); } /** diff --git a/src/main/java/signumj/service/impl/HttpNodeService.java b/src/main/java/signumj/service/impl/HttpNodeService.java index 276b24e7..fbf9dcdf 100644 --- a/src/main/java/signumj/service/impl/HttpNodeService.java +++ b/src/main/java/signumj/service/impl/HttpNodeService.java @@ -39,7 +39,7 @@ public final class HttpNodeService implements NodeService { private String nodeAddress; public HttpNodeService(String nodeAddress, String userAgent) { - this(nodeAddress, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT); + this(nodeAddress, userAgent, signumj.Constants.HTTP_REQUEST_TIMEOUT_SECS); } public HttpNodeService(String nodeAddress, String userAgent, int readTimeout) { From ef1138ad3fd22b0e8b0e955e42a1d2138064d174 Mon Sep 17 00:00:00 2001 From: ohager Date: Sat, 29 Jun 2024 18:03:14 -0300 Subject: [PATCH 4/4] chore: minor change --- src/main/java/signumj/service/impl/UseBestNodeService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/signumj/service/impl/UseBestNodeService.java b/src/main/java/signumj/service/impl/UseBestNodeService.java index 92350f82..880c47a2 100644 --- a/src/main/java/signumj/service/impl/UseBestNodeService.java +++ b/src/main/java/signumj/service/impl/UseBestNodeService.java @@ -491,7 +491,7 @@ public Single generateTransactionRemoveCommitment(byte[] senderPublicKey @Override public Single getBlockChainStatus() { - return performOnBest(service -> service.getBlockChainStatus()); + return performOnBest(NodeService::getBlockChainStatus); } @Override