Merge remote-tracking branch 'origin/master'

This commit is contained in:
kennycud 2024-09-27 19:26:17 -07:00
commit 7c4b0bd7f2
4 changed files with 77 additions and 7 deletions

View File

@ -20,10 +20,7 @@ import org.qortal.asset.Asset;
import org.qortal.controller.LiteNode;
import org.qortal.controller.OnlineAccountsManager;
import org.qortal.crypto.Crypto;
import org.qortal.data.account.AccountData;
import org.qortal.data.account.AccountPenaltyData;
import org.qortal.data.account.RewardShareData;
import org.qortal.data.account.SponsorshipReport;
import org.qortal.data.account.*;
import org.qortal.data.network.OnlineAccountData;
import org.qortal.data.network.OnlineAccountLevel;
import org.qortal.data.transaction.PublicizeTransactionData;
@ -668,7 +665,7 @@ public class AddressesResource {
description = "Returns sponsorship statistics for an account's sponsor",
responses = {
@ApiResponse(
description = "the statistics",
description = "statistics",
content = @Content(mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = SponsorshipReport.class)))
)
}
@ -698,4 +695,31 @@ public class AddressesResource {
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
}
}
}
@GET
@Path("/levels/{minLevel}")
@Operation(
summary = "Return accounts with levels greater than or equal to input",
responses = {
@ApiResponse(
description = "online accounts",
content = @Content(mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = AddressLevelPairing.class)))
)
}
)
@ApiErrors({ApiError.REPOSITORY_ISSUE})
public List<AddressLevelPairing> getAddressLevelPairings(@PathParam("minLevel") int minLevel) {
try (final Repository repository = RepositoryManager.getRepository()) {
// get the level address pairings
List<AddressLevelPairing> pairings = repository.getAccountRepository().getAddressLevelPairings(minLevel);
return pairings;
} catch (DataException e) {
throw ApiExceptionFactory.INSTANCE.createException(request, ApiError.REPOSITORY_ISSUE, e);
}
}
}

View File

@ -0,0 +1,43 @@
package org.qortal.data.account;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import java.util.Arrays;
// All properties to be converted to JSON via JAXB
@XmlAccessorType(XmlAccessType.FIELD)
public class AddressLevelPairing {
private String address;
private int level;
// Constructors
// For JAXB
protected AddressLevelPairing() {
}
public AddressLevelPairing(String address, int level) {
this.address = address;
this.level = level;
}
// Getters / setters
public String getAddress() {
return address;
}
public int getLevel() {
return level;
}
@Override
public String toString() {
return "SponsorshipReport{" +
"address='" + address + '\'' +
", level=" + level +
'}';
}
}

View File

@ -165,7 +165,9 @@ public interface AccountRepository {
*/
public Optional<String> getSponsor(String address) throws DataException;
/** How to order results when fetching asset balances. */
public List<AddressLevelPairing> getAddressLevelPairings(int minLevel) throws DataException;
/** How to order results when fetching asset balances. */
public enum BalanceOrdering {
/** assetID first, then balance, then account address */
ASSET_BALANCE_ACCOUNT,

View File

@ -1,5 +1,6 @@
package org.qortal.repository.hsqldb;
import cash.z.wallet.sdk.rpc.Service;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.qortal.asset.Asset;