Skip to content

Commit d2646f6

Browse files
committed
Misc fixes
1 parent e45b478 commit d2646f6

File tree

8 files changed

+32
-5
lines changed

8 files changed

+32
-5
lines changed

convex-core/src/main/java/convex/core/cvm/Peer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,5 +777,9 @@ private PeerIndex getPeerIndex() {
777777
return peerIndex;
778778
}
779779

780+
public SignedData<ATransaction> getTransaction(Hash transactionID) {
781+
return getPeerIndex().getTransaction(this, transactionID);
782+
}
783+
780784

781785
}

convex-core/src/main/java/convex/core/cvm/PeerIndex.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,10 @@ public Result getTransactionResult(Peer peer,ABlob txID) {
6363
return peer.getBlockResult(loc.get(0).longValue()).getResult(loc.get(1).longValue());
6464
}
6565

66+
public SignedData<ATransaction> getTransaction(Peer peer, Hash transactionID) {
67+
AVector<CVMLong> loc=txLocations.get(transactionID);
68+
if (loc==null) return null;
69+
return peer.getPeerOrder().getBlock(loc.get(0).longValue()).getValue().getTransactions().get(loc.get(1).longValue());
70+
}
71+
6672
}

convex-core/src/main/java/convex/core/lang/RT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ public static AString str(ACell a) {
11001100
* Converts a value to a Java String representation
11011101
*
11021102
* @param a Any CVM value
1103-
* @return Java String representation. May be "nil".
1103+
* @return Java String representation. May be "nil" for null values.
11041104
*/
11051105
public static String toString(ACell a) {
11061106
return toString(a, Constants.PRINT_LIMIT);

convex-core/src/main/java/convex/core/util/CAIP.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ public static ACell parseAssetID(AString assetID) {
6969

7070
/**
7171
* Gets the asset ID for a CAD29 token from a CAPI-19 string
72-
* @param caip19
73-
* @return CAD29 asset ID, or CONVEX_ASSET_ID contant if the String refers to CVM
72+
* @param caip19 CAIP19 Format asset ID, e.g. "cad29:72"
73+
* @return CAD29 asset ID, or CONVEX_ASSET_ID constant if the String refers to CVM
7474
* @throw IllegalArgumentException if String is not a valid token ID
7575
*/
7676
public static ACell parseTokenID(String caip19) {
@@ -99,7 +99,7 @@ public static ACell parseTokenID(String caip19) {
9999
} catch (ParseException | IndexOutOfBoundsException e) {
100100
throw new IllegalArgumentException("Invalid CAIP19 asset for Convex: "+caip19,e);
101101
}
102-
throw new IllegalArgumentException("Only CAD29 assets currently supported on Convex, but CAIP19 code was: "+caip19);
102+
throw new IllegalArgumentException("Only CVM or CAD29 assets currently supported on Convex, but CAIP19 code was: "+caip19);
103103
}
104104

105105
/**

convex-core/src/main/java/convex/core/util/JSONUtils.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,20 @@ private static BlobBuilder appendWhitespaceString(BlobBuilder sb, long count) {
416416

417417
private static void appendCVMStringQuoted(BlobBuilder bb, CharSequence cs) {
418418
int n = cs.length();
419+
419420
for (int i = 0; i < n; i++) {
420421
char c = cs.charAt(i);
421422
AString rep = getReplacementString(c);
422423
if (rep != null) {
423424
bb.append(rep);
424425
} else {
425-
bb.append(c);
426+
if (Character.isSurrogate(c)) {
427+
int codePoint=Character.codePointAt(cs, i);
428+
bb.append(CVMChar.create(codePoint));
429+
i++;
430+
} else {
431+
bb.append(c);
432+
}
426433
}
427434
}
428435
}

convex-core/src/main/java/convex/lattice/ALattice.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
public abstract class ALattice<V extends ACell> {
99

10+
11+
1012
/**
1113
* Implementation of merge function
1214
* @param ownValue Own lattice value

convex-core/src/main/java/convex/lattice/MaxLattice.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
*/
1010
public class MaxLattice extends ALattice<AInteger> {
1111

12+
private MaxLattice() {
13+
// private to enforce Singleton
14+
}
15+
1216
private static final MaxLattice INSTANCE = new MaxLattice();
1317

1418
@Override

convex-core/src/main/java/convex/lattice/SetLattice.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
*/
1212
public class SetLattice<V extends ACell> extends ALattice<ASet<V>> {
1313

14+
private SetLattice() {
15+
// private to enforce Singleton
16+
}
17+
1418
private static final SetLattice<?> INSTANCE = new SetLattice<>();
1519

1620
@Override

0 commit comments

Comments
 (0)