Skip to content

Commit c14cf95

Browse files
committed
Make set-peer-data less strict to allow controllers with different keys
1 parent 98178d1 commit c14cf95

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,20 +2159,17 @@ public Context setPeerData(AccountKey peerKey, AHashMap<ACell, ACell> data) {
21592159

21602160
// get the callers account and account status
21612161
Address address = getAddress();
2162-
AccountStatus as = getAccountStatus(address);
21632162

2164-
AccountKey ak = as.getAccountKey();
2165-
if (ak == null) return withError(ErrorCodes.STATE,"The account signing this transaction must have a public key");
2166-
PeerStatus ps=s.getPeer(ak);
2167-
if (ps==null) return withError(ErrorCodes.STATE,"Peer does not exist for this account and account key: "+ak.toChecksumHex());
2168-
if (!ps.getController().equals(address)) return withError(ErrorCodes.STATE,"Current address "+address+" is not the controller of this peer account");
2163+
PeerStatus ps=s.getPeer(peerKey);
2164+
if (ps==null) return withError(ErrorCodes.STATE,"Peer does not exist for key: "+peerKey);
2165+
if (!Utils.equals(ps.getController(),address)) return withError(ErrorCodes.STATE,"Current address "+address+" is not the controller of this peer account");
21692166

21702167
Hash lastStateHash = s.getHash();
21712168
// TODO: should use complete Map
21722169
// at the moment only :url is used in the data map
21732170
AHashMap<ACell,ACell> newMeta=data;
21742171
PeerStatus updatedPeer=ps.withPeerData(newMeta);
2175-
s=s.withPeer(ak, updatedPeer); // adjust peer
2172+
s=s.withPeer(peerKey, updatedPeer); // adjust peer
21762173

21772174
// if no change just return the current context
21782175
if (lastStateHash.equals(s.getHash())){

0 commit comments

Comments
 (0)