Skip to content

Commit

Permalink
use millis instead of nanos
Browse files Browse the repository at this point in the history
  • Loading branch information
nkramer44 committed Sep 16, 2024
1 parent 1720832 commit d213a64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 39 deletions.
31 changes: 6 additions & 25 deletions xrpl4j-client/src/main/java/org/xrpl/xrpl4j/client/XrplClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,30 +133,10 @@ public XrplClient(final HttpUrl rippledUrl) {

/**
* Public constructor that allows for configuration of connect and read timeouts.
*
* @param rippledUrl The {@link HttpUrl} of the node to connect to.
* @param connectTimeout A {@code long} indicating the client's connect timeout.
* @param connectTimeoutUnit The {@link TimeUnit} that {@code connectTimeout} is denominated in.
* @param readTimeout A {@code long} indicating the client's read timeout.
* @param readTimeoutUnit The {@link TimeUnit} that {@code readTimeout} is denominated in.
*/
public XrplClient(
HttpUrl rippledUrl,
long connectTimeout,
TimeUnit connectTimeoutUnit,
long readTimeout,
TimeUnit readTimeoutUnit
) {
this(
JsonRpcClient.construct(
rippledUrl,
new Options(connectTimeout, connectTimeoutUnit, readTimeout, readTimeoutUnit, true)
)
);
}

/**
* Public constructor that allows for configuration of connect and read timeouts.
* <p>
* Note that any {@link Duration} passed in that is less than one millisecond will result in the actual timeout being
* zero milliseconds. It is therefore advised to never set {@code connectTimeout} or {@code readTimeout} to a
* {@link Duration} less than one millisecond.
*
* @param rippledUrl The {@link HttpUrl} of the node to connect to.
* @param connectTimeout A {@link Duration} indicating the client's connect timeout.
Expand All @@ -170,7 +150,8 @@ public XrplClient(
this(
JsonRpcClient.construct(
rippledUrl,
new Options(connectTimeout.toNanos(), TimeUnit.NANOSECONDS, readTimeout.toNanos(), TimeUnit.NANOSECONDS, true)
new Options(connectTimeout.toMillis(), TimeUnit.MILLISECONDS, readTimeout.toMillis(), TimeUnit.MILLISECONDS,
true)
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,20 +601,6 @@ public void getXrplClientTest() {
assertThat(new XrplClient(rippledUrl) instanceof JsonRpcClient).isFalse();
}

@Test
void createXrplClientWithTimeouts() {
HttpUrl rippledUrl = HttpUrl.parse("https://s.altnet.rippletest.net:51234");
XrplClient client = new XrplClient(
rippledUrl,
1,
TimeUnit.SECONDS,
2,
TimeUnit.MINUTES
);

assertThat(client).isInstanceOf(XrplClient.class);
}

@Test
void createXrplClientWithDurationTimeouts() {
HttpUrl rippledUrl = HttpUrl.parse("https://s.altnet.rippletest.net:51234");
Expand Down

0 comments on commit d213a64

Please sign in to comment.