Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix backward compatibility issue with avatar version #1797

Merged
Merged
Show file tree
Hide file tree
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 @@ -24,7 +24,7 @@

@Slf4j
public abstract class BucketConfig {
static final String CURRENT_VERSION = "v1";
static final int CURRENT_VERSION = 0;
static final String DIGIT = "#";
static final String SHAPE_NUMBER = "#SHAPE_NUMBER#";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public static Image getImage(UserProfile userProfile) {
userProfile.getAvatarVersion(), true);
}

public static Image getImage(byte[] pubKeyHash, byte[] powSolution, String avatarVersion) {
public static Image getImage(byte[] pubKeyHash, byte[] powSolution, int avatarVersion) {
return getImage(pubKeyHash, powSolution, avatarVersion, true);
}

public static Image getImage(byte[] pubKeyHash, byte[] powSolution, String avatarVersion, boolean useCache) {
public static Image getImage(byte[] pubKeyHash, byte[] powSolution, int avatarVersion, boolean useCache) {
byte[] combined = ByteArrayUtils.concat(powSolution, pubKeyHash);
BigInteger input = new BigInteger(combined);
if (useCache && CACHE.containsKey(input)) {
Expand All @@ -61,14 +61,14 @@ public static Image getImage(byte[] pubKeyHash, byte[] powSolution, String avata
return image;
}

public static String currentAvatarsVersion() {
public static int currentAvatarsVersion() {
return BucketConfig.CURRENT_VERSION;
}

private static BucketConfig getBucketConfig(String avatarVersion) {
private static BucketConfig getBucketConfig(int avatarVersion) {
BucketConfig bucketConfig;
switch (avatarVersion) {
case "v1": {
case 0: {
bucketConfig = new BucketConfigV1();
log.info("Creating v1 BucketConfig: {}", bucketConfig.getClass().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

@Slf4j
public class CreateNewProfileStep2Controller implements InitWithDataController<CreateNewProfileStep2Controller.InitData> {
private static final String CURRENT_AVATARS_VERSION = CatHash.currentAvatarsVersion();
private static final int CURRENT_AVATARS_VERSION = CatHash.currentAvatarsVersion();

@Getter
@ToString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

@Slf4j
public class CreateProfileController implements Controller {
private static final String CURRENT_AVATARS_VERSION = CatHash.currentAvatarsVersion();
private static final int CURRENT_AVATARS_VERSION = CatHash.currentAvatarsVersion();

protected final CreateProfileModel model;
@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public CompletableFuture<UserIdentity> createAndPublishNewUserProfile(String nic
KeyPair keyPair,
byte[] pubKeyHash,
ProofOfWork proofOfWork,
String avatarVersion,
int avatarVersion,
String terms,
String statement) {
String identityTag = nickName + "-" + Hex.encode(pubKeyHash);
Expand Down Expand Up @@ -315,7 +315,7 @@ private CompletableFuture<BroadcastResult> publishPublicUserProfile(UserProfile

private UserIdentity createUserIdentity(String nickName,
ProofOfWork proofOfWork,
String avatarVersion,
int avatarVersion,
String terms,
String statement,
Identity identity) {
Expand Down
4 changes: 2 additions & 2 deletions user/src/main/java/bisq/user/profile/UserProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static UserProfile from(UserProfile userProfile, String terms, String sta
private final String nickName;
// We need the proofOfWork for verification of the nym and cathash icon
private final ProofOfWork proofOfWork;
private final String avatarVersion;
private final int avatarVersion;
private final NetworkId networkId;
private final String terms;
private final String statement;
Expand All @@ -75,7 +75,7 @@ public static UserProfile from(UserProfile userProfile, String terms, String sta

public UserProfile(String nickName,
ProofOfWork proofOfWork,
String avatarVersion,
int avatarVersion,
NetworkId networkId,
String terms,
String statement) {
Expand Down
2 changes: 1 addition & 1 deletion user/src/main/proto/user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ message UserProfile {
security.ProofOfWork proofOfWork = 3;
string terms = 4;
string statement = 5;
string avatarVersion = 6;
sint32 avatarVersion = 6;
}

message UserIdentity {
Expand Down
Loading