Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,21 @@ public BigInteger getLatestBlockNumber() {

@Override
public String getNodeWithTheLatestBlockNumber() {
// the case that the sdk is allowed to access all the connected node, select the first
// connected node to send the request
if (nodeWithLatestBlockNumber.size() > 0) {
int random = (int) (Math.random() * (nodeWithLatestBlockNumber.size()));
return nodeWithLatestBlockNumber.get(random);
try {
// the case that the sdk is allowed to access all the connected node, select the first
// connected node to send the request
if (nodeWithLatestBlockNumber.size() > 0) {
// Note: when the nodeWithLatestBlockNumber modified, and the random value
// calculated after the modification, and the nodeWithLatestBlockNumber.get is
// called after the modification, this function will throw
// ArrayIndexOutOfBoundsException
int random = (int) (Math.random() * (nodeWithLatestBlockNumber.size()));
return nodeWithLatestBlockNumber.get(random);
}
} catch (Exception e) {
logger.error(
"getNodeWithTheLatestBlockNumber for {}, select the node to send message randomly",
e.getMessage());
}
// select the first element
if (!groupNodeSet.isEmpty()) {
Expand Down